Hi Team,
This is bit of strange situation that I am facing.
Initially the entire firmware was written based on SDK version 1.40 and everything worked fine in the code except that it was not able to go into deep sleep mode.
As suggested by TI experts I moved the firmware to utilize the SDK V 1.60 in order to use the benefit of deep sleep mode implementation.
To start with I implemented the firmware so that the unit will wake up after every certain interval and that is based on watchdog timer.
But because watchdog time is not supporting the deep sleep mode again as per the suggestions from TI experts I utilized the RTC timer to have the unit go into deep sleep mode and wake up after certain interval.
The concept of the firmware is such as : As soon as the unit is powered up first time it turns on the SD card and the uPulser that are connected, takes shot from the uPulser and saves data into SD card.
Before even the uPulser starts taking shot information (UART communication) I open a new file every time the unit wakes up. the File system used is FatFs library.
Once the uPulser triggers and starts receiving data it saves that data into SD card and once all data is done, file is closed and then the same SPI line is used to perform another SPI transaction to another module (radio module).
Now the problem is that if I execute the firmware using the Debug mode (i.e. having the JTAG connected connected and pressing the "Run" button on the CCS window, the firmware runs fine without any issue i.e. it opens new file and also the USART responds with data written into the SD card.
But the same firmware if I execute in Rn mode (i.e. powering straight from battery source) even keeping the JTAG connected, the f_open fucntion fails returning FR_DSK_ERR or FR_NO_FILESYSTEM and not only this but the following function that is related to USART Rx is also halted meaning it does not get any information back from uPulser.
I have tried this on multiple boards and also multiple battery and multiple SD cards but all give the same result.
Question -
What is it different in Run mode as against the Debug mode?
Why would file opening function failure impact the UART reading functionality?
The reason I asked the above question is if I comment the SD card file opening part from the firmware, then the USART functions fine in the Run mode too except the fact is that it is not able successfully close the SDFatFs handle and the code hangs there.
And the strange part is that I not even enabled the Power Policy to have the deep sleep impacted.
I am attaching the firmware if you could have a look into this matter.
Hope to hear soon from you.
/* In debug mode meaning having the JTAG cable connected if I execute this function works fine and opens SD card. * It takes a shot and saves onto the file every time the unit wakes up. Wake up time is 2 minutes for now to test. * But if I run the firmware as it is straight from the power switch without having the JTAG connector, it fails at this point. * You can verify based on the LED toggling part below. * */ if(FR_OK == sdcardFileOpenWrite(logFile)) { for(msdump = 0;msdump<3;msdump++) { GPIO_toggle(Fogwise_Board_LED_D1); usleep(250000); } } probeRunMSAG(); for(dump = 0;dump<6;dump++) { GPIO_toggle(Fogwise_Board_LED_D1); sleep(1); } /* Now say in order to verify weather UART works even in run mode I comment out the statements related to sdcardFileOpenWrite(logFile). * Doing so in the debug mode it runs the probeRunMSAG(); function completely and then toggles the led as above and closes the handle * as below. * But if i run it directly from power switch without the JTAG connector. it will toggle the LED as above but crashes while closing the * SDFatFs_close handle. * */ SDFatFS_close(sdfatfsHandle); sdfatfsHandle = NULL;
For clarification I have also attached the statement in the firmware where I get the issues while executing straight from battery power.
Thank you
vikram