Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Problem in code

Status
Not open for further replies.

Jyothi@Pic

New Member
Hi,

I am using PIC18f4620 and c18 compiler below is the code when i execute this code the controller does not goto interrupt routine break point is at isr.

If their is any mistake please tell me what corrections is to be made



Code:
#include <p18f4620.h>
 #include <timers.h>

 #define NUMBER_OF_LEDS 8

 void timer_isr (void);

 static unsigned char s_count = 0;

 #pragma code low_vector=0x18
 void low_interrupt (void)
 {
	 _asm GOTO timer_isr _endasm
 }

 #pragma code

 #pragma interruptlow timer_isr
 void timer_isr (void)
 {
 	static unsigned char led_display = 0;

 	INTCONbits.TMR0IF = 0;

 	s_count = s_count % (NUMBER_OF_LEDS + 1);

	led_display = (1 << s_count++) - 1;

 	PORTB = led_display;
 }

 void main (void)
 {
 	TRISB = 0;
 	PORTB = 0;

 	OpenTimer0 (TIMER_INT_ON & T0_SOURCE_INT & T0_16BIT);
 	INTCONbits.GIE = 1;

	while (1)
 	{
 	}
}
 
Timer 0 interrupt enable bit is bit 5. This is the problem when you use library routines rather than write the code yourself.

Mike.
 
INTCON register has 0xA0 value on overflow INTCONbits.TMR0IF=0 is not becoming high so control is not going to isr I am not able to find what is the problem could anybody Please help me.
 
You have now made two statements,
INTCON=0X07 is the value
and,
INTCON register has 0xA0 value. (T added)

You either changed something or you are mistaken.

How do you expect help when we don't know the problem?

Mike.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top