JRDavisUF 5 Posted December 12, 2018 Share Posted December 12, 2018 I've a code I've been working on a while that has worked fine with an older version of the Energia and the board file. When I recently upgraded Energia to 21 and the MSP432 board to 5.23.1 a bunch of things broke. I was able to determine one set of problems was caused by the SPI Mode0/1 bug being corrected. That is, since spi mode0 and 1 were switched, I switched them in my code. When the bug got fixed everything spi-related broke until I switched the modes back (to what they should have been in the first place). My latest problem is that my usage of the RTC no longer works. Attempts to read/set the clock (internal and an external DS3231) are not working correctly. Setting the time to unix time 0, yields "Thu Apr 23 19:16:16 198054" Something funky with the year for sure. (as an aside, anyone have ideas on this problem?) So this led me down the path of trying to figure out what changes were made in the upgrades of Energia and the msp432 board file. However, I've not been able to find a good source of the changelist-type information relating to these two things. Can someone point me to this? I'm guess this might be in github somewhere, but it wasn't really clear to me how to get at this info. For example, figuring out where/when the SPI modes got corrected. Also, I think it would be helpful to have some kind of "upgrade guide" that people could reference. That is, for example, saying things like: "If upgrading from an earlier version of XXX, you will need to swap anything related to SPI Mode0 and SPI Mode1", etc. Quote Link to post Share on other sites
Rei Vilo 695 Posted December 12, 2018 Share Posted December 12, 2018 Which board are you using? Have you had a look at the pins maps on the Energia website? On the MSP430G2553, the I²C port has migrated from pins 14/15 to pins 9/10. Quote Link to post Share on other sites
JRDavisUF 5 Posted December 12, 2018 Author Share Posted December 12, 2018 I'm using the MSP432 Launchpad (red). I2C seems to be working ok as I've got a oled display connected via the same I2C pins and that is working just fine. I've also tried swapping out the RTC module with an identical one and it's showing the same behavior, so it looks like some kind of software-related issue at this point. And FWIW, both the internal (on the msp itself) and external RTC (I2C) are showing the same behavior. Quote Link to post Share on other sites
JRDavisUF 5 Posted December 13, 2018 Author Share Posted December 13, 2018 Lots more digging and it looks there is a time_t related issue. While trying to debug the problem, I tried running this example: https://github.com/rei-vilo/DateTime_Library/blob/master/Examples/Date_String/Date_String.ino These particular lines; // Fri, 31 Jul 2015 20:41:48 GMT myEpochRTC = 1438375308; Serial.print("Using default local time = "); Serial.println(convertDateTime2String(myEpochRTC)); Output this: Using default local time = Sat Jan 6 19:29:16 -1905047 which is consistent with the problem I am seeing in my test code that outputs the incorrect dates: Fri Mar 5 12:50:20 -1920835 Wed Sep 8 05:11:40 -848351 //test code #include "time.h" #include "RTC_Library.h" void setup() { // put your setup code here, to run once: Serial.begin(38400); time_t time1, time2; String result1, result2; // Fri, 31 Jul 2015 20:41:48 GMT time1 = 1438375308; result1 = convertDateTime2String(time1); Serial.println(result1); // Fri, 31 Jul 2015 20:41:48 GMT time2 = 1438375308; result2 = (String)ctime(&time2); result2.trim(); Serial.println(result2); } void loop() { // put your main code here, to run repeatedly: } Quote Link to post Share on other sites
JRDavisUF 5 Posted December 13, 2018 Author Share Posted December 13, 2018 I don't really get it, but if I change my declaration of time1 and time2 in my example to include "static": static time_t time1, time2; Then time2 gives the correct answer at least... Thu Aug 1 14:43:24 -1920291 Fri Jul 31 20:41:48 2015 Quote Link to post Share on other sites
JRDavisUF 5 Posted December 13, 2018 Author Share Posted December 13, 2018 Downgraded Energia from 21 to 18 and the problem still exists. Downgraded the board file from 5.23.1 to 5.6.3 and problem goes away ... Quote Link to post Share on other sites
JRDavisUF 5 Posted January 28, 2019 Author Share Posted January 28, 2019 So I've narrowed my code down to what is below. Using the latest Windows 10 Code Composer, the code works using Energia 21 / 5.6.3 but not with Energia 21/ 5.23.1...It kind of feels like a heap/stack size issue. Maybe the newer board file needs more memory for something...Any code composer experts out there? There used to be some obvious places to change such things...but I don't see them any more... #include<time.h> void setup() { // put your setup code here, to run once: Serial.begin(38400); // Thu Jan 1 00:00:00 1970 time_t time1=0; Serial.println(ctime(&time1)); } void loop() { } (I'll also note that if the time_t and Serial.println lines are moved to the loop, the code runs fine.) Quote Link to post Share on other sites
JRDavisUF 5 Posted January 31, 2019 Author Share Posted January 31, 2019 FWIW, I'm able to get ctime to work correctly if I switch from the default GNU 6.3.1 compiler supplied with energia to the GNU 7.2.1 compiler supplied with CCS8...not sure the implications of this change...so I started a new topic to talk about that Quote Link to post Share on other sites
JRDavisUF 5 Posted February 11, 2019 Author Share Posted February 11, 2019 OK, I think I know the problem now. It looks like time_t variable expected by ctime has changed from a 32 bit number to a 64 bit one (long long). (see my related compiler change post) In time.h ($USER\AppData\Local\Energia15\packages\energia\tools\arm-none-eabi-gcc\6.3.1-20170620\arm-none-eabi\include) If I make the following change: char *_EXFUN(ctime, (const time_t *_time)); to char *_EXFUN(ctime, (const long long *_time)); The the ctime function works correctly. 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.