hello there,
I am facing some issue with the SPI communication with ADS124S08 with PIC18f45k22.
the SPI operates at a baud rate of 450k. and there is no problem getting converted data when CS to first clock pulse and last clock pulse to CS disable delay is 50ms.
the ADC is configured to operate in single shot mode. since we have different configuration on each channel, we configure the channel each time, send the start command and later read it. as I mentioned, all this works at higher SPI delays.
but when this delay is reduced to 10ms we see there is no response from ADS1240S.
for isolation we have an isolator(ADMU1401) on the SPI bus.
below is the sample code to control the CS with delay.
please feel free to ask any clarification.
/**/
#define CS_2_CLK_DLY 10
#define CLK_2_CS_DLY 10
/* CS enable */
VOID siospi_adc_cs_en(UINT8 chn)
{
/* is this ADC 1 ?*/
if(chn < 0x02 )
{ /* yes */
/*drive low, slave select 1(RA5)*/
LATA = LATA & 0xDF;
}
else
{/* no */
/*drive low, slave select 2 (RA2)*/
LATA = LATA & 0xFB;
}
/* set delay after cs and clk */
f_sio_spi_to = SAT_FALSE;
g_sio_spi_to_cnt = 0;
g_sio_spi_to_lmt = CS_2_CLK_DLY; //10ms
/* wait for delay */
while (f_sio_spi_to == SAT_FALSE);
} /* siospi_adc_cs_en(), end*/
/* diable channel */
VOID siospi_adc_cs_ds(UINT8 chn)
{
/* delay after last bit read and cs low */
f_sio_spi_to = SAT_FALSE;
g_sio_spi_to_cnt = 0;
g_sio_spi_to_lmt = CLK_2_CS_DLY; // 10ms
/* wait for delay before cs disable from clk */
while (f_sio_spi_to == SAT_FALSE);
/* is this ADC 1 ?*/
if(chn < 0x02 )
{ /* yes */
/*drive high, deselec slave 1 (RA5)*/
LATA = LATA | 0x20;
}
else
{
/*drive high, deselec slave 2(RA2)*/
LATA = LATA | 0x04;
} /* is this ADC 1 ?, end */
} /* spi_adc_cs_ds() end */