device:LPC2103 Keil MDK 3.11 I want to control the sample speed with MAT0.3 in simulator,but I can't reach the interrupt subroutine and the ADC do not work at all! Thanks everyone read the message!
the following is my code:
******************************************************* #include <lpc2103.h>
void InitADC(void); __irq void irq_adc (void) ;
void InitTimmer(void); __irq void irq_t0 (void) ;
int main(void) {
InitADC(); InitTimmer(); while(1); return(0) ; }
// T0.3 void InitADC(void) { // SEL CKDIV PDN START
int x=0x000000ff | 100<<8 | 1<<21 |5<<24 ;
ADCR = x;
ADINTEN=0X1FF;
PINSEL0 |= 3<<20 | 3<<22 | 3<<24;
PINSEL1 |=3<<12 | 3<<14 | 3<<16 | 3<<18 | 3<<20 ;
VICVectAddr1=(long)irq_adc ;
VICVectCntl1 |= 0x20 | 18; VICIntEnable |= 1<<18;
}
void InitTimmer(void) { T0MCR = 3<<9;//On match reset the counter and generate an interrupt
T0MR3 = 1500; //Set the cycle time
T0TCR = 0x00000001;//enable timer
VICVectAddr0=(long)irq_t0 ;
VICVectCntl0 = 0x20 |4; VICIntEnable|= 1<<4;
__irq void irq_adc (void) { int adc_channal;
adc_channal=ADSTAT & 0x00ff;
switch(adc_channal)
{ case 1:break; case 2 :break; case 4 :break; case 8 :break; case 0x10 :break; case 0x20 :break; case 0x40:break; case 0x80:break; } }
__irq void irq_t0 (void) { T0IR = 1; // Clear interrupt flag
VICVectAddr = 0; // Acknowledge Interrupt
switch(T0IR) { case 1:break; case 2 :break; case 4 :break; case 8 :break; case 0x10 :break; case 0x20 :break; case 0x40:break; case 0x80:break; }
Thank you for looking at my threat so seriously!!
device:lpc2103 develop
tool:keil mdk3.11 simulator
function: 1.Sample voltage from AD00.
2.Sampling speed is controlled by MAT0.3
problem: can't not reach the ADC interrupt subrountine
code list: The declaration
#include <lpc2103.h> void InitADC(void);//initiate ADC __irq void irq_adc (void) ;//ADC interrupt subroutine void InitTimer(void);//initiate timmer __irq void irq_t0 (void) ;//timmer 0 interrupt subroutine
The main function
int main(void) { InitADC(); //initiate ADC InitTimer(); //initiate timer while(1); return(1) ; }
ADC initiation part
void InitADC(void)// Initate the ADC { // SEL=1 CKDIV=100 PDN=1 START=5(MAT0.3) ADCR = 0x1 | 100<<8 | 1<<21 |5<<24 ; ADINTEN=0X101;//enable interrupt of ADC PINSEL0 |= 3<<20 | 3<<22 | 3<<24;// connect the pin PINSEL1 |=3<<12 | 3<<14 | 3<<16 | 3<<18 | 3<<20 ; VICVectAddr1=(long)irq_adc ;//set the interrupt adress VICVectCntl1 |= 0x20 | 18; //set the timmer0 interrupt VICIntEnable |= 1<<18;//enable timmer0 interrupt }
timer initiation part
void InitTimer(void)//Initiate the timer0 { T0MCR = 3<<9;//On match reset the counter and generate an interrupt in MAT0.3 T0MR3 = 1500; //Set the cycle time T0TCR = 0x00000001;//enable timer VICVectAddr0=(long)irq_t0 ; VICVectCntl0 = 0x20 |4; VICIntEnable|= 1<<4; }
the ADC interrupt subrountine
// the ADC interrupt subrountine __irq void irq_adc (void) { int adc_channal; adc_channal=ADSTAT & 0x00ff; VICVectAddr = 0; // Acknowledge Interrupt switch(adc_channal) { case 1:break; case 2 :break; case 4 :break; case 8 :break; case 0x10 :break; case 0x20 :break; case 0x40:break; case 0x80:break; } }
THE timmer0 interrupt subrountine
// THE timmer0 interrupt subrountine __irq void irq_t0 (void) { VICVectAddr = 0; // Acknowledge Interrupt switch(T0IR) { case 1:break; case 2 :break; case 4 :break; case 8 :break; case 0x10 :break; case 0x20 :break; case 0x40:break; case 0x80:break; } TOIR=0XFF; }