Thanks David.
I implemented same way.
However my requirement is, I have to use
22 channels of EQADCA and 7 channels of EQADC B
How do I modular the code so that for every channel configuration same function is called always.
Also need clarification when to use CFPR[0] and CFPR[1] etc and likewise CFCR0 and CRFR1 registers etc.
Here is my init and send and receive functions.
void eqadc_init (struct EQADC_tag *my_eqadc)
{
/* CBuffer0 */
my_eqadc->CFPR[0].R = B0 | MESSAGE_TAG(NULL_M) | LST(CYCLES_2) | CHANNEL(4);
my_eqadc->CFPR[0].R = EOQ | B1 | MESSAGE_TAG(NULL_M) | LST(CYCLES_2) | CHANNEL(4);
/*Trigger CFIFO 0 using Single Scan SW mode */
my_eqadc->CFCR0.R= SINGLE_SCAN_ENABLE | MODEx(SOFTWARE_TRIGGER_SINGLE_SCAN);
/*Wait for End Of Queue flag*/
while(my_eqadc->FISR[0].B.EOQFX != 1) {}
my_eqadc->FISR[0].R = End_of_Queue_Flag;
}
void SendConvCmd(struct EQADC_tag *my_eqadc, int channelnum)
{
/* Conversion command: convert channel 5 */
/* with ADC0, set EOQ */
my_eqadc->CFPR[0].R = EOQ | channelnum<<8;
}
void ReadResult(struct EQADC_tag *my_eqadc, int *Result)
{
while(my_eqadc->FISR[0].B.RFDFX != 1){}; /* Wait for RFIFO 0's Drain Flag to set */
Result = my_eqadc->RFPR[0].R; /* ADC result */
//ResultInMv = (vuint32_t)((5000*Result)/0x3FFC);
my_eqadc->FISR[0].R = RFIFO_Drain_Flag; /* Clear RFIFO 0's Drain Flag */
}
From main function I am calling it as below
eqadc_init(&EQADC_A);
eqadc_init(&EQADC_B);
SendConvCmd(&EQADC_A, 4); // here 4 corresponds to channel no 4
ReadResult(&EQADC_A, &duty);