Hi,
I had written a simple code to use the ADC channel 4 and 5 in a timer ISR.I first convert channel 5 and then channel 4.
Voltage in channel 5 is getting converted properly. Then, I switch to Channel 4. But, its been observed that
ADCmux is not getting set to channel 4 !!! What is the exact procedure, if you want to switch between channels?
Is there amyu issue, if I do inside a ISR ?? I have posted the ISR code. Please help me out.
interrupt void TINT_isr(void)
{
Int32 SAVE_ME = 0;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Clearing Timer Interrupt Flags and Timer0 Bit
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
*CPU_TIM0_IER = 0x0001; /* clear Timer0 interrupt flag */
*CPU_TIMINT_AGGR |= 0x0001; /* clear Timer0 bit */
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//This section of the code selected Channel 5
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
*SARCTRL |= (1 << 14);
*SARCTRL &= ~(1 << 13);
*SARCTRL |= (1 << 12);
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//ADC is working on Single Conversion mode.
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
*SARDATA |= (1<<15); //ADC_BUSY Made high
*SARCTRL |= (1<<15); //Start ADC Conversion
while ((*SARDATA & 0x8000)==0x8000); //Wait for ADC conversion
*SARCTRL &= ~(1<<15); //Stop ADC Conversion
Input_Signal_1[ptr] = *SARDATA & 0x3FF;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//SAVE_ME variable is watched in debug mode to ensure tht channel 5 is being converted
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
SAVE_ME = *SARDATA;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Here I switch to Channel 4
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
*SARCTRL |= (1 << 14); //
*SARCTRL &= ~(1 << 13); //
*SARCTRL &= ~(1 << 12); //
*SARDATA |= (1<<15); //ADC_BUSY Made high
*SARCTRL |= (1<<15); //Start ADC Conversion
while ((*SARDATA & 0x8000)==0x8000); //Wait for ADC conversion
*SARCTRL &= ~(1<<15); //Stop ADC Conversion
Input_Signal[ptr] = *SARDATA & 0x3FF;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//SAVE_ME variable is watched in debug mode to ensure tht channel 5 is being converted
//BUT here, evn after setting channel 4, in SAVE_ME varibale it shown tht Channel 0 is being selected
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
SAVE_ME = *SARDATA;
}