Forum > Embedded - ARM

Serial receive on STM32 MBR framework not working (solved)

(1/2) > >>

petex:
hello,

I am using the STM32 MBR frame work to do serial communications. I can get serial transmission to work fine, but serial reception refuses to work. I am calling "ReadString" and it just sits waiting for the status register (bit 5) to change.


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---  USART1.Initialize(TUARTRXPins.PA10_USART1,TUARTTXPins.PA9_USART1);    USART1.WriteString('Test program start');  USART1.WriteString(CRLF);    USART1.ReadString(str, 1);  
I am using the default baud rate. The loopback of Rx and Tx to my computer works ok. Baud rate is 11520.

Also tried:

  //USART1.BitsPerWord := TUARTBitsPerWord.Eight;
 // USART1.Parity := TUARTParity.None; 

MiR:
You cannot test in this way, when the writestring has finished the receive side will be in overrun because the chars sent by the write will have flooded the rx which will start receiving after all data was sent.

Remember that you are not on a multitasking OS here, with freertos this code would likely work because the serial will receive the chars based on interrupts and will put the chars in a queue for later reading.

You would need to implement interupts and queing on your own to get the same effect here.

check the uart example in mbf-freertos to see how uart interrupts can be implemented.

petex:
I am not trying to test by looping back on the STM32 card. I just did a loopback test to my PC to check that the FTDI interface and terminal software part are working ok.

I do understand that the readstring procedure is polling the data, but when I call it, it sits waiting on a character forever, i press a key on the terminal running on my pc and nothing is received on the STM32 card.

petex:
In the MBF framework unit MBF.STM32F1.UART.
The RX GPIO pin mode was set to TPinMode.AF0.
When I change it to an input, the readstring procedure works as expected.

i.e.


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---  setBaudRate(DefaultUARTBaudRate);  GPIO.PinMode[longWord(aRxPin) and $ff] := TPinMode.Input;  GPIO.PinMode[longWord(aTxPin) and $ff] := TPinMode.AF0;     

MiR:
I will check what the reference manual has to say on that tonight, thanks for pointing this out!

Michael

Navigation

[0] Message Index

[#] Next page

Go to full version