Jump to content
Sign in to follow this  
fred

Timer1 Not Jumping To Interrupt()...?

Recommended Posts

I'm having some strange results using timer1. In MPLAB I just discovered when TMR1IF is set and TMR1 already passed 0 it just continues stepping a 'while' in main() before jumping to interrupt()....

 

Is this normal behaviour or am I doing something wrong probably?

 

I'm running a 16F648A at 4MHz

 

some examples:

TMR1 at measurepoint-1 0xFCD6 it has the value of 0x88 at measurepoint-2

TMR1 at measurepoint-1 0xFF00 it has the value of 0xBA at measurepoint-2

TMR1 at measurepoint-1 0xFA00 it has the value of 0xA6 at measurepoint-2

 

 

void interrupt( void ) {
//Handle timer1 interrupt
if( pir1 & (1<<TMR1IF) ) {
////////////////////////
// measurepoint 2 //
////////////////////////
	TMR1handler();
	clear_bit( pir1, TMR1IF ); 	
}

//Handle timer0 interrupt	
if( intcon & (1<<T0IF) ) {
	// timer0 code
	clear_bit( intcon, T0IF );
}

if( intcon & (1<<INTF) ) {
	// RB0 falling edge interrupt
	if (( bitno == 0 ) && ( stream.num == 0 )) {
		clear_bit( t1con, TMR1ON );
		TMR1start( 0xFFFF + 0x50 - 889 );
////////////////////////
// measurepoint 1 //
////////////////////////
		lValue= 1;						  
		bitValPeriod= 0;			  
		buffer.num= 0;
	}
	clear_bit( intcon, INTF );
	}
return;
}

 

btw. something likes to happen also on the RB0 interrupt. Stimulus is generating a 1->0 pulse at 90000 ticks. the tickcounter says 90200 at the start of the the generated RB0 interruptroutine for this

Edited by fred

Share this post


Link to post
Share on other sites

You setting the PEIE bit in the intcon register? (it's PEIE on the 876, the "Peripheral Interrupt Enable bit" in the interrupt register). That might have something to do with why it can overflow and not call the interrupt. The interrupt call may be as a result of other interrupts.

Share this post


Link to post
Share on other sites

thanks twomers!

 

I never realized to set PEIE for TMR1 and it was entering the interrupt routine cause of TMR0 overflow and not of TMR1...

That's also explains why the delay between tmr1 overflow and starting the tmr1 routine never exceeded my setting for TMR0.. :(

Share this post


Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...