the problem is i can only enter the interrupt
funciton once,then never enter the function again.
are there any problems with my program?
anyone can give me a suggestion?
#include "config.h"
unsigned int result[20];
unsigned char channelx[20];
void __irq IRQ_ADC(void)
{
unsigned int value = 0x0000; //result of the ADC converter
unsigned char channel = 0x00; //the channel
unsigned char i = 0;
value = ADDR; //read the result and clear the DONE sign
channel = (value>>0x18)&0x07; //get the channel
value = (value>>6)&0x03ff; //convert the ADC result
if(channel == 0x00) //switch the channel
ADCR = ADCR&0xFFFFFF00|0x02;
else if(channel == 0x01)
ADCR = ADCR&0xFFFFFF00|0x04;
else if(channel == 0x02)
ADCR = ADCR&0xFFFFFF00|0x08;
else if(channel == 0x03)
ADCR = ADCR&0xFFFFFF00|0x01;
channelx[i] = channel;
result[i] = value;
i++;
if(i<20) //whether get 20 result ?
i++;
else
i = 0;
VICVectAddr0 = 0; //clear the IRQ function address
}
int main(void)
{
PINSEL1 = 0x01400000;//connect the pin to adc
ADCR = 0x00201501;//setup the ADCR only use the ain0
ADCR = ADCR|0x00010000;//use burst model
VICIntSelect = 0x00000000; //
VICVectCntl0 = 0x32;
VICVectAddr0 = (int)IRQ_ADC; //address of the IRQ function
VICIntEnable = 0x00040000; //enamble the ADC interrupt
while(1)
{
; //wait for the interrupt
}
return(0);
}Message
AD problem
2005-12-22 by zhengy_yong
Attachments
- No local attachments were found for this message.