This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Timer 0 triggering a FIQ on the Keil MCB2130 board

I've read and reread the Phillips manual and still have a problem with a fast interrupt routine. I want timer 0 to trigger a fast interrupt. In the timer 0 service routine, I just want to do an A/D conversion into an array. I can't seem to get it to work. I'd appreciate it if anyone could tell me what I am doing wrong. The interrupt service routine and the routine which set up timer 0 are shown below. In the rest of the program, I just enable the timer 0 interrupt to start it off and disable it when the array is filled

Thanks in advance, Jim


void fiqint(void) __fiq
//
// Timer 0 interrupt routine
//
{
unsigned int val;


AD0CR |= 0x01200000; // start A/D conversion
do
val = AD0DR;
while ((val & 0x80000000) == 0);
AD0CR &= ~0x01000000;

data[index++] = val;

T0IR = 0x08; // clear the flag
VICVectAddr = 0;
}

void timer0_init(void)
// sets up timer 0 to interrupt every sample time using the FIQ interrupt

{
// float sample_freq;

T0MR0 = (VPB_CLOCK / (SAMPLES_PER_CYCLE * expected_freq)) - 1;
// sample_freq = ((double) VPB_CLOCK) / ((double) (SAMPLES_PER_CYCLE * (T0MR0) + 1));
// printf("T0MR0 is %d\n\r", T0MR0);
// printf("Sample frequency is %g\n\r", sample_freq);

T0MCR = 3; // timer 0 triggers on match and resets itself
T0TCR = 1; // start the clock

VICIntSelect = (1 << 4); // Timer0 made to be the FIQ
}