Hello,
I'm working on a routine that uses SPI to read from an FPGA, and the FPGA uses an IO pin to indicate that data is available.
In my function, I read the state of that pin and continue reading until it goes low. Unfortunately, my register-read does not change when the IO pin changes, unless I explicitly re-delcare the register struct as volatile inside the function. The struct is already declared "extern volatile" in F28M35x_GPIO.h
Int16 ReadCommPortBuffer( Uint16 NumWordsToGet, Uint16 *RecBuffer)
{
extern volatile struct GPIOG1_DATA_REGS GpioG1DataRegs; // REGISTER STRUCT DOESN'T ACT VOLATILE WITHOUT THIS LINE.
while( GpioG1DataRegs.GPADAT.bit.GPIO9 == 1 ) // Read excess data from the FPGA
{...}
}
Re-declaring the struct outside the function (like at the top of the file, or explicitly including F28M35x_GPIO.h) does not work.
Could there be some optimization that is overriding the volatile parameter? I don't want to need to re-declare these structs everywhere I use them because it
destroys the hardware abstraction.
Thanks for any advice.