I have just started to use the Metrowerks CodeWarrior C compiler and have a problem with the A/D CONVERTER. I want to use the AIN2, AIN3, AIN4, AIN5. (PD2 to PD5 ST72F324J2) When i use only one channel, All is ok. But when i want to make the acquisition of one channel after one channel, it's not ok. I have a function that is named Adc() void Adc(void) { ADCCSR = 0x22; // Channel 2 while (!(ADCCSR & 0x07)); In_ana2 = ADCDRH; ADCCSR = 0x23; // Channel 3 while (!(ADCCSR & 0x07)); In_ana3 = ADCDRH; ADCCSR = 0x24; and so ... } If i use only anyone channel the acquisiton in the variable In_anaX is correct. But if use all the channel, the acqusition in the variable is false. What is my mistake? /Fred.B
For checking the End of conversion you have to use
while (!(ADCCSR & 0x80)); But you are using ''while (!(ADCCSR & 0x07));''. You can also download the ST7 software library to have the ''ADC code'' from the same site.
Hello, Thanks Jatin. Could you give me the links to the ST7 software library because i have found in this site the AN979 but in this apllication note there is only the main code and it refers to the library. Example ADC_Enable();. The problem was the link :http://cmg.st.com/stonline/products/cmg/mcd/st7.html (ST7 software library version1.1). It doesn't match. So could you give me the right link to download the ST7 software library included ADC_Enable() for the ST72F324 Fred.B