2 years ago.

Nucleo - STM32F410RB not reading from serial port

I have a 3DR radio telemetry setup with which I am trying to establish two way communications between a laptop and the Nucleo board. The board functions fine while transmitting data but it is just not reading from the radio. The radio receives the data, and also on the laptop side, the radio is successfully transmitting data.

STM32F410RB code

#include "mbed.h"


#define TX_PIN PB_6
#define RX_PIN PA_10

Serial pc(USBTX, USBRX);
Serial pc2(TX_PIN, RX_PIN);
DigitalOut myled(LED1);
char recvdChar = 'a';

void recvdData(){
        recvdChar = pc2.getc();
    }

int main()
{   
    pc.baud(57600);
    pc2.baud(57600);
    pc2.abort_write();
    //pc.printf("STARTING\n");
    myled = 1;
    wait(1);
    myled = !myled;
    pc2.attach(&recvdData, Serial::RxIrq);
    while(1) {
       pc.printf("%c\n", recvdChar);
       wait(0.5);
    }
}


Laptop code

  import serial
  import time
   
   board = serial.Serial(port = '/dev/tty.usbserial-DN02136Z', baudrate = 57600    , timeout = 3)
        
   time.sleep(3)
        
   while(1):
     board.write("w")                   

You probably should declare the variable recvdChar as 'volatile' since it is updated in an interrupt. The compiler does not understand that and might optimise out re-checking the new value before printing it in your main loop.

posted by Wim Huiskamp 05 Dec 2017
Comment on this question
Be the first to answer this question.

Assigned to Graham S. 2 years ago.

This means that the question has been accepted and is being worked on.

You need to log in to post a question