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
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.
Im using HAL library
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.
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
"Thats my problem"
that's the least of your problems,
anyway, here is a circular buffer - platform independent as well: Yet Another Circular Buffer – dannyelectronics
Alejandro Ismael wrote:sometimes i have only one tag to read, but sometimes i have two or more tag
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 ?!
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.
As dhenry 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 ...
Circular buffer - Wikipedia
eg, see: https://www.avrfreaks.net/comment/2369221#comment-2369221
also: [NEW!] RE: single crystal - 8052.com
Retrieving data ...