Author Topic: RTC Issues with Nucleo L152RE  (Read 4531 times)

0 Members and 1 Guest are viewing this topic.

Offline LabSpokaneTopic starter

  • Super Contributor
  • ***
  • Posts: 1899
  • Country: us
RTC Issues with Nucleo L152RE
« on: July 19, 2014, 12:45:39 am »
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 UTC
    printf("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[32];
        //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 UTC
    printf("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 line
                vin = vPin0;
                pc.printf("Pin 0 = %f volts\n", vin);
                break;
            case ('t'):  // output time
                printf("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!!
« Last Edit: July 19, 2014, 01:12:33 am by LabSpokane »
 

Offline LabSpokaneTopic starter

  • Super Contributor
  • ***
  • Posts: 1899
  • Country: us
Re: RTC Issues with Nucleo L152RE
« Reply #1 on: July 19, 2014, 07:57:18 pm »
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.
 

Offline jeremy

  • Super Contributor
  • ***
  • Posts: 1079
  • Country: au
Re: RTC Issues with Nucleo L152RE
« Reply #2 on: July 19, 2014, 09:01:54 pm »
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.

Can 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?
 

Offline LabSpokaneTopic starter

  • Super Contributor
  • ***
  • Posts: 1899
  • Country: us
Re: RTC Issues with Nucleo L152RE
« Reply #3 on: July 20, 2014, 06:11:26 pm »
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!



 

Offline jeremy

  • Super Contributor
  • ***
  • Posts: 1079
  • Country: au
Re: RTC Issues with Nucleo L152RE
« Reply #4 on: July 21, 2014, 06:38:04 am »
Hi,

Can you please send a picture of the software with the same tabs open?
 

Offline LabSpokaneTopic starter

  • Super Contributor
  • ***
  • Posts: 1899
  • Country: us
Re: RTC Issues with Nucleo L152RE
« Reply #5 on: July 21, 2014, 04:00:31 pm »
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.
 

Offline LabSpokaneTopic starter

  • Super Contributor
  • ***
  • Posts: 1899
  • Country: us
Re: RTC Issues with Nucleo L152RE
« Reply #6 on: July 25, 2014, 05:38:25 am »
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. 
 

Offline josem

  • Regular Contributor
  • *
  • Posts: 63
  • Country: gb
Re: RTC Issues with Nucleo L152RE
« Reply #7 on: July 25, 2014, 09:23:28 am »
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.

Are you mounting the board with the sync option?
See http://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,sync

mount should show something like

/dev/disk4 on /Volumes/NUCLEO (msdos, local, synchronous, noowners)
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf