Hello Community,
I’m in need of some simple pin toggle sequences. Therefore I’ve ordered a Nucleo F103RB board and started “programming” with the MBED online compiler. Here is the code:
`#include “mbed.h”
Serial pc(SERIAL_TX, SERIAL_RX);
InterruptIn mybutton(USER_BUTTON);
DigitalOut myled(LED1);
DigitalOut rx(D8);
DigitalOut idle(D9);
DigitalOut tx(D10);
volatile uint32_t counter = 0; //How often did we cylcle through our routine
void pressed()
{
counter = 0;
}
int main()
{
mybutton.fall(&pressed);
while (1) {
counter++;
rx = 1;
wait_us(150);
rx = 0;
idle = 1;
wait_ms(1);
idle = 0;
tx = 1;
wait_us(150);
tx = 0;
wait_ms(100);
printf(“Sequence No. = %zu\n”, counter); //Print out result
}
}`
nothing big. Compilation went without errors, so far so good. Unfortunately the timings are completely off. The 150us wait is a total of 34ms. The 1ms is expanded to 65ms between high and low transitions of the port. The 3rd port which should be set and reset after 150µs is also 65ms long. Next I’ve loaded a demo program of the MBED compiler which blinks an LED. It also uses the wait functions and the timings are again totally wrong.
So is it a bug in the compiler? Am I missing some necessary configurations for the Nucleo or might it be a typical case of PEBCAK?
Yours faithfully,
Chris