7 years, 7 months ago.

Unable to transmit data from serial port

Hello,

I am Using custom deveoped board with STM32L073RZ, I had written a protocol so that the communication between the device and PC is through serial port. I have used iSerial.cpp and iSerial.h for buffered and interruptmode communication. I am also using Normal USART for data to display on hyperterminal. Now the problem comes

Quote:

I am using the USART to get the Protocol from the software and other side the same USART is used for recieving data from the device and display the data on the hyperterminal.

iSerial Intialization

COMMUNICATION::COMMUNICATION(PinName tx, PinName rx, uint32_t baudRate, uint16_t tx_buff, uint16_t rx_buff )
{


    _serialCom = new iSerial(tx, rx,NULL,tx_buff,rx_buff);
   // _serialCom->baud(baudRate);

}

Normal Serial Intialization

Serial pc(tx, rx);

when i want to use both of them at the same time there would be no communication means no transmission of protocol nor recived data from device.Communication works when the uncomment Serial Pc (tx,rx); then communication works otherwise no. I am unable to identify the issue.need some assitance.I here by attach my code kindly have a look in to it

I am using Crystal oscillator of 8 Mhz cahnged as per mbed-dev . /media/uploads/sandeepmalladi/serialtest_73_uvision5_nucleo_l073rz.zip

1 Answer

7 years, 7 months ago.

So you want to read data from a device on the serial port RX and then use the TX pin of the same serial port to send other data out to a PC?

You can't split a USART like that, at least not with the standard libraries. You need to create a single instance of the serial port and then split the data flow in software. Both directions need to be running at the same speed.

Or use two physically different serial ports.

Hello Andy,

I would like to explain my problem in depth. I have to do 2 tasks with same serial port that is USART2 with baud rate 115200, So the first task is the command and response to and from the device to pc and vise versa for that i am using Ring buffer concept, as the command and response packet have variable amount of data. Second task is for example i have to read file from SD card and display that information to user on serial terminal on PC for this i am also using same USART2 but normal fashion no ring buffer. As this one worked on Nucelo Board L053R8 if you initialize both, but on my custom board it does not work if i initialize.

posted by san m 29 Mar 2017

Hello Andy,

I had updated my mbed and found strange behaviour unable to create a directory in sd file system, Serial Communication, Mbed_config.h error. This is all happening due to updated version of mbed. Could you please tell when the bug in mbed will be fixed?

posted by san m 31 Mar 2017