PIC24F16KA101 and interrupts

Status
Not open for further replies.

card_claud

Newbie level 4
Joined
Jun 26, 2006
Messages
5
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,322
Hi !

I am using for the first time PIC24, programming in C and using MPLab + Hitech.

I do not know why, but I am not getting the interrupt work. I put a breakpoint inside the interrupt, but seems it never comes inside...
Someone could help me, please ?


My code:

Setting:

//----- TIMER1 -------------
T1CON = 1000000000000000 ; //ON, FOSC/2, 16bits
PR1 = 0;
TMR1 = 0;
T1IF = 0;
T1IE = 1; //Seta interupção

And Interrupt vetor

void interrupt TMR01 (void) @ T1_VCTR
{

while (1) { };

}

Thanks in advance
 

Hi !

I am using for the first time PIC24, programming in C and using MPLab + Hitech.

using the C30 compiler it looks something like
Code:
void Timer1init()
{
    T1CON = 0x00; 			//Stops the Timer1 and reset control reg.
    TMR1 = 0x00; 			//Clear contents of the timer register
    PR1 = 4000;				//Load the Period register with 1mSec counter 
   // PR1 = 16000U;				//Load the Period register with 1mSec counter 
	IPC0bits.T1IP = 0x01; 	//Setup Timer1 interrupt for desired priority level
	// (This example assigns level 1 priority)
	IFS0bits.T1IF = 0; 		//Clear the Timer1 interrupt status flag
	IEC0bits.T1IE = 1; 		//Enable Timer1 interrupts
	T1CONbits.TON = 1; 		//Start Timer1 with prescaler settings at 1:1 and
							//clock source set to the internal instruction cycle
}

volatile int mSecDelayCounter=0;         // used in the millsecond delay function

/* interrupt service routine for Timer1 ISR*/
void __attribute__((__interrupt__, __shadow__)) _T1Interrupt(void)
{
/* Interrupt Service Routine code goes here */
IFS0bits.T1IF = 0; 							//Reset Timer1 interrupt flag														
mSecDelayCounter--;	
}
 
Thanks a lot !

I compared with my code, and I figured out where ther erro was.

First = I did a mistake here : T1CON = 1000000000000000 -> correct is T1CON = OB1000000000000000
Second = PR1 = 0; I can´t put zero value here...

Thanks again my friend !
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…