cancel
Showing results for 
Search instead for 
Did you mean: 

Interupt handling problem

skale9
Associate II
Posted on July 17, 2003 at 08:40

Interupt handling problem

3 REPLIES 3
skale9
Associate II
Posted on July 15, 2003 at 10:17

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

#include

#include

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;

CC12IC = 0x46;

CCM3 = 0x0001;

T6 = 0x6768;

CAPREL = 0xFFC3;

T6CON = 0x8201;

T6IC = 0x44;

T6R = 1;

IEN = 1;

ADC_CONV = 0;

ADC_CONV = 1;

while(1)

{

;

}

}

charles239955_st
Associate II
Posted on July 17, 2003 at 06:23

Hello,

It seems that you generate the edge on P2.12 by using P3.5 line. I do not see in the code that this line is configured as output, please check ( DP3 |= 0x0020; ).

I also does not see the interrupt service routine associated to the CC12, trap number 0x1C. If there is no routine associated, maybe your compiler initialises this interrupt vector to an infinite loop and therefore you end into the T6 interrupt when it reaches the limit value.

And then, because of the pipeline effect on the ports, I will insert a NOP instruction between the 2 operation on Port2.

Regards,

Kenshin
skale9
Associate II
Posted on July 17, 2003 at 08:40

Hi Kenshin,

Thanks for the reply. You are right about the trap number. I had assigned it as 0x28 instead of 0x1C. 28 is the decimal equivalent of hex 1C, hence the confusion.

I was not able to detect this error earlier when I had tested T6 separately maybe because of the compiler initialisation.

Regards

Sonali