Hello,
I am attempting to use the Input Capture channel 1 to time pulses from an IR receiver. I have it set up to trigger an interrupt on the stop condition. The strangeness begins when an interrupt is triggered. DC 9.52 tells me that a Quadrature Decoder interrupt has been triggered but there is no vector assigned to handle the interrupt. I have QDCR set to 0x00 to disable QD ints, but they keep happening.
#class auto
const unsigned char PRESCALEA8 = 36;
unsigned int IC1_count;
char in_int;
char capture_status;
void IC1_ISR();
void main()
{
unsigned long pulse_width;
float pulse_time;
SetVectIntern(0x1A, IC1_ISR);
IC1_count = 0;
in_int = 0;
capture_status = 0;
WrPortI(ICS1R, NULL, 0x00); //PC1 is pulse capture pin for channel 1
//timer a8 prescaler for input capture
//division for timer A is n+1
//so every (prescaleA8 + 1) one pulse is output to the input capture
//for PRESCALEA8 = 36, 1.6uS resolution and 106mS til overflow
WrPortI(TAT8R, NULL, PRESCALEA8);
WrPortI(ICCSR, NULL, 0x14); //zero out counters int on IC1 stop
WrPortI(ICCR, NULL, 0x01); //int priority 1
WrPortI(QDCR, NULL, 0x00);
//run counter start to stop
//start is falling edge, stop is rising edge
//latch counter on stop
WrPortI(ICT1R, NULL, 0x59);
pulse_width = 0;
while(1)
{
if (IC1_count)
{
printf("Count: %u
", IC1_count);
}
if (capture_status)
{
printf("Status: %x
", capture_status);
capture_status = 0;
}
if (in_int)
{
printf("ISR entered
");
}
}
}
#asm
IC1_ISR::
push af
push hl
ld a, ICCSR ;clear INT
ld (capture_status), a
bit 4, a
jr z, done
ld l, ICL1R
ld h, ICM1R
ld (IC1_count), hl
done:
ld a, 0x01
ld (in_int), a
pop hl
pop af
ipres
ret
#endasm
According to the documentation, 0x1a is the vector for a IC interrupt, while 0x19 is the vector for a QD interrupt. I tried switching the vectors in my SetVectIntern() statement, but then it tells me that a IC interrupt has occurred, but the vector is uninitialized.
What do I have to do to get the IC ints working properly?