2015-04-14 12:51 PM
Hello,
I have functionfifo_read(RxFifo, &rx, 1)
which reads byte from FIFO buffer.
I want to use this function in two different interrupt handlers.
I have declared rx variable as follows
volatile
uint8_t rx;
but there is warning like this when I call function:
passing 'volatile uint8_t *' to parameter of type 'void *' discard qualifiers.
What is wrong? Thank you
2015-04-14 01:59 PM
When used in a normal writing sense, volatile means do so immediately, and every time it changes, don't cache it in a register, or fold it over multiple operations. You're passing it as a pointer, so the function isn't going to optimize away the write. With things writing into the variable via a pointer once, they aren't going to care if it's volatile, or not.
What specifically needs the volatile is the code that reads the value, to ensure it re-reads it every time the code asks it to check, rather than read it once into a register.You need to determine if the fifo function writes it more than once, or checks the value, and then you cast the pointer to avoid the warning. Or you read it into a holding variable, and then write it to rx if the fifo function was successful.2015-04-14 02:51 PM
In ISR, function check if there is some byte in FIFO, because function returns 1 if there are some byte. Processor goes to this ISR when there is some received byte from UART and another function moves it to FIFO.
Timer sends interupt request when there is all bytes from UART stored in FIFO. In timer ISR, the same function is intend to read all these bytes from FIFO in cycle. I supposed variable which used in ISR must be volatile.