Jump to content

JasonP

Members
  • Content Count

    22
  • Joined

  • Last visited


Reputation Activity

  1. Like
    JasonP reacted to Fmilburn in Serial/Serial1@57600bps on MSP432R Launchpad won't work   
    It did not work on Serial back to the terminal when I tried it just now but I don't have any other information on the implementation.
  2. Like
    JasonP reacted to Rei Vilo in Software Serial library use   
    Currently, there's one single UART port implemented for the MSP432. A ticket asks for secondary ports to be implemented as well (UART, I
  3. Like
    JasonP reacted to Fmilburn in Software Serial library use   
    @@JasonP
     
    I just ran your sketch above in Energia v17 with MSP-432 and get the following at the bottom of the compilation output
    In other words, SoftwareSerial.h was not included with Energia for the MSP432.
     
    Further, the other Serial hardware pins don't show on the Energia pin map so perhaps additional hardware access (i.e. use of Serial1) is not included for the MSP432 either.  The thing to do might be to access the serial hardware directly but I realize that isn't particularly satisfying for an Energia user.
  4. Like
    JasonP reacted to Rickta59 in Software Serial library use   
    The msp432 has up to 4 hardware UARTS, I don't know what Energia supports.  Do you really need SoftwareSerial?
  5. Like
    JasonP reacted to Rickta59 in Software Serial library use   
    Seems like it supports at least Serial and Serial1. This compiles:
    /* Multple serial test Receives from the main serial port, sends to the others. Receives from serial port 1, sends to the main serial (Serial 0). The circuit: * Any serial device attached to Serial port 1 * Serial monitor open on Serial port 0: created 30 Dec. 2008 by Tom Igoe This example code is in the public domain. */   void setup() { // initialize both serial ports: Serial.begin(9600); Serial1.begin(9600); } void loop() { // read from port 1, send to port 0: if (Serial1.available()) { int inByte = Serial1.read(); Serial.write(inByte); } }
  6. Like
    JasonP reacted to Rickta59 in Software Serial library use   
    It looks like all that stuff is now hidden in a binary blob that doesn't come with source code.
    $ arm-none-eabi-nm -C hardware/emt/ti/runtime/wiring/msp432/lib/wiring_msp432.m4fg.lib | grep Serial HardwareSerial.om4fg: 00000000 t _GLOBAL__sub_I__ZN14HardwareSerialC2Ev 00000000 B Serial 00000000 B Serial1 00000000 T HardwareSerial::readCallback(UART_Config*, void*, unsigned int) 00000000 T HardwareSerial::end() 00000000 T HardwareSerial::init(unsigned long) 00000000 T HardwareSerial::peek() 00000000 T HardwareSerial::read() 00000000 T HardwareSerial::begin(unsigned long) 00000000 T HardwareSerial::flush() 00000000 T HardwareSerial::write(unsigned char) 00000000 T HardwareSerial::write(unsigned char const*, unsigned int) 00000000 T HardwareSerial::acquire() 00000000 T HardwareSerial::release() 00000000 T HardwareSerial::setPins(unsigned long) 00000000 T HardwareSerial::flushAll() 00000000 T HardwareSerial::available() 00000000 T HardwareSerial::setModule(unsigned long) 00000000 T HardwareSerial::HardwareSerial(unsigned long) 00000000 T HardwareSerial::HardwareSerial() 00000000 T HardwareSerial::HardwareSerial(unsigned long) 00000000 T HardwareSerial::HardwareSerial() 00000000 T HardwareSerial::operator bool() 00000000 R vtable for HardwareSerial It appears that only Serial and Serial1 are implemented.
     
    This is a question for @@energia
     
    -rick
  7. Like
    JasonP got a reaction from abecedarian in MSP432 digitalRead() / Interrupt not working?   
    @@abecedarian,  Ha ha I was just writing to say thank you to everyone that has pitched in and helped me, especially you!  Honestly I don't see a better workaround for the time being and things are actually working flawless.  Spitting the two interrupts into two is actually nice as each interrupt is much simpler.  Thanks again.
    ////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////// I N T E R R U P T //////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////// void risingA(){ // Must be a low-to-high on channel A Ahigh = true; // The pin must be high to get here. // check channel B to see which way encoder is turning if (!Bhigh) { encoder0Pos++; // CW direction = 1; } else { encoder0Pos--; // CCW direction = 2; } } ////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////// I N T E R R U P T //////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////// void fallingA(){ // must be a high-to-low edge on channel A Ahigh = false; // check channel B to see which way encoder is turning if (Bhigh) { encoder0Pos++; // CW direction = 1; } else { encoder0Pos--; // CCW direction = 2; } } ////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////// I N T E R R U P T //////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////// void risingB(){ // Must be a low-to-high on channel B Bhigh = true; // check channel A to see which way encoder is turning if (Ahigh) { encoder0Pos++; // CW direction = 1; } else { encoder0Pos--; // CCW direction = 2; } } ////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////// I N T E R R U P T //////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////// void fallingB(){ Bhigh = false; // must be a high-to-low on channel B sensblast = false; // check channel B to see which way encoder is turning if (!Ahigh) { encoder0Pos++; // CW direction = 1; } else { encoder0Pos--; // CCW direction = 2; } }
  8. Like
    JasonP reacted to abecedarian in MSP432 digitalRead() / Interrupt not working?   
    Okay... put something together... a little simplified, but using the EMT abilities... and "CHANGE". One part eschews using Serial for debugging and sets up the "Aflag" variable and configures pin 11 as in input with an interrupt handler using CHANGE, the handler does a "NOT" on the Aflag variable when called, and loop() sets the RED LED to the Aflag state. The other is a "thread" which sets up another pin (12) to automatically turn on and off every 1/10 second.
     
    So, create new sketch in Energia and put the following in it:

    const int encoder0PinA = 11; volatile bool Aflag; void setup(){ pinMode(encoder0PinA,INPUT); Aflag = digitalRead(encoder0PinA); attachInterrupt(encoder0PinA, doEncoderA, CHANGE); pinMode(78, OUTPUT); // RED single LED on board } void loop(){ digitalWrite(78, Aflag); } void doEncoderA(){ Aflag = !Aflag; }Then make a new tab, name it "blink", then paste the following code in:
    void setupBlink() { pinMode(12, OUTPUT); digitalWrite(12,HIGH); } void loopBlink() { delay(100); digitalWrite(12, LOW); delay(100); digitalWrite(12,HIGH); }Then, connect a jumper between pins 11 and 12 and upload the program. 
    "CHANGE" does in fact work... this way at least.
     
    Makes me wonder if using a physical switch without debouncing, or something with Serial might be culprit...?
     
    *edit: changed the value in the delay() in "blink" to a few different values and couldn't see any issues.
     
    *edit-2: tried to do digitalRead() in the interrupt and that still does not work.
  9. Like
    JasonP reacted to abecedarian in MSP432 digitalRead() / Interrupt not working?   
    A little wasteful of GPIO and code space perhaps, but could you not send the encoder's signals to two pins each and attach rising and falling interrupt handlers / functions to those pins separately?
  10. Like
    JasonP reacted to chicken in MSP432 digitalRead() / Interrupt not working?   
    I think the proposed Aflag ^= 1 workaround does not really solve your problem. You still only get an interrupt on one of the transitions (high-low or low-high), but instead of reading the current pin state, you simply inverse the current state of the variable.
     
    From reading the e2e thread and without reading at the datasheet, it looks like the MSP432 hardware only supports configuring the interrupt for one of the transitions at a time, i.e. no native support of CHANGE.
     
    It could be worked around by re-configuring within the interrupt. E.g. if currently high, trigger on going low; if currently low, trigger on going high. Calling attachInterrupt within the interrupt probably won't work, so you'd have to go to the register level to implement that.
     
    Maybe there's already an Energia library for reading quadrature encoders that takes care of those low-level details.
  11. Like
    JasonP reacted to Fmilburn in MSP432 digitalRead() / Interrupt not working?   
    @@JasonP
     
    I added it to your issue
  12. Like
    JasonP reacted to Fmilburn in MSP432 digitalRead() / Interrupt not working?   
    I modified the code to use the buttons so that I didn't have to hook up an encoder.  Something in Energia doesn't process "CHANGE" from the attachInterrupt() function properly either.  It works as expected on a F5529 and catches rising and falling edges but not on the MSP432.
     
    @@JasonP - The following "works" but will only catch one edge
    const int encoder0PinA = PUSH1; const int encoder0PinB = PUSH2; volatile int pinACount = 0; volatile int pinBCount = 0; volatile bool Aflag = false; volatile bool Bflag = false; /////////////////////////////////////////////////////////////////////////////////// ////////////////////////////// S E T U P ////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////// void setup(){ Serial.begin(115200); Serial.println("COUNTER STARTING UP"); pinMode(encoder0PinA,INPUT_PULLUP); pinMode(encoder0PinB,INPUT_PULLUP); attachInterrupt(encoder0PinA, doEncoderA, CHANGE); attachInterrupt(encoder0PinB, doEncoderB, CHANGE); } /////////////////////////////////////////////////////////////////////////////////// //////////////////////////////// L O O P ////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////// void loop(){ // SANITY CHECK Serial.println(digitalRead(encoder0PinA)); // Here to see that the pin does change states Serial.println(pinACount); Serial.println(digitalRead(encoder0PinB)); // Here to see that the pin does change states Serial.println(pinBCount); Serial.print("A Flag: "); Serial.print(Aflag); // I never see either of these get set to 1. Serial.print(" B Flag: "); Serial.println(Bflag); ; Serial.println(); delay(500); } void doEncoderA(){ pinACount++; if (Aflag == 0) { Aflag = 1; } else { Aflag = 0; } } void doEncoderB(){ pinBCount++; if (Bflag == 0) { Bflag = 1; } else { Bflag = 0; } }
  13. Like
    JasonP reacted to energia in MSP432 digitalRead() / Interrupt not working?   
    Would you please be so kind to file an issue on github here: https://github.com/energia/Energia/issues
     
    Thanks!
     
    Robert
  14. Like
    JasonP reacted to energia in MSP432 digitalRead() / Interrupt not working?   
    It seems that you have stumbled on a bug. I was able to reproduce it.
    Odd thing is that I am able to read a pin that has not seen attachedInterrupt() and see the flag change if I digitalRead() that pin in the interrupt routine.
     
    I'll look into it.
     
    Robert
  15. Like
    JasonP got a reaction from Fmilburn in Is there a way in Energia to access the LPM's?   
    Hello everyone,
     
    I just wanted to post an update on my MSP432 project.  Today after a few hours of messing around trying to get RTC interrupts working properly I gave up.  I did have a calendar based event trigger an interrupt but afterwards I was in no mans land.  All code execution stopped and I wasn't quite sure were I was ending up.  I suppose thats where the power of CCS comes in?  
     
    Anyways, I have seen the comment posted several times "when the processor is in an idle, it automagically enters a low power state".  A few days ago this was the first thing I tried, but it didn't seem to change the power consumption much.  I assumed it was entering LPM0 or LPM1 because during the delay state I was still up around 4.5mA.  After failing miserably with the RTC interrupt I figured I would re-explore this. 
     
    Huge thanks to @@dubnet for posting this
     
     
    The key words in there are long delays.  After I added delay(10000); in each of my loops I saw the current all the way down to 2.5uA!!!!  The trick to get this low of current is to make sure to end Serial if it is used.... Serial.end(); Otherwise I could never get below 1.5mA.  Thank you @@energia for this awesome MT platform!  I can now use interrupt based code with delays() in my loops and achieve my power budget goals. 
     
    I really only wished I had paid more attention to what was right in front of me or someone had spelled it out clearer.  
     
    LONG DELAYS = LOW POWER!
     
    IF YOU HAVE A MULTIPLE SKETCHES, ALL LOOPS MUST DELAY TO ENTER THIS LOW POWER STATE.  A FREE SPINNING LOOP IS NOT IDLE. 
     
     
    Cheers!
  16. Like
    JasonP got a reaction from dubnet in Is there a way in Energia to access the LPM's?   
    Hello everyone,
     
    I just wanted to post an update on my MSP432 project.  Today after a few hours of messing around trying to get RTC interrupts working properly I gave up.  I did have a calendar based event trigger an interrupt but afterwards I was in no mans land.  All code execution stopped and I wasn't quite sure were I was ending up.  I suppose thats where the power of CCS comes in?  
     
    Anyways, I have seen the comment posted several times "when the processor is in an idle, it automagically enters a low power state".  A few days ago this was the first thing I tried, but it didn't seem to change the power consumption much.  I assumed it was entering LPM0 or LPM1 because during the delay state I was still up around 4.5mA.  After failing miserably with the RTC interrupt I figured I would re-explore this. 
     
    Huge thanks to @@dubnet for posting this
     
     
    The key words in there are long delays.  After I added delay(10000); in each of my loops I saw the current all the way down to 2.5uA!!!!  The trick to get this low of current is to make sure to end Serial if it is used.... Serial.end(); Otherwise I could never get below 1.5mA.  Thank you @@energia for this awesome MT platform!  I can now use interrupt based code with delays() in my loops and achieve my power budget goals. 
     
    I really only wished I had paid more attention to what was right in front of me or someone had spelled it out clearer.  
     
    LONG DELAYS = LOW POWER!
     
    IF YOU HAVE A MULTIPLE SKETCHES, ALL LOOPS MUST DELAY TO ENTER THIS LOW POWER STATE.  A FREE SPINNING LOOP IS NOT IDLE. 
     
     
    Cheers!
  17. Like
    JasonP got a reaction from spirilis in Is there a way in Energia to access the LPM's?   
    Hello everyone,
     
    I just wanted to post an update on my MSP432 project.  Today after a few hours of messing around trying to get RTC interrupts working properly I gave up.  I did have a calendar based event trigger an interrupt but afterwards I was in no mans land.  All code execution stopped and I wasn't quite sure were I was ending up.  I suppose thats where the power of CCS comes in?  
     
    Anyways, I have seen the comment posted several times "when the processor is in an idle, it automagically enters a low power state".  A few days ago this was the first thing I tried, but it didn't seem to change the power consumption much.  I assumed it was entering LPM0 or LPM1 because during the delay state I was still up around 4.5mA.  After failing miserably with the RTC interrupt I figured I would re-explore this. 
     
    Huge thanks to @@dubnet for posting this
     
     
    The key words in there are long delays.  After I added delay(10000); in each of my loops I saw the current all the way down to 2.5uA!!!!  The trick to get this low of current is to make sure to end Serial if it is used.... Serial.end(); Otherwise I could never get below 1.5mA.  Thank you @@energia for this awesome MT platform!  I can now use interrupt based code with delays() in my loops and achieve my power budget goals. 
     
    I really only wished I had paid more attention to what was right in front of me or someone had spelled it out clearer.  
     
    LONG DELAYS = LOW POWER!
     
    IF YOU HAVE A MULTIPLE SKETCHES, ALL LOOPS MUST DELAY TO ENTER THIS LOW POWER STATE.  A FREE SPINNING LOOP IS NOT IDLE. 
     
     
    Cheers!
  18. Like
    JasonP reacted to dubnet in Is there a way in Energia to access the LPM's?   
    With the MSP432 Launchpad you can use CCS6 and Energy Trace to measure LPM supply currents. You can import your Energia sketches into CCS and do full debug as well.  I haven't had a lot of success getting much below 100uA on the 432 with my testing, both with Energia MT using long delays in the program, and with a TI LPM3 (maybe LPM3.5, can't remember for sure) demo program under CCS.  Under Energia I shut down the serial port prior to the delay (which helped) and the CCS demo program supposedly put all the ports in a low power configuration prior to calling LPM3.x  I am sure that I am missing something and am planning to dig deeper when I get some free time. 
  19. Like
    JasonP got a reaction from dubnet in Is there a way in Energia to access the LPM's?   
    #include "driverlib.h" #include "msp.h" /* Standard Includes */ #include <stdint.h> #include <stdbool.h> volatile int state = HIGH; volatile int flag = HIGH; int count = 0; void setup(){ Serial.begin(9600); delay(1000); Serial.println("Starting setup"); delay(1000); //Set all I/0s as out put except for reset and power pins. setPins_LowPower(); // Set pin mode for interrupt pinMode(73, INPUT_PULLUP); pinMode(GREEN_LED,OUTPUT); attachInterrupt(73, blink, FALLING); // Interrupt is fired whenever button is pressed Serial.println("Done with setup"); delay(1000); } void loop(){ if(state) { digitalWrite(GREEN_LED, state); //LED starts ON } else{ digitalWrite(GREEN_LED, state); //delay(1000); if(flag){ flag = LOW; Serial.begin(9600); Serial.println(count); Serial.end(); // Without ending Serial I was not able to enter LPM3 lowpower(); } } } void blink() { //count++; state = !state; flag = HIGH; } void setPins_LowPower(){ for (int i = 2; i < 11; i++) { pinMode(i, OUTPUT); digitalWrite(i, LOW); } for (int i = 11; i < 16; i++) { pinMode(i, OUTPUT); digitalWrite(i, LOW); } for (int i = 17; i < 20; i++) { pinMode(i, OUTPUT); digitalWrite(i, LOW); } for (int i = 23; i < 79; i++) { pinMode(i, OUTPUT); digitalWrite(i, LOW); } } void lowpower(){ MAP_WDT_A_holdTimer(); // Turn off watchdog timer? //MAP_RTC_C_holdClock(); // Turn off RTC MAP_PSS_disableHighSide(); // MAP_PSS_disableLowSide(); // MAP_PCM_gotoLPM3(); } So I threw a Hail Mary with with bits and pieces I have found from this forum and TI's forum.  The above code although a bit scabby, toggles the MSP-432 in and out of LPM3 mode.  While the device is in low power mode the the LED is off.  While out of low power mode the LED is on.  Not sure how to handle debouncing of the button but it seems to work well enough to get the idea of power consumption.
     
    **************************************************
    @3.3V
     
    LPM3 / LED OFF ~ 2.5uA !! low power
    ACTIVE / LED ON ~12mA
    ACTIVE/ LED OFF ~6mA
     
    ***************************************************
    I was happy to see "count" is maintained after entering and exiting LPM3.  There are still some quirks to get passed such as delay() doesn't work after calling my lowpower() function and coming back, but that's not too surprising since I disabled WDT?  Also without Serial.end() the device never reaches a low power state.  It gets stuck somewhere in between at about 4.5mA.  I will keep playing with this to see if I can completely come back from LPM3 with full functionality.
     
    Anyways things are looking OK thus far but I realized today that I need a way to wake the device on some specified time interval also.  I was thinking an RTC interrupt but I am looking for some advice on this.  I am finding snippets of code here and there but nothing really concrete yet.  
     
    I would be grateful if anyone can verify those sleep currents with the above code and give and or advise on timer interrupt in LPM3.
     
    Thanks guys.
  20. Like
    JasonP reacted to jpnorair in Using RTC as an ultra-low-power timer for the likes of MSP432   
    I posted a blog entry about how I used the STM32L1 RTC (a few years ago) as a tickless, ultra-low-power timer for my RTOS.  http://www.indigresso.com/_blog/?p=181
     
    The MSP432 has a similar problem.  Only the RTC and Watchdogs run in LPM3 and 3.5, no other timers do, but you want to use those LPMs for timed sleep!  There is a workaround, and it is actually very fast thanks to the really great ALU in the CM3 and CM4 devices.  My code is also implemented in bulletproof production firmware that I've shipped to various industries .
     
    Yes, the code is for STM32L1, but I think you should be able to very easily port it to MSP432.  If you wait long enough, I already will have ported it, but I noticed some forum activity on this very topic last week and I had to step in.
     
    Happy Coding.
  21. Like
    JasonP reacted to Fmilburn in Is there a way in Energia to access the LPM's?   
    Hi @@JasonP and welcome.  The code you referenced will not compile because it is for the MSP430 and you are using a MS432.  The MSP432 is different in that it uses Energia MT and can multi-task.  When it is idle it automatically enters a low power mode so you don't need to do anything it in Energia.  See for example this discussion:  http://forum.43oh.com/topic/8896-msp432-energia-code-composer-studio/
×
×
  • Create New...