Report
4 years, 9 months ago.  This question has been closed. Reason: Unclear question

RTC Locking Up Nucleo STM L152RE

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 jumper changes correct this issue?

Here is the code in question. The first block is the STM sample code. The second block is my "hello world" code that responds to serial port inputs.

/*********************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*****************************************/

/****************************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 ************************************/

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?

Thanks!!


To post an answer, please log in.