Hi, I'm using Timer T6 to generate a clock for a device and I want to keep a count of these clock pulses. Also I want to use CC12 as positive edge interupt (P2.12). I have kept the priority of this interupt higher than that of the timer. I have pasted the code to achieve this below. My problem is that when I try to give interupt on P2.12, the CPU enters T6 interupt routine. Please can anyone help me solve this problem. Thanks and regards Sonali //------------------------------------------------ #include <stdio.h> #include <reg167.h> sbit ADC_CONV = P3^5; sbit ADC_BUSY = P2^12; unsigned int num = 0x00; void timer6(void) interrupt 0x26 { num++; } void adc976(void) interrupt 0x28 { ADC_CONV = 0; ADC_CONV = 1; } void main(void) { P2 = 0x0000; DP2 = 0x0000; P3 = 0xFFFF; DP3 = 0xFFFF; CC12IC = 0x46; CCM3 = 0x0001; T6 = 0x6768; CAPREL = 0xFFC3; T6CON = 0x8201; T6IC = 0x44; T6R = 1; IEN = 1; ADC_CONV = 0; ADC_CONV = 1; while(1) { ; } }
Eventhough I didn't have a direct answer for your question, I will tell u a indirect way to solve the problem. I think u used the timer 6 interrupt to count the clock pulses. Wat is the need to use the timer 6 interrupt?. Instead of that, in a infinity while loop in main, u can do the polling for Timer 6 overflow flag. Whenever the Timer 6 overflows, u increment the 'num' variable. Remove the Timer 6 interrupt rountine. Try out this.
hi, Thanks for the reply. I'll try out ur suggestion. In the meanwhile, I've found my mistake. I have given interupt number 0x28 to adc976. Actually it is 0x1C (decimal value = 28).