Timing problem with Blink Program - Nucleo L476RG
I created a minimal custom Nucleo L476RG board. There is no 8 MHz crystal on the board and only a 32.768 KHz crystal. I connected an LED to PA_5 pin and trying to test the Mbed blinky program. I upload codes to the custom board via SWD connection from another Nucleo STLink. I am powering the board of 3.3V DC power supply.
The problem is the timing in blink. While i set it to 1 sec, the LED does blink on and off for one second but in between, sometimes, it blinks 5 times a second. Same thing happens if I set timing to some other time. The LED randomly blinks 5-6 times a second now and then after blinking for set time properly for 2-3 seconds. This happens regardless of the SWD connectors disconnected or connected.
Very very weird: THE PROBLEM DOES NOT OCCUR FOR ARDUINO COMPILATION OF THE EXACT SAME PROGRAM.
Mbed code:
#include "mbed.h"
DigitalOut ledpin(PA_5);
int main(){
ledpin = 1;
while(1){
ledpin = !ledpin;
thread_sleep_for(250);
}
}
Arduino Code:
int led = 13;
bool val = 1;
void setup() {
pinMode(led, OUTPUT);
}
void loop() {
digitalWrite(led, val);
val = !val;
delay(250);
}
Any idea what the problem is?
