Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
LinkBack Thread Tools Display Modes
Old 25th January 2005, 06:20 PM   (permalink)
Default HELP!! INTERRUPT PROBLEM

Could anyone help me out. I have included my C code. I want to create two signals on the my PIC DEMO PLUS 2 board RA0 and RA1. I am getting an interrupt on RA0 but nothing on RA1. RB0 is my interrupt PIN. I have set all my registers according to the datasheet. but getting confused.

#include <io16f877.h>

#pragma vector = 0x1
__interrupt void externISR()
{
if(INTF) //loop controllling software design of interrupts on PIC
{
RA0 = 0; // ensuring RA0 set low
RA1 = 0;

TMR1H = 0xF6; // Pre - load timer with this value = 63035
TMR1L = 0x3B; // We want an overflow after 2500 ticks (interval of 20ms)
// As (2^16 -1)-2500 = 63035
TMR2 = 0x0;
TMR2IF = 0x0;

TMR1IF = 0; // no interrupt flag
INTF = 0; //related with INTCON register in void main, set to 0 here to clear interrupt.
}
else if(TMR1IF)
{
RA0 = 1; // RA0 set high when interrupt occurs
}
else if(TMR2IF)
{
RA1 = 1;
}

}

void main()
{
TRISA = 0x0; //Set as an output on PortA
TRISB = 0x1; //Set as an input on PortB
RA0 = 0; // RA0 always set low
RA1 = 0;

INTEDG = 0x1; // Set to trigger off the rising clock edge.
INTCON = 0x90; //this is our control and status of our interrupts.
T1CON = 0x3d; // sets the prescaler value of clock 1:8, oscillator enabled,internal clock selected
TMR1IE = 1;
TMR1IF = 0; // set at zero, flags are seen when = 1

T2CON = 0x7F;
TMR2IE = 1;
TMR2IF = 0;
PEIE = 1;
PR2 = 0xFF;

while(1);
}
aidantmurphy is offline  
Old 25th January 2005, 07:25 PM   (permalink)
Default

Hi,

There are control registers (TMR1ON, TMR2ON) that enable and disable the timers on 16f877. I did not see where they are explicitly being set.

I would also personaly reset the relevant timers once the interrupt has occured (does tmr2 get reset if tmr1 has caused an interrupt?).

How is the INTF being triggered?
spirosd is offline  
Old 26th January 2005, 01:55 PM   (permalink)
Default

Quote:
Originally Posted by spirosd
Hi,

There are control registers (TMR1ON, TMR2ON) that enable and disable the timers on 16f877. I did not see where they are explicitly being set.

I would also personaly reset the relevant timers once the interrupt has occured (does tmr2 get reset if tmr1 has caused an interrupt?).

How is the INTF being triggered?
yeah , i am the beginner . can u help me . post the link to the C compiler for PIC . thanks
__________________
Rock Mental
Jacky is offline  
Old 26th January 2005, 07:52 PM   (permalink)
Default

Quote:
Originally Posted by Jacky
yeah , i am the beginner . can u help me . post the link to the C compiler for PIC . thanks
Did you try googling? Also take a look at gnupic.
spirosd is offline  
Reply

Bookmarks

Thread Tools
Display Modes





All times are GMT. The time now is 04:08 PM.


Electronic Circuits  |  Learning Electronics
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.

eXTReMe Tracker