8 years, 3 months ago.

411 Nucleo, putc(0xa0) sends two chars; D0 then B0 plus other funnies

Hi, I'm a relative newbie and have been struggling for a day on this. I'm trying to send 0xA0,0xA1,0x02,0x00 as separate bytes to a device (GPS module) over the second serial port on a Nucleo 411 using pins PA_9 and PA10.

What I see coming out of the serial port in a terminal emulator in hex mode is D0,B0,D0,B1,02,20 instead of A0,A1,02,00. Note that the values A0,A1 and 00 have been sent incorrectly - 00 turns into 20 which is kind of bizzare by itself.

I have seen references around the place where someone is using putc() to send hex chars to an XBEE device, so presumably this should work. Is this an int versus uint8_t or unsigned char type of issue? Has anyone got a workaround to send raw hex bytes out a serial port if it is related to data type?

Paring my code down to avoid arrays, interrupts and stuff couldnt get simpler than putc(0xA0) which doesnt work.

I wish I was using a ye olde intel 8251 USART programmed in assembler, then it would be easy, but...

1 Answer

8 years, 3 months ago.

I have been succesfully using F401RE with a GPS-module by sending and receiving data in HEX using putc() and getc().

First thing I would check is that your baud rates match. My GPS uses 115200 by default while the default baud rate for mbed serial is 9600. This can be changed with

Serial device(PA_9, PA_10);

int main()
{
device.baud(115200);

...

}

Also, can you try communication between two Nucleo boards? I did my initial testing by using two F401RE connected via UART, and monitoring the messages over COM ports. There's a ready example of the UART bridge in the mbed handbook page. https://developer.mbed.org/handbook/Serial

Accepted Answer

Thanks for responding to my question. I was grateful to hear that somebody else had done something similar to me without having any issues. The baud rate was setup correctly (I should have mentioned that I've been happily extracting info from the GPS from the get go). I thought I'd try the code out on an L152RE since you'd been successful on a different platform to the 411. There was no difference, so I downloaded RealTerm and pointed the code's output to the Virtual Comm port. I was able to see that the data was in fact sent correctly from the Nucleo meaning that in fact the problem is with the other terminal emulator! I wont bother trying to find out why.

Many thanks again

posted by Marc D 30 Jul 2016