cancel
Showing results for 
Search instead for 
Did you mean: 

UART stm32f4 discovery board

Alejandro Ismael
Associate II
Posted on March 20, 2018 at 16:20

hi, i need to recive variable amoun of data from the UART, but the problem is that the pointer of the Rx buffer is incremented any time and i cant decrease it, sorry for my english, i working whit stm32f4 discovery bord, thanks

8 REPLIES 8
Posted on March 20, 2018 at 16:51

If the buffering scheme isn't working for you, create a different one. The USART flags RXNE in the status, or can interrupt, upon the reception of each character.

What library are you using? HAL or SPL

Posted dozens of STM32F4-DISCO USART examples here over the years.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on March 20, 2018 at 16:54

Im using HAL library

henry.dick
Senior II
Posted on March 20, 2018 at 18:15

First, try to have a realistic expectation on what's doable. If you truly don't know the message length, and want your code to handle potentially an infinitely long message, give up because that's never going to happen in this word.

If, on the other hand, you are sure that your processor has enough power to remove data from the receiver faster than it can handle, and you just need a buffer to hold the received data temporarily, consider a buffer of some sorts. A circular buffer makes perfect sense here.

Posted on March 20, 2018 at 18:19

I try to read data from a RFID, the proble is that sometimes i have only one tag to read, but sometimes i have two or more tag because is a multitag RFID, so i dont now how many tag im going to read. Thats my problem, sorry for my english

Andrew Neil
Evangelist
Posted on March 21, 2018 at 09:13

As

henry.****

‌ said, you need to do the basic sums on how much data is coming from your RFID reader, and how fast - and consider whether

stm32f4

can cope with that.

However, in general, RFID is neither high-volume nor high-speed data; people having been connecting these things to simple 8-bit micros for decades - so it should really be no problem for a Cortex-M4!

As already noted, a so-called 'Ring Buffer' (aka 'Circular Buffer' or 'FIFO') is commonly used to buffer UART data ...

https://en.wikipedia.org/wiki/Circular_buffer

eg, see:

https://www.avrfreaks.net/comment/2369221#comment

and

https://www.avrfreaks.net/comment/2410116#comment

and

https://www.avrfreaks.net/comment/2333471#comment

also:

http://www.8052mcu.com/forum/read/74916

etc, ...

Posted on March 21, 2018 at 13:18

'

Thats my problem'

that's the least of your problems,

anyway, here is a circular buffer - platform independent as well: 

https://dannyelectronics.wordpress.com/2018/03/14/yet-another-circular-buffer/

 
Posted on March 21, 2018 at 13:27

Alejandro Ismael wrote:

sometimes i have only one tag to read, but sometimes i have two or more tag

I'd have thought that is standard & to be expected in pretty much any RFID system ?!

Posted on March 21, 2018 at 13:52

his/her response reflects a complete lack of understanding of the issues s/he is facing. it is not about how many tags the mcu has to read, but how fast the data comes in vs. being processed by the mcu. the bit rate of those things is abysmal vs. the mcu's ability to process them.

without him/her understanding that, no amount of help is going to do any good.