SPI hangs polling SPI1STATbits.SPIRBF PIC32MZ
Having an issue with the pic32MZ SPI. It hangs when I try to poll the SPI1STATbits.SPIRBF bit. Everything works fine (I get CLK pulses and the HW responds with the correct values from the 23S08 IC) if I comment out the offending line. Also the value in data is always 0xFF (not reading anything).
Code below (mostly from DS):
SDI1R=0b0111; //set pin c14 as MISO1
RPD2R=0b0101; //set pin D2 as MOSI1
.... init module
SPI1BRG=0x4; //10 MHZ clk
SPI1STATCLR=0x40; //clr SPIROV
SPI1CON=0x8220;//8 bit mode master
... read SPI
for (i = 0; i < 2; i++)//READ 23S08 INPUTS
SS = 0;
j = i * 2 + 0X41;
SPI1BUF = j;
SPI1BUF = 0x09;
SPI1BUF = 0x00;
while (!SPI1STATbits.SPIRBF);// HANGS HERE!
data = SPI1BUF;
SS = 1;
kinda stumped as this is simple stuff... looked at the errata as these pics seem to have a lot of them (found that out the hard way with I2C). Didn't find anything relevant.
Thanks for your ideas!