I'm using an ADS1281 with a PIC32MX695F512L-80I/PT Microprocessor from microchip. I can get pin mode to work fine. I need to use register mode though so that I can control timed throughput. I can't seem to get register mode going. I've been through all of the forum subject matter. I haven't succeeded yet in getting the DRDY signal to happen. This causes the external interrupt to fire. Actually, I tried reading Register 0, 1 and 3. I couldn't even read the registers reliably. Can anyone help me get my head on straight. I'm starting with just trying to read register 3.
The Pin Mode PIN (Pin 21) is set to 0.
fclk is 4.096 Mhz. So only need 8uS between commands.
Here is my code:
int main(void)
{
int rdData1;
int input;
INPacketIndex = 0;
tickcount = 0;
timercount = 0;
int k;
InitializeSystem();
SpiInitDevice(SPI_CHANNEL1, 1, 0, 1); //8 bit
SpiChnClrIntFlags(SPI_CHANNEL1); //Clear Spi Interrupt
for(k=0; k< 8; k++) //Cause a reset
{
SpiChnPutC(1,0x00);
SpiChnGetC(1);
}
SpiChnPutC(1, 0x11); // Stop read data continuous
rdData1 = SpiChnGetC(1);
Delay10us(0x2a);
//check the chip ID
SpiChnPutC(1, 0x21);
rdData1 = SpiChnGetC(1);
SpiChnPutC(1, 0x00);
rdData1 = SpiChnGetC(1);
SpiChnPutC(1, 0x00);
rdData1 = SpiChnGetC(1);
OpenTimer2(T2_ON|T2_IDLE_CON|T2_PS_1_256|T2_SOURCE_INT, 62500);
ConfigIntTimer2(T2_INT_ON | T2_INT_PRIOR_7);
}
void __ISR(_TIMER_2_VECTOR, ipl7) Timer2_Interrupt(void)
{
int rdData1;
//read register 3 should always be 0x52
SpiChnPutC(1, 0x23);
rdData1 = SpiChnGetC(1);
SpiChnPutC(1, 0x00);
rdData1 = SpiChnGetC(1);
SpiChnPutC(1, 0x00);
rdData1 = SpiChnGetC(1);
mT2ClearIntFlag();
}
When I run this code I get 0x00000000 in rdData1. Looking Dout (pin 4) with a oscilloscope.
I would appreciate the help.
Thanks in advance.