Hello
I am currently working with 24-Bit external ADC. I have one continous problem since starting of my project.
Firstly I can correctly read A/D conversion data from external ADC. I calculated RMS value of it and also graph it. There is no problem. I also did time-stamp data and I am sure about I do not miss data between samples.
ADC conversion starts directly with my PWM output of my MCU. I do not control conversion. It is continous conversion. PWM is 4MHZ and SPI communication runs on 8 MHZ.
The problem is sometimes when I reprogrammed my MCU, External ADC sends certain value is like "00000001 / 00000001 / 00000001". I checked MOSI request pin it seems like as always. I send address and R/W bit in one byte. I checked that frame I sent is correct.
Problem generally is solved when I power off device and on again. I couldnt understand where I am going wrong.
My reading algorith is like
void StartADC1() { a = 0x0000; ADCdata = 0x00; clrbit(ADC_CS1,0); // Chip Select LOW( START Communication ) while((SSI0_SR_R&SSI_SR_RNE)!=0) { a = SSI0_DR_R ; } a = SSI0_DR_R; // Dummy Read read_adress |= 0x41; SSI0_DR_R = read_adress ; while((SSI0_SR_R&SSI_SR_RNE)==0){}; // Receive FIFO Not Empty a = SSI0_DR_R ; ADCResult.VCH1_AN = (Read_ADC1(0)<<8) - VCH1_OFFSET; ADCResult.VCH2_AN = (Read_ADC1(1)<<8) - VCH2_OFFSET; ADCResult.VCH3_AN = (Read_ADC1(2)<<8) - VCH3_OFFSET; setbit(ADC_CS1,0); // Chip Select HIGH( Terminate Communication ) }
unsigned long Read_ADC1(char adress) { a = 0x0000; ADCdata = 0x00; a = SSI0_DR_R ; // Dummy Read if(adress<3) { SSI0_DR_R = 0; // Write SPIBufffer. Sets TX Flag, if not done read will not clock. while((SSI0_SR_R&SSI_SR_RNE)==0){}; // Receive FIFO Not Empty ADCdata += SSI0_DR_R; ADCdata = (ADCdata<<8); SSI0_DR_R = 0; while((SSI0_SR_R&SSI_SR_RNE)==0){}; // Receive FIFO Not Empty ADCdata += SSI0_DR_R; ADCdata = (ADCdata<<8); SSI0_DR_R = 0; while((SSI0_SR_R&SSI_SR_RNE)==0){}; // Receive FIFO Not Empty ADCdata += SSI0_DR_R; } return(ADCdata); }