5 years, 3 months ago.

STM Nucleo L476RG with 8266 and serial passthrough

This is straight forward in arduino, where you simply compile, and type interactively. Every step I tried with the stm I repeated with an arduino successfully.

I cannot figure out how to get this to work with a STM device. It seems that the STM Nucleo L476RG cannot deliver 3.3v, so I made that external power. Depending on what I try it ether hanged, disconnects from serial, just repeats a single character, or now with RawSerial repeats entire line, but it does not at any point appear to actually interact with the device.

Related : https://os.mbed.com/questions/92/serial-PC-to-MBED/ https://os.mbed.com/handbook/USBSerial https://os.mbed.com/handbook/SerialPC

  1. include "mbed.h"

RawSerial pc(USBTX, USBRX); RawSerial dev(D1, D0); RawSerial dev(PA_2,PA_3); DigitalOut led1(LED1); DigitalOut led4(LED4);

void dev_recv() { led1 = !led1; while(dev.readable()) { pc.putc(dev.getc()); } }

void pc_recv() { led4 = !led4; while(pc.readable()) { dev.putc(pc.getc()); } }

int main() { pc.baud(115200); dev.baud(115200);

pc.attach(&pc_recv, Serial::RxIrq); dev.attach(&dev_recv, Serial::RxIrq);

while(1) { sleep(); } }

1 Answer

5 years, 3 months ago.

Hello,

It does not work correctly because the program is using the same Serial port (Serial2) to communicate with the device and with the PC (check in the PinNames.h) :

PinNames.h

//...

USBTX = PA_2;
USBRX = PA_3;

//...

D1 = PA_2;
D0 = PA_3;

//...

Try to select differennt Serial port for the device. For example Serial1:

//...

RawSerial   pc(USBTX, USBRX);  // Serial2
RawSerial   dev(A4, A5);  // Serial1
//RawSerial   dev(PC_1, PC_0); //Serial1

//...

ADVISE: To have a more readable code after pasting it here (to mbed pages) try to mark it up as below (with <<code>> and <</code>> tags, each on separate line at the begin and end of your code)

<<code>>
text of your code
<</code>>