st3al 1 Posted July 14, 2012 Share Posted July 14, 2012 Hi, i've a G2211 laying around and i can confirm that it is working using it as LaunchPad w/ msp430g2231. I've tried the following sketches and all of them works OK. Blink Fade Button Debounce AnalogInput it's really weird, i've connected a pot in the pin P1_5 as i've wrote it in the code. I've just tried connecting the center tap to pin P1_7 and now it's working. The command Serial.Begin doesn't work: AnalogReadSerial.cpp.o: In function `setup': C:\Users\Dani\AppData\Local\Temp\build1421017437023774230.tmp/AnalogReadSerial.cpp:12: undefined reference to `Serial' C:\Users\Dani\AppData\Local\Temp\build1421017437023774230.tmp/AnalogReadSerial.cpp:12: undefined reference to `HardwareSerial::begin(unsigned long)' AnalogReadSerial.cpp.o: In function `loop': C:\Users\Dani\AppData\Local\Temp\build1421017437023774230.tmp/AnalogReadSerial.cpp:17: undefined reference to `Serial' collect2: ld returned 1 exit status Quote Link to post Share on other sites
energia 484 Posted July 14, 2012 Share Posted July 14, 2012 The Serail.xxx API is for Hardware Serial. The G2231 does not have a Hardware Serial peripheral. You can use the timer based TimerSerial. TimerSerial example is in: File->Examples->TimerSerial. Also see https://github.com/energia/Energia/wiki/Know-Issues for a bug fix for TimerSerial on the msp430g2231. Sorry to have to make you jump through hoops. Robert st3al 1 Quote Link to post Share on other sites
st3al 1 Posted July 15, 2012 Author Share Posted July 15, 2012 Thanks! here i'll post some sketches that works: delay time set by an analog input int sensorPin = 7; int ledPin = 14; int sensorValue = 0; void setup() { pinMode(ledPin, OUTPUT); } void loop() { sensorValue = analogRead(sensorPin); digitalWrite(ledPin, HIGH); delay(sensorValue); digitalWrite(ledPin, LOW); delay(sensorValue); } If you declare PIN 7 (P1_5) as input, then, connect the wiper on PIN 15(P1_7). Maybe the pin mapping is wrong. const int sensorPin = 7; const int ledPin = 14; int sensorValue = 0; int sensorMin = 1023; int sensorMax = 0; void setup() { pinMode(13, OUTPUT); digitalWrite(13, HIGH); while (millis() < 5000) { sensorValue = analogRead(sensorPin); if (sensorValue > sensorMax) { sensorMax = sensorValue; } if (sensorValue < sensorMin) { sensorMin = sensorValue; } } digitalWrite(13, LOW); } void loop() { sensorValue = analogRead(sensorPin); sensorValue = map(sensorValue, sensorMin, sensorMax, 0, 255); sensorValue = constrain(sensorValue, 0, 255); analogWrite(ledPin, sensorValue); } map() it's working very well. Quote Link to post Share on other sites
energia 484 Posted July 15, 2012 Share Posted July 15, 2012 Also see post for a working TimerSerial example: viewtopic.php?f=38&t=2808&start=10 Quote Link to post Share on other sites
st3al 1 Posted July 16, 2012 Author Share Posted July 16, 2012 Thanks Robert! Here it's the example StateChangeDetection working! #include TimerSerial mySerial; const int buttonPin = PUSH2; const int ledPin = RED_LED; int buttonPushCounter = 0; int buttonState = 0; int lastButtonState = 0; void setup() { pinMode(buttonPin, INPUT_PULLUP); pinMode(ledPin, OUTPUT); mySerial.begin(); } void loop() { buttonState = digitalRead(buttonPin); if (buttonState != lastButtonState) { if (buttonState == LOW) { buttonPushCounter++; mySerial.println("on"); mySerial.print("number of button pushes: "); mySerial.println(buttonPushCounter); } else { mySerial.println("off"); } } lastButtonState = buttonState; if (buttonPushCounter % 4 == 0) { digitalWrite(ledPin, HIGH); } else { digitalWrite(ledPin, LOW); } if (buttonPushCounter % 3 == 0) { digitalWrite(GREEN_LED, HIGH); } else{ digitalWrite(GREEN_LED, LOW); } } Rickta59 1 Quote Link to post Share on other sites
maudette 0 Posted July 19, 2012 Share Posted July 19, 2012 I'm also having issues with the TimerSerial - it won't compile (at least on OSX) /Applications/Energia.app/Contents/Resources/Java/hardware/msp430/libraries/TimerSerial/TimerSerial.cpp: In static member function 'static void TimerSerial::RxIsr()': /Applications/Energia.app/Contents/Resources/Java/hardware/msp430/libraries/TimerSerial/TimerSerial.cpp:205:16: error: 'TA0IV_TACCR1' was not declared in this scope The code I am trying to compile is here #include TimerSerial mySerial; const int ledPin = 14; // the pin that the LED is attached to int incomingByte; // a variable to read incoming serial data into void setup() { // initialize serial communication: mySerial.begin(); // initialize the LED pin as an output: pinMode(ledPin, OUTPUT); } void loop() { // see if there's incoming serial data: if (mySerial.available() > 0) { // read the oldest byte in the serial buffer: incomingByte = mySerial.read(); // if it's a capital H (ASCII 72), turn on the LED: if (incomingByte == 'H') { digitalWrite(ledPin, HIGH); } // if it's an L (ASCII 76) turn off the LED: if (incomingByte == 'L') { digitalWrite(ledPin, LOW); } } } NOTE - even the TimerSerial example won't compile for me....same error. If I edit the "timerSerial.cpp" and comment the lines as follows it compiles and runs as expected. //Timer A1 interrupt service routine __attribute__((interrupt(TIMERA1_VECTOR))) void TimerSerial::RxIsr(void) { static unsigned char rxBitCnt = 8; static unsigned char rxData = 0; //#ifdef TIMER0_A1_VECTOR // if ( TA0IV == TA0IV_TACCR1 ) { // this mcu has multiple TIMERA peripherals //#else if ( TAIV == TAIV_TACCR1 ) { //#endif Quote Link to post Share on other sites
Rickta59 589 Posted July 19, 2012 Share Posted July 19, 2012 If you are adventuresome you might grab the latest version from source. I checked in fixes for all this stuff. You don't have to explicitly include the TimerSerial stuff now. The code now creates a Serial instance based on your chip. For g2231/g2542 chips it will pick the TimerSerial, for g2553 it will use HardwareSerial. It also allows you to change the baud rate with TimerSerial and automatically limits it to 4800 if you are running at 1MHz so that it will work properly. Source is here: https://github.com/energia/Energia/commits/master Comments and changes I made to fix the issue here: https://github.com/energia/Energia/pull/86 check it out cd build ant clean build run -rick st3al and energia 2 Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.