2018-03-20 08:20 AM
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
2018-03-20 08:51 AM
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.
2018-03-20 09:54 AM
Im using HAL library
2018-03-20 10:15 AM
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.
2018-03-20 11:19 AM
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
2018-03-21 01:13 AM
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 whetherstm32f4
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, ...
2018-03-21 06:18 AM
'
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/
2018-03-21 06:27 AM
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 ?!
2018-03-21 06:52 AM
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.