Hi,
I tried it on an ICS08MR board and after some small changes, it seems to work.
Here is the code I have changed:
/******************************************************************
* InitADC - initialize the ADC
*
* Calling convention:
* InitADC()
*
* Returns: nothing
******************************************************************/
void InitADC(void) {
ADSCR = 0; //stop conversion
#if ADC_8BIT
ADCLK = ADCLK_ADICLK_MASK; //internal bus clock/1, 8 bit result,
#else
ADCLK = ADCLK_ADICLK_MASK
|ADCLK_MODE0_MASK; //internal bus clock/1, right justified 10 bit result
//divide by 4, right justified
#endif
ADSCR_ADCH0=1; //read ATD1 PIN 63
ADSCR_ADCO=1; //continous conversion
ADCLK_ADIV2 = 1; //divide input clock by 16
ADSCR_AIEN = 1; //enable the interrupts
};
/******************************************************************
* main - entry point to this program
*
* Calling convention:
* main()
*
* Returns: nothing
******************************************************************/
void main(void) {
CONFIG_COPD = 1; // turn off the COP
InitIO();
InitPLL();
InitADC();
EnableInterrupts; /* enable interrupts */
for(;
{
asm nop;
} /* loop forever */
};
/******************************************************************
* Interrupt for the ADC
*
* Calling convention:
* lecturaadc()
*
* Returns: nothing
******************************************************************/
interrupt VectorNumber_ADC void lecturaadc(void)
{
ADCresult = ADRL; //get and store ADC result
PTC_PTC2 ^= 1;
}
I haven't checked the program but it seems to work. The PTC2 pin toggled at 4.8 kHz, which means that the interrupt was running at about every mS.
Regards,
Ake