This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

SPI not working in infinite loop

Hi experts

I am trying to interface an external ADC to NRF51-DK i am presently reading SPI ADC code values on BUTTON press event. I am able to read the values from ADC properly on button press.

I want to read the ADC values through infinite loop. idea is to constantly read ADC values in a loop and copy the value on button press in a variable and then send the variable over bluetooth to connected device.

Right now when i try to read the SPI based ADC in infinite loop i am able to read the ADC only once. On every subsequent query only the last received value is displayed the count does not change even if i change the ADC input voltage physically

Please find attached source code of my implementation. Right now the SPI i implemented in Button_0 event and in the int main function the test routine is commented.

Can someone help me in reading the ADC code in infinite loop.

main.c

Parents
  • yes peter i have tried that i have tried printf as well as debugger. SPI reads values from ADC first time properly then repeats the same value over and over again even if physical voltage is changed on the adc input side. Eg if i am supplying 3 volts to ADC input i get count as 0x5859 (ADC is of 16 bit resolution). Now if i change input voltage to 1.5 volts i should get 0x2C2C but count received is still 0x5859. This ADC count does not change. I have interfaced the same ADC to another micro-controller and keeping the software flow almost same i am able to see the desired change in ADC count. If same logic is working on one microcontroller it should work on another(nRF51422) also.

Reply
  • yes peter i have tried that i have tried printf as well as debugger. SPI reads values from ADC first time properly then repeats the same value over and over again even if physical voltage is changed on the adc input side. Eg if i am supplying 3 volts to ADC input i get count as 0x5859 (ADC is of 16 bit resolution). Now if i change input voltage to 1.5 volts i should get 0x2C2C but count received is still 0x5859. This ADC count does not change. I have interfaced the same ADC to another micro-controller and keeping the software flow almost same i am able to see the desired change in ADC count. If same logic is working on one microcontroller it should work on another(nRF51422) also.

Children
No Data
Related