This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

RTOS/SIMPLELINK-MSP432-SDK: Using RTC to trigger an event every 6 hours instead of watchdog

Part Number: SIMPLELINK-MSP432-SDK
Other Parts Discussed in Thread: ENERGYTRACE, TPS22810

Tool/software: TI-RTOS

Hi Team,

My application at present triggers an event every 6 hours and once that event is completed it registers the time with the data in the file on SD card.

At the moment we are using watchdog to execute this task.

However, the limitation of using watchdog is that we cannot put the unit in the deep sleep mode.

And in order to utilize the feature of deep sleep we have to use the RTC (real time clock).

Please can someone share information on how to trigger the RTC every 6 hours so as we can trigger the event and also once the event has accomplished how can we get the real time to be written into the SD card for the file written?

I have went through the forum and the document and also the header file "rtc_c.h" but it only shows how we can trigger every minute or every hour certain minute pass the hour.

For us, whenever we start the unit (msp432) every 6 hours after the start of the unit, the rtc should trigger the event and we need to get the time at the rtc triggered.

I am using the SimpleLink MSP432 SDK RTOS version.

  • You will need to figure out two things.

    1. How to wake up the mcu via rtc?

    2. How to set up the rtc so it wakes up every 6 hours? I would check to see. If your rtc has an alarm function. Set the alarm to trigger an interrupt every 6 hours. Inhe isr, renew the alarm for another 6 hours and do you thing before put the mcu to sleep.
  • As a side note:

    To utilize either RTC or WDT, the lowest you can go is LPM3.5. Both RTC and WDT are sourced from the 32.768KHz clock. All other modules are off. I am not sure why you are assuming there would be further power reduction using RTC vs. WDT. In fact, powering the silicon needed for the RTC module could consume more energy than a WDT wakeup / counter increment with single branching instruction.

    As for the actual question:

    The RTC module is by default set to utilize 1Hz clock. All you need would be:

    * zero all registers to get 12:00am.

    * set the alarm at 6:00am (trigger after 6 hours).

    * do the above at the end of what you need to do when the alarm triggers.

  • Thank you Danny and Mike for your feedback.

    Two main reasons for using RTC instead of Watchdog.

    1. As per the forum information earlier that I had obtained it said that in order to take advantage of Deep Sleep Mode I have to use the RTC instead of Watchdog. This is because my firmware is based on RTOS and the timer used in RTOS for watchdog does not allow the processor to go into deep sleep mode. Hence, in order to take the advantage of deep sleep mode I opted to use RTC.

    But as per you saying Mike, it would not matter if we used watchdog or rtc, both will let the processor go into deep sleep mode. Is that correct?

    2. The firmware written includes writing data onto SD card once the event is triggered every 6 hours. So I would like to get the real time at which this data is written onto the SD card.

    Using the seconds module only gives me relative time in the sense that I have to always hard code the current time using Second_set() function and the time at which the data is written is achieved relative to this time.

    In practice I need the processor gives the real time and not relative time and hence RTC was selected.

    The point is that the data that is going to be written onto the SD card or the event that is going to be triggered every 6 hours is not always starting at 00:00 hours it could be any time of the day so that's why RTC was needed.

    Please share your thoughts whether this is feasible or not?

    Vikram

  • P.S. My original input was based on non-RTOS solution. This being said:

    On the WDT vs RTC using RTOS: This depends on the configurations of the RTOS, but I still believe with proper settings it would not matter.

    On point 2: You should be able to do it with absolute time (+/- error of your LF XT and given no power interruption). You would need a method to synchronize the internal RTC to the actual time. The alarm function can be set based on current time plus 6 hours. So, it is very feasible.

  • I think reading the datasheet confirming the questions I posted earlier would be the most productive approach for you.
  • Thank you Mike. But how to synchronize the internal RTC to actual time? Sorry as I am using the RTC for first time I am not aware how this would work?
  • Thank you Danny. I have gone through the data sheet and did found that using the ALARM option to trigger every specified hours can be done.
    But it is as if you want to trigger at specific time which is not the case. I don't have a specified time but I have specified interval
  • You do realize that future time = current time plus desired interval?

    So before you put your mcu to sleep, set up the alarm 6 hours later. And you mcu will wake up from it then. That doesn't work for you?
  • To synchronize the RTC, you would need to implement a communication link to the design over which you would send a time-sync packet. You could do this using multiple methods including:
    * An RFID receiver on your design and create an app (or another device) that sends the time data once in close proximity.
    * UART (RS-232) communication to a software.
    * USB.
    * Bluetooth / WiFi.
    * IR
    * Bit banging over one of the I/Os
    * Dip switch plus an I/O trigger.

    or any other I/O method.
  • Everything comes to a halt. I was believing till now that since I was using WDT i was not able to enter the deep sleep mode.
    But works out that even with RTC I am not able to go into deep sleep mode.

    So I have turned back to WDT application usage.
    I tried to debug and found that the value of the "sleepState" variable in the "Power_sleep" function in file PowerMSP432.c is never set to 4 which is the macro value for PowerMSP432_DEEPSLEEP_1 as defined in file PowerMSP432.h

    Can you pls suggest why the value of the sleepState never sets to 4 or even 2 which is the macro value of PowerMSP432_DEEPSLEEP_0.
  • Vikram,
    Can you access the software associated with this design? In this implementation the WDT is used to wake up the MSP432P device from LPM3 (deep sleep 0). The interval is user defined and can range from seconds to hours. Please let me know if you cannot access or have questions.

    Regards,
    Chris

    www.ti.com/.../TIDA-01575
  • Thank you Chris.

    Yes I can download it.

    I will go through the example to see how I can utilize it for my firmware and let you know.

    Vikram

  • Hi Chris,

    I tried loading the firmware into msp432 board and execute the same.

    But can't see anytime the RTC_C_IRQHandler function getting triggered.

    Do I need to get the entire setup mentioned in the "Reference design" document or can i simply load the program into msp432 board and see how the deepsleep mode is getting executed and have the device become active at RTC interrupt?

    Vikram

  • Secondly in the example I see that there is no WDT utilized but instead it is based on RTC. Is this not correct or I am seeing something else?
  • Vikram,
    I misspoke. It is the RTC and not the WDT. The example uses the RTC and sets an alarm based upon the desired wakeup time. You may need to remove the threads associated with the comms and the AFE. I did not think that this was the case and will investigate.

    Chris
  • Thank you Chris for clarifying.
    Just one more question in my application I want that the intended task is executed as soon as the board is powered up and then the task gets executed every certain interval say 6 hours.
    How can we change the WakeTime after initially settting to 0 hours and 0 minutes to 6 hours and 0 minutes? Can this be done in the RTC Handler?
  • What you seem to have trouble understanding is that for your application, you don't care about absolute time. You only need to set the alarm 6 hours into the future.

    Ie, if your mcu thinks it is in Jan 1 1970 1am now, and setting the alarm to Jan 1 1970 7am will wake up the mcu 6 hours later, in the real world.

    All you need to do is to keep pushing out that alarm, 6 hours at a time.

    It is literally that simple. No point in synchronizing the rtc with anything at all.
  • Yes. This could be done in the RTC Handler. Please bear in mind that this application is using the function predictive_maintenance_setWakeTime to add the delay to the alarm from the existing time as Danny F has described. Currently the first measurement of the ADC is done immediately and subsequent measurements are done after the interval. If you put the update in the RTC handler then you would need to move the wait (pend) and design accordingly.

    Chris
  • Hi Chris,

    I tried to check the current using the EnergyTrace Profile when the MCU goes into deepsleep as per the example provided and found the current in the deep sleep mode to be 2.9926 mA. Is that correct because as the documentations I see that the deep sleep current should be in microamps.
    Can you plesae confirm?

    Vikram

  •  Vikram,

       Are you running the serial communication example?  Yes I will confirm.

    Chris

  • Yes I am running the serial comunication example.
  • I was able to confirm the uA operation.  Is the debugger disconnected when you run energy trace?

  • Yes the debugger is connected. Otherwise how will I be able to see the Energy trace.
    Can you let me know he set up or share an image of the setup so that I don't have to connect to the debugger.

    Vikram
  • Thank you Chris for the document attached.
    So I see that if I run the board in the ET-only mode I get the mean current as 0.0018 mA, which resembles to your results.

    One more thing concerning is that when I execute the firmware related to the new SDK version that u had sent in the serial comm mode, I can see that the value of the sleep state changes to 2 (that is the value PowerMSP432_DEEPSLEEP_0) which is what was expected.
    But implementing the same concept of wake up through RTC in my firmware it still shows the value as 1 (PowerMSP432_SLEEP).
    Can't understand why is the same concept that is utilized in the firmware that you have sent not working in my firmware.
    Can you suggest some things that I can look into?

    Vikram
  • Vikram,
    Can you confirm all of the appropriate APIs are called?

    #include <ti/drivers/Power.h>
    #include <ti/drivers/power/PowerMSP432.h>

    /* Power Policy Object*/
    Power_NotifyObj notifyObj;

    Power_setPolicy((Power_PolicyFxn)PowerMSP432_deepSleepPolicy);

    Power_setConstraint(PowerMSP432_DISALLOW_DEEPSLEEP_1);

    Also, if you are using the UART, the 'open' will not release the contraint when the transmit is finished in order to support receive. We are looking into a fix for this. As a workaround in the example the release is called twice:

    Power_setConstraint(PowerMSP432_DISALLOW_DEEPSLEEP_0);
    sem_post(&startComms);
    sem_wait(&endComms);
    Power_releaseConstraint(PowerMSP432_DISALLOW_DEEPSLEEP_0);
    Power_releaseConstraint(PowerMSP432_DISALLOW_DEEPSLEEP_0);



    Thank you,
    Chris
  • Hi Chris,

    Thank you for the reply.

    Yes I am using UART since we are taking to a micropulser unit over the USART line and the micro pulser sends data over the UART line.

    Vikram

  • Hi Chris,

    As I mentioned in my previous reply, I am using USART to communicate with the micropulser on board to get the data from micropulser.

    I see that even though the MCU goes into sleep mode, the current consumed shown in sleep mode is 22 mA.

    I am not using the JTAG just running the board using 3.3V D cell battery.

    Can u please suggest some ideas to see where the current is getting drawn?

    Vikram

  • Hi Vikram,

    The idle state of UART TX is high. You could be having a short between the MCU and micropulser.

  • Just to confirm: 22mA or 22uA?
  • No it is 22 mA confirmed.
    Also second point is that after the MCU wakes from sleep mode as per the RTC implementation, it does not turn on the pulser unit.
    I checked the voltage at the enable pin for the load switch TPS22810 that we are using to turn on the pulser. The EN pin shows low for some reason.
    Whereas the another TPS22810 EN pin used to power the SD card is showing high 3.0V.

    Vikram
  • And what I found is surprising that after waking up from sleep mode even though I see the GPIO's getting toggled to enable the LDO switching IC (TPS22810), but the output of this IC's don't go high and it only goes high after a long while.

    Vikram
  • And lastly, I need to ask that in the notifyDeepSleepFxn, why are we setting the port pins PA to PJ as output and low when ideally any unused pins should be made input and pulled high to avoid floating voltage scenario. Is it that not correct? Or am I missing something?
  • Vikram,
    22mA is a lot and would be concerned that one of the GPIO is sinking current. Either because it is damaged or it is in contention with another device. It sounds like the outputs are not being actively driven and 'float' to the high level over time. You may want to confirm how the GPIOs are handled by the power module: here is how the GPIO are handled (parking) in the earlier referenced example:
    /*
    * =============================== Power ===============================
    */
    const PowerMSP432_ConfigV1 PowerMSP432_config = {
    .policyInitFxn = &PowerMSP432_initPolicy,
    .policyFxn = &PowerMSP432_sleepPolicy,
    .initialPerfLevel = 2,
    .enablePolicy = true,
    .enablePerf = true,
    .enableParking = false
    };

    In the default configuration of this the enableParking is set to true, meaning that the power driver will handle the gpio and 'park' them into an appropriate value when going to a low power mode. This is disabled and the IO are handled manually in the deep sleep notification callback.

    In the callback the IO are set to output low. This is fairly common practice to ensure that the schmidt-trigger receivers in the GPIO do not toggle. I see how using the internal pullups (or pulldowns) would potentially provide similar protection, but I think that the output low would be more robust. This is also what is recommended in the documentation.

    Regards,
    Chris
  • Thank you Chris for your reply.

    This makes sense.

    I might sound dumb in asking the question below.

    I see that in the function "notifyDeepSleepFxn" we are turning all GPIOs except (P1_2, P1_3, P4_0, P4_2 and P6_1 which corresponds to USART0 and ADC) to output and low. Why are the CS line and the EN line excluded in this case as they also may drawn current in the sleep mode? Correct me if I am wrong.

    Also now coming to my application, I am using SPI to communicate with another microcontroller, SD card to gather data sent from uPulser, USART2 to communicate with uPulser, NVS in order to retain some of the information even on power reset of the msp432 and along with this peripherals I use two GPIO's to enable the LDOs (P5_4, P5_5) and CS lines for SD card and SPI enabling.

    Now in this case, what port pins should I be excluding?

    As per my understanding from what you mentioned in your last post, I will have to only exclude the port pins that are used in the peripheral operations as below:

    Port Pin P1_5, P1_6 & P1_7 for SPI

    Port Pin P3_2 and P3_3 for USART2

    Is the above explaination correct?

    Thank you

    Vikram

  • Also additionally I tried two different options as below and both time I got different outcomes.
    The port pin P5.6 cannot be made as output since this the pin connected to a voltage voltage monitor and if I make it output and low the voltage monitor has voltage dropped.
    P5.4 and P5.5 are used to provide an enable input to TPS22810 and later is used to drive voltage to SD card and uPulser to turn each of them.
    unsigned int notifyDeepSleepFxn(unsigned int eventType, unsigned int eventArg,
    unsigned int clientArg)
    {
    if(PowerMSP432_ENTERING_DEEPSLEEP == eventType)
    {
    /* Set the unused IOs to low state */
    MAP_GPIO_setOutputLowOnPin(GPIO_PORT_PA, (PIN_ALL16 & ~(GPIO_PIN5|GPIO_PIN6|GPIO_PIN7)));
    MAP_GPIO_setOutputLowOnPin(GPIO_PORT_PB, (PIN_ALL16 & ~(GPIO_PIN2|GPIO_PIN3)));
    MAP_GPIO_setOutputLowOnPin(GPIO_PORT_PC, (PIN_ALL16 & ~(GPIO_PIN4|GPIO_PIN5|GPIO_PIN6)));
    MAP_GPIO_setOutputLowOnPin(GPIO_PORT_PD, PIN_ALL16);
    MAP_GPIO_setOutputLowOnPin(GPIO_PORT_PE, PIN_ALL16);
    MAP_GPIO_setOutputLowOnPin(GPIO_PORT_PJ, PIN_ALL16);
    MAP_GPIO_setAsOutputPin(GPIO_PORT_PA, (PIN_ALL16 & ~(GPIO_PIN5|GPIO_PIN6|GPIO_PIN7)));
    MAP_GPIO_setAsOutputPin(GPIO_PORT_PB, (PIN_ALL16 & ~(GPIO_PIN2|GPIO_PIN3)));
    MAP_GPIO_setAsOutputPin(GPIO_PORT_PC, (PIN_ALL16 & ~(GPIO_PIN4|GPIO_PIN5|GPIO_PIN6)));
    MAP_GPIO_setAsOutputPin(GPIO_PORT_PD, PIN_ALL16);
    MAP_GPIO_setAsOutputPin(GPIO_PORT_PE, PIN_ALL16);
    MAP_GPIO_setAsOutputPin(GPIO_PORT_PJ, PIN_ALL16);


    /* Turn off PSS high-side supervisors to consume less power in shutdown */
    MAP_PSS_disableHighSide();
    }
    return NULL;
    }
    With the setting above I got the current drawn showing as 16 mA in sleep mode and with the setting below I got the current drawn showing as 45 mA
    unsigned int notifyDeepSleepFxn(unsigned int eventType, unsigned int eventArg,
    unsigned int clientArg)
    {
    if(PowerMSP432_ENTERING_DEEPSLEEP == eventType)
    {
    /* Set the unused IOs to low state */
    MAP_GPIO_setOutputLowOnPin(GPIO_PORT_PA, (PIN_ALL16 & ~(GPIO_PIN5|GPIO_PIN6|GPIO_PIN7)));
    MAP_GPIO_setOutputLowOnPin(GPIO_PORT_PB, (PIN_ALL16 & ~(GPIO_PIN2|GPIO_PIN3)));
    MAP_GPIO_setOutputLowOnPin(GPIO_PORT_PC, (PIN_ALL16 & ~(GPIO_PIN6)));
    MAP_GPIO_setOutputLowOnPin(GPIO_PORT_PD, PIN_ALL16);
    MAP_GPIO_setOutputLowOnPin(GPIO_PORT_PE, PIN_ALL16);
    MAP_GPIO_setOutputLowOnPin(GPIO_PORT_PJ, PIN_ALL16);
    MAP_GPIO_setAsOutputPin(GPIO_PORT_PA, (PIN_ALL16 & ~(GPIO_PIN5|GPIO_PIN6|GPIO_PIN7)));
    MAP_GPIO_setAsOutputPin(GPIO_PORT_PB, (PIN_ALL16 & ~(GPIO_PIN2|GPIO_PIN3)));
    MAP_GPIO_setAsOutputPin(GPIO_PORT_PC, (PIN_ALL16 & ~(GPIO_PIN6)));
    MAP_GPIO_setAsOutputPin(GPIO_PORT_PD, PIN_ALL16);
    MAP_GPIO_setAsOutputPin(GPIO_PORT_PE, PIN_ALL16);
    MAP_GPIO_setAsOutputPin(GPIO_PORT_PJ, PIN_ALL16);


    /* Turn off PSS high-side supervisors to consume less power in shutdown */
    MAP_PSS_disableHighSide();
    }
    return NULL;
    }

    Kindly provide your input.
    Vikram
  • And lastly, do you think the point that you made in your posts earlier about using USART
    "Also, if you are using the UART, the 'open' will not release the contraint when the transmit is finished in order to support receive. We are looking into a fix for this. As a workaround in the example the release is called twice:"
    can this be causing the issue since I see that whenever, I disconnect the uPulser from the msp432 just by disconnecting the TX line it pulls the current down to 1 mA.

    Vikram
  • Vikram,
    To your first point, yes, only put the IO that are unused into the 'output low' state. I will confirm with the application designer, but I think it would make more sense to configure the unused inputs only one time at the beginning and use the deep sleep notification callback to only adjust IO that can be changed in functionality without negatively impacting the system. I do not think it makes sense to touch all of the IO with each power transition.

    The current values are still really high. You mention that disconnecting the UART TX reduces the MSP432 current consumption down to 1mA. Is this signal sourced from the MSP or the uPulser? Is the enable parking been set to false in the board file?

    Lastly, the release constraint does not impact the IO, only the ability to enter deep sleep. Similar to the previous questions can you clarify that the current is going from 16mA to 1mA when you disconnect the MSP432 TX line from the uPulser?

    Regards,
    Chris
  • Thank you Chris for the input.

    So as you mentioned that we only put the unused IO's into output low state then since, I am using the USART2, SPIB0, NVS, SDSPI0 peripherals and along with that GPIO pins 3.4, 3.5, 5.0, 8.0, 5.4, 5.5, 5.7 as output and GPIO pins 4.5, 4.6, 4.7 as inputs, I should be excluding this pins when putting them into output low state statement in the notifyDeepSleepFxn?

    Is that is true than is the below function correct in implementing? Please confirm.

    unsigned int notifyDeepSleepFxn(unsigned int eventType, unsigned int eventArg,
    unsigned int clientArg)
    {
    if(PowerMSP432_ENTERING_DEEPSLEEP == eventType)
    {
    /* Set the unused IOs to low state */
    MAP_GPIO_setOutputLowOnPin(GPIO_PORT_PA, (PIN_ALL16 & ~(GPIO_PIN5|GPIO_PIN6|GPIO_PIN7)));
    MAP_GPIO_setOutputLowOnPin(GPIO_PORT_PB, (PIN_ALL16 & ~(GPIO_PIN2|GPIO_PIN3|GPIO_PIN4|GPIO_PIN5)|GPIO_PIN13|GPIO_PIN14|GPIO_PIN15));
    MAP_GPIO_setOutputLowOnPin(GPIO_PORT_PC, (PIN_ALL16 & ~(GPIO_PIN0|GPIO_PIN4|GPIO_PIN5|GPIO_PIN6|GPIO_PIN7)));
    MAP_GPIO_setOutputLowOnPin(GPIO_PORT_PD, (PIN_ALL16 & ~(GPIO_PIN8));
    MAP_GPIO_setOutputLowOnPin(GPIO_PORT_PE, PIN_ALL16);
    MAP_GPIO_setOutputLowOnPin(GPIO_PORT_PJ, PIN_ALL16);
    MAP_GPIO_setAsOutputPin(GPIO_PORT_PA, (PIN_ALL16 & ~(GPIO_PIN5|GPIO_PIN6|GPIO_PIN7)));
    MAP_GPIO_setAsOutputPin(GPIO_PORT_PB, (PIN_ALL16 & ~(GPIO_PIN2|GPIO_PIN3)));
    MAP_GPIO_setAsOutputPin(GPIO_PORT_PC, (PIN_ALL16 & ~(GPIO_PIN4|GPIO_PIN5|GPIO_PIN6)));
    MAP_GPIO_setAsOutputPin(GPIO_PORT_PD, PIN_ALL16);
    MAP_GPIO_setAsOutputPin(GPIO_PORT_PE, PIN_ALL16);
    MAP_GPIO_setAsOutputPin(GPIO_PORT_PJ, PIN_ALL16);


    /* Turn off PSS high-side supervisors to consume less power in shutdown */
    MAP_PSS_disableHighSide();
    }
    return NULL;
    }

    Also in case if this pins are put into output low state in the deep sleep notification function, once the mcu wakes up from sleep will I have to reconfigure them?

    The USART TX pin is sourced from msp432 so basically I am sending a command from msp432 over USART TX and get a response back from the uPulser over USART RX.

    The enable parking is set to false in board file.

    And yes I confirmed multiple times by disconnecting and reconnecting the TX line between msp432 and uPuler. Whenever, I disconnect in sleep mode it showed 1 mA and when connected showed 16 mA.

    Thank you

    Vikram

  • Vikram,
    Yes what you have done is correct. Leaving the deep sleep does not change the GPIO. I do not understand why you would be seeing 1mA in sleep and then 16mA when the TX line is connected. I will keep thinking about it, but I do not have any immediate ideas.

    Chris
  • Vikram,
    I know that we have not resolved the current issue that you are seeing, but I am going to mark resolved for the original question of getting to deep sleep. Do you have multiple platforms that you could test and confirm if the current performance is consistent. I am still bewildered as to why the current is so high. Checking another device would simply confirm that the device is not damaged.

    Regards,
    Chris
  • You are correct Chris that the deep sleep issue is resolved but getting that resolved has led to another issue. As I mentioned that when the device wakes up from the deep sleep neither the USART is able to work nor the SD card driver is able to work. Basically once the CS line for the SD card is disabled and the LDO that powers the SD card is turned off after the operation next time when the device wakes up and I enable the SD card CS and LDO is turned, still the f_open fails and I always get the FR_DSK_ERROR and the value of fmt in the find_volume function shows 3. I not sure if this is because of the way SD card reader driver is implemented in SDK V1.60 or is it because of the deep sleep. Because in the version 1.40 I know it was not going into deep sleep but whenever the watchdog used to trigger after the interval i never had issue with the SD card file operations.
    And the challenge is since I am using same SPI for two slaves, I have to disable the CS line for the SD card once its operation is done and have to turn off the LDO otherwise it will drain current.

    I have tested the concept on multiple devices.

    Hope you understand. I am using the FatFs library.
    Thank you
    Vikram
  • Vikram,
    This post has gone on for a while, so it might be helpful to restate some of the possible issues:
    (1) The parking of the GPIO. I thought we addressed this and that the parking is disabled and that the gpio state is handled in the deepSleep callback.
    (2) The constraints of the power driver. In the original example I provided only the UART was in use and there was a second release constraint to take care of the issue with the driver maintaining a contraint to receive data. Is this still the case, and is there any issue with the SPI and the UART adjusting the constraints. Are both SPIs masters?
    (3) Finally, I am not familiar with the errors returned by the SD Card driver. It is possible to take the source code from the SDK and place it into your project (you will need to change some includes) and actually debug what his happening when the driver fails upon reopening. This is challenging because having the debugger will also influence the ability to enter deepsleep and may mask the issue.

    Please feel free to address additional comments.

    Regards,
    Chris
  • Thank you Chris for getting back for the query.

    I will try what you have mentioned and get back to you by tomorrow.

    In terms of USART the issue is that if I don't make the P3.2 and P3.3 as output and low than even in the sleep mode I see the current drawn but as i mentioned if I remove the jumper that that current is dropped to 1 mA.

    If I try to make the P3.2 and P3.3 low in sleep mode than once the unit wakes from sleep mode, the UART does not function.

    The other option I tried that when in sleep mode, I make the GPIO P3.2 and 3.3 as output and low and close the UART handle.

    Once when the unit wakes up that is when the RTC Interrupt handler is called, I reconfigure the P3.2 and P3.3 as the primary function i.e. as USART and also open the UART again.

    Doing this it is able to get the current to 1 mA and we are able to get the UART comnmunication going for next file.

    What I would like to know is it safe to close and re-open UART whenever the unit wakes up and is it ok to open the UART in interrupt handler?

    Vikram

  • Hi Chris,

    Doing some additional debugging I found different outcomes.

    I debugged and found that in the same version of SDK V1.60, if I use the watchdog concept to wake up the unit after every certain time period, that there is no issue of the SD card opening the file and writing new data to it.

    But with the same SDK version if I am using the RTC concept to wakeup I find the issue that for first time, the firmware writes the data to file and the same file is been transmitted over SPI to another device.

    But next time when the unit wakes up, it always gives FR_DISK_ERR while trying to open a new file.



    The problem is that watchdog concept does not let the unit go into deepsleep which is must for my application and the RTC allows the unit to go into deepsleep.

    Also in the RTC concept I am executing below lines after going into deep sleep and after waking from deep sleep.

    Before going into deep sleep I close the USART handle, SDFatFs handle and the SPI handle and then once into sleep the below function is executed

    unsigned int notifyDeepSleepFxn(unsigned int eventType, unsigned int eventArg,
    unsigned int clientArg)
    {
    if(PowerMSP432_ENTERING_DEEPSLEEP == eventType)
    {
    /* Set the unused IOs to low state */
    MAP_GPIO_setOutputLowOnPin(GPIO_PORT_PA, PIN_ALL16);
    MAP_GPIO_setOutputLowOnPin(GPIO_PORT_PB, PIN_ALL16);
    MAP_GPIO_setOutputLowOnPin(GPIO_PORT_PC, (PIN_ALL16 & ~(GPIO_PIN4|GPIO_PIN5|GPIO_PIN6)));
    MAP_GPIO_setOutputLowOnPin(GPIO_PORT_PD, PIN_ALL16);
    MAP_GPIO_setOutputLowOnPin(GPIO_PORT_PE, PIN_ALL16);
    MAP_GPIO_setOutputLowOnPin(GPIO_PORT_PJ, PIN_ALL16);
    MAP_GPIO_setAsOutputPin(GPIO_PORT_PA, PIN_ALL16);
    MAP_GPIO_setAsOutputPin(GPIO_PORT_PB, PIN_ALL16);
    MAP_GPIO_setAsOutputPin(GPIO_PORT_PC, (PIN_ALL16 & ~(GPIO_PIN4|GPIO_PIN5|GPIO_PIN6)));
    MAP_GPIO_setAsOutputPin(GPIO_PORT_PD, PIN_ALL16);
    MAP_GPIO_setAsOutputPin(GPIO_PORT_PE, PIN_ALL16);
    MAP_GPIO_setAsOutputPin(GPIO_PORT_PJ, PIN_ALL16);


    /* Turn off PSS high-side supervisors to consume less power in shutdown */
    MAP_PSS_disableHighSide();
    }
    return NULL;
    }
    Now when the unit wakes up i.e. once the RTC_interrupt triggers, I execute the following piece of firmware in the handler before I turn on the LDO for the uPulser and the SD card.

    void RTC_C_IRQHandler(UArg arg)
    {
    /* Clear the interrupt status for alarm and timer-0 interrupt */
    MAP_RTC_C_clearInterruptFlag(RTC_C_CLOCK_ALARM_INTERRUPT);

    MAP_GPIO_setOutputHighOnPin(GPIO_PORT_P8, GPIO_PIN0);
    MAP_GPIO_setAsOutputPin(GPIO_PORT_P8, GPIO_PIN0);
    MAP_GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P3,
    GPIO_PIN2 | GPIO_PIN3, GPIO_PRIMARY_MODULE_FUNCTION);
    MAP_GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P1,
    GPIO_PIN5 | GPIO_PIN6 | GPIO_PIN7, GPIO_PRIMARY_MODULE_FUNCTION);

    uart = UART_open(Board_UART1, &uartParams);
    if (uart == NULL)
    {
    System_abort("Error opening the UART");
    }
    /* Post the semaphore to process the ADCBuf Task and FFT */
    sem_post(&devWakeMutex);
    }

    Please let me know what difference will it be when using RTC as against the Watchdog while using the FatFs library functions.



    Hope to hear soon from you.

    Vikram
  • Vikram,
    For your previous question; I do not have any experience outside of the application examples and therefor I would not advise opening the UART or any handle in the ISR. I would recommend using a semaphore and opening the handle in the thread.

    For what you are currently describing, I will look into the SPI and SDFats drivers to see if there is an issue with the driver not closing or some conflict as they both use spi. Can you provide any more information regarding the SPI handle? Is this a SPI slave implementation? What peripheral (eUSCIx) and IO resources (GPIO) are used? If not too much trouble can you send the board file which describes SDFatFS, SD, and SPI instances?

    In addition to closing the handles are you also releasing any constaints? This may be unrelated but I have encountered issues with the UART and re-entering deepsleep after closing the handle. In this case I am describing I also had to release the constraint in addition to closing the UART.

    In the code snippet you provided I do not see how the IO are configured for the non-deep sleep entry case. You should also use this function when leaving deep sleep to return the IO to its orginal state if you are not using the IO park feature.

    Regards,
    Chris
  • Hi Chris,

    Thank you for replying.

    For the first part in terms of opening and closing of the UART handle, I will try the semaphore approach you have mentioned.

    In the terms of SPI handle, MSP432 SPI is implemented as master controller SPI slave devices (Both SD card and the radio board MCU).

    The peripherals used are as below:

    For USART - P3.2 and P3.3 that represents UARTA2

    For SPI - P1.5, P1.6 and P1.7 that represents SPIB0

    For the CS lines I have used P5.0 (For Radio board) and P8.0 for SD card

    There are other GPIO's that as also used for handshaking, wake up radio and to turn on and off the LDO that controls power to uPulser and SD card.

    This GPIOs are P5.4, P5.5, P4.5, P4.6 and P5.7. I have attached the board file and the MSP432.c and .h files for you to look into.

    2476.MSP_EXP432P401R.c
    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    /*
    * Copyright (c) 2015-2017, Texas Instruments Incorporated
    * All rights reserved.
    *
    * Redistribution and use in source and binary forms, with or without
    * modification, are permitted provided that the following conditions
    * are met:
    *
    * * Redistributions of source code must retain the above copyright
    * notice, this list of conditions and the following disclaimer.
    *
    * * Redistributions in binary form must reproduce the above copyright
    * notice, this list of conditions and the following disclaimer in the
    * documentation and/or other materials provided with the distribution.
    *
    * * Neither the name of Texas Instruments Incorporated nor the names of
    * its contributors may be used to endorse or promote products derived
    * from this software without specific prior written permission.
    *
    * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
    * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
    * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
    * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
    * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
    * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
    * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
    * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
    * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
    * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
    * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    */
    /*
    * ======== MSP_EXP432P401R.c ========
    * This file is responsible for setting up the board specific items for the
    * MSP_EXP432P401R board.
    */
    #include <stdbool.h>
    #include <stddef.h>
    #include <stdint.h>
    #include <ti/drivers/Power.h>
    #include <ti/drivers/power/PowerMSP432.h>
    #include <ti/devices/msp432p4xx/inc/msp.h>
    #include <ti/devices/msp432p4xx/driverlib/rom.h>
    #include <ti/devices/msp432p4xx/driverlib/rom_map.h>
    #include <ti/devices/msp432p4xx/driverlib/adc14.h>
    #include <ti/devices/msp432p4xx/driverlib/dma.h>
    #include <ti/devices/msp432p4xx/driverlib/gpio.h>
    #include <ti/devices/msp432p4xx/driverlib/i2c.h>
    #include <ti/devices/msp432p4xx/driverlib/interrupt.h>
    #include <ti/devices/msp432p4xx/driverlib/pmap.h>
    #include <ti/devices/msp432p4xx/driverlib/ref_a.h>
    #include <ti/devices/msp432p4xx/driverlib/spi.h>
    #include <ti/devices/msp432p4xx/driverlib/timer_a.h>
    #include <ti/devices/msp432p4xx/driverlib/timer32.h>
    #include <ti/devices/msp432p4xx/driverlib/uart.h>
    #include <ti/devices/msp432p4xx/driverlib/wdt_a.h>
    #include "MSP_EXP432P401R.h"
    /*
    * =============================== ADC ===============================
    */
    #include <ti/drivers/ADC.h>
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    5100.MSP_EXP432P401R.h

    0724.Board.h

    I am releasing the constraints only at the end of file as how it was described in the sample code that you had provided as below.

            Power_setConstraint(PowerMSP432_DISALLOW_DEEPSLEEP_0);
            sem_post(&startComms);
            sem_wait(&endComms);
            pulsing = false;
            Power_releaseConstraint(PowerMSP432_DISALLOW_DEEPSLEEP_0);
            Power_releaseConstraint(PowerMSP432_DISALLOW_DEEPSLEEP_0);
    

    And for the last part in your reply you have mentioned to re-configure the IO for non-deep sleep entry case and to use the same function to return the IOs to its original state. How do we do that?

    Do you mean to say that when the RTC_interrupt handler triggers I reconfigure the IOs to it original state before proceeding with the thread?

    Please let me know.

    thank you

    Vikram

  • Hi Chris,

    Sorry technically is it correct to have below in the RTC_interrupt handler once the unit wakes up?

    void RTC_C_IRQHandler(UArg arg)
    {
        /* Clear the interrupt status for alarm and timer-0 interrupt */
        MAP_RTC_C_clearInterruptFlag(RTC_C_CLOCK_ALARM_INTERRUPT);
    
        MAP_GPIO_setOutputHighOnPin(GPIO_PORT_P8, GPIO_PIN0);
        MAP_GPIO_setAsOutputPin(GPIO_PORT_P8, GPIO_PIN0);
    
        MAP_GPIO_setOutputHighOnPin(GPIO_PORT_P5, GPIO_PIN0);
        MAP_GPIO_setAsOutputPin(GPIO_PORT_P5, GPIO_PIN0);
    
        MAP_GPIO_setOutputHighOnPin(GPIO_PORT_P5, GPIO_PIN7);
        MAP_GPIO_setAsOutputPin(GPIO_PORT_P5, GPIO_PIN7);
    
        MAP_GPIO_setAsInputPinWithPullUpResistor(GPIO_PORT_P4, GPIO_PIN5);
    
        MAP_GPIO_setAsInputPinWithPullUpResistor(GPIO_PORT_P4, GPIO_PIN6);
    
        MAP_GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P3,
                GPIO_PIN2 | GPIO_PIN3, GPIO_PRIMARY_MODULE_FUNCTION);
    
        MAP_GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P1,
                GPIO_PIN5 | GPIO_PIN6 | GPIO_PIN7, GPIO_PRIMARY_MODULE_FUNCTION);
    
        /* Post the semaphore to process the ADCBuf Task and FFT */
        sem_post(&devWakeMutex);
    }
    #endif
    

    Vikram

  • Hi Chris,

    I have managed to get the sleep current down to 1mA.
    How much low can we go in deep sleep in this scenario? Are will able to achieve uA value?
    Vikram
  • Hi Chris,

    With the new SDK 2.10 I have managed to get all the problem related to the firmware working got resolved.

    But for some reason I cannot get the current down than 2.43 mA.

    I have verified in the circuit that there is no voltage on the LDO outputs but still current is showing 2.43 mA and the voltage across the battery terminals is showing full voltage i.e. 3.6V.

    I am trying to use the Energy Trace option but I am not sure what settings should I have while testing.

    Below is the image of the circuit connection to the debugger and I am using 3.6V D cell battery to power the board.

    Below is the image of the setting that I need to get idea based on the battery that I am using.

    Please can you guide on this so I can get idea about it.

    At present I tried the setting as shown in image below but that gives always 4mA whether active or in sleep which is not correct because in active mode I know it draws between 46-76 mA but with multimeter I am not able to go lower than 2.3 mA.

    So want to verify with that option too.

    Vikram

1 2

**Attention** This is a public forum