RTC Issues with Nucleo L152RE - Page 1
Forum section: electronics / general

author: LabSpokane
author_rank: Super Contributor
timestamp: July 19, 2014, 12:45:39 am
content: I am experiencing an issue with the RTC on the Nucleo L152RE where if I access most any other mbed library function and also access the RTC, my board locks up. It will not respond to a reset. I must power down the board, then reload code that either accesses the RTC exclusively, or other peripherals exclusively.I am assuming that the mbed library is using the on-board 8MHz clock for the external clock...? Or is it not?Will populating X2 or X3 and doing the solder bridge changes correct this issue?Here is the code in question. The first block is the STM sample code - which works fine. The second block is my "hello world" code that responds to serial port inputs. The RTC code is directly pasted from the ST sample code. The second block of code works just fine if I comment out all the references to the clock. It also works fine if I comment out all the external I/O reference and leave in the clock code.Any ideas?<<code>>/*********************This code block works************************************#include "mbed.h"DigitalOut myled(LED1);int main() {printf("RTC example\n");set_time(1387188323); // Set RTC time to 16 December 2013 10:05:23 UTCprintf("Date and time are set.\n");while(1) {time_t seconds = time(NULL);//printf("Time as seconds since January 1, 1970 = %d\n", seconds);printf("Time as a basic string = %s", ctime(&seconds));//char buffer;//strftime(buffer, 32, "%I:%M:%S %p\n", localtime(&seconds));//printf("Time as a custom formatted string = %s", buffer);myled = !myled;wait(1);}}***************************working code block*****************************************/<</code>><<code>>/****************************This code block locks up the L152RE Nucleo**************#include "mbed.h"//------------------------------------// Hyperterminal configuration// 9600 bauds, 8-bit data, no parity//------------------------------------Serial pc(SERIAL_TX, SERIAL_RX);void trigger(){static int i = 1;pc.printf("Push Button pressed %i times.\n", i++);}int main(){AnalogIn vPin0(PA_0);InterruptIn PushButton (PC_13);DigitalOut myled(LED1);set_time(1387188323); // Set RTC time to 16 December 2013 10:05:23 UTCprintf("Date and time are set.\n");pc.printf("Program Loaded. \n");char cmd;float vin;PushButton.fall(&trigger);do {time_t seconds = time(NULL);cmd = fgetc(pc);switch (cmd) {case ('#'):pc.printf("Command 001 Received\n");break;case ('$'):pc.printf("Give me money!\n");break;case ('b'):pc.printf("Blinky activated.\n");myled =1;break;case ('d'):pc.printf("Blinky deactivated.\n");myled = 0;break;case ('r'): // read analog linevin = vPin0;pc.printf("Pin 0 = %f volts\n", vin);break;case ('t'): // output timeprintf("Time as seconds since January 1, 1970 = %d\n", seconds);printf("Time as a basic string = %s", ctime(&seconds));break;default:pc.printf("received: %c \n", cmd);}} while (1);}********************************* This block locks up the Nucleo ************************************/<</code>>Thanks!!

author: LabSpokane
author_rank: Super Contributor
timestamp: July 19, 2014, 07:57:18 pm
content: More info: I discovered that the "bad" code seems to not compile properly. I am using the mbed online IDE. Anyone else have issues with the mbed not compiling properly? It compiles without errors, but when I look at the memory on the uc, it's obviously not compiling correctly.

author: jeremy
author_rank: Super Contributor
timestamp: July 19, 2014, 09:01:54 pm
content: Quote from: LabSpokane on July 19, 2014, 07:57:18 pmCan you be more specific about this? I have used the mbed rtc code on an stm32f051 without any issues. But I do not use the mbed boot loader or online compiler. Perhaps try a gcc/openocd tool chain if you can?

author: LabSpokane
author_rank: Super Contributor
timestamp: July 20, 2014, 06:11:26 pm
content: Hi Jeremy,The "bad" bin file is most zeros when I view it in ST-Link. I will try another tool for compilation. It seems as though the board is fine, its actually the mbed compiler that's not working correctly.The first pic is the "bad" bin file that is created by mbed. Second is the "good" working bin file.I am going to try a different IDE / GCC compiler. Any recommendations on using the mbed API with other compilers? Or is it the root of the problem...?Thanks!

author: jeremy
author_rank: Super Contributor
timestamp: July 21, 2014, 06:38:04 am
content: Hi,Can you please send a picture of the software with the same tabs open?

author: LabSpokane
author_rank: Super Contributor
timestamp: July 21, 2014, 04:00:31 pm
content: Will send screenshots tonight. Oddly enough, after one last go at mbed, I got a good compile and everything started working.Obviously mbed is a bad plan for long term dev. I tried out IAC which seems pretty good. I'm just disappointed that the mbed header files don't compile natively there.Thanks again.

author: LabSpokane
author_rank: Super Contributor
timestamp: July 25, 2014, 05:38:25 am
content: Found the problem. On board ST-Link is incompatible with the mac since the board disconnects before unmounting the drive. RTC code addition some how put it over the edge and caused the failure.

author: josem
author_rank: Regular Contributor
timestamp: July 25, 2014, 09:23:28 am
content: Quote from: LabSpokane on July 25, 2014, 05:38:25 amAre you mounting the board with the sync option?Seehttp://mbed.org/handbook/Mounting-with-sync(replacing MBED with NUCLEO)Essentially add this to /etc/fstab (create the file doesn't exist):LABEL=NUCLEO none msdos rw,syncmount should show something like/dev/disk4 on /Volumes/NUCLEO (msdos, local, synchronous, noowners)