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
 
Thread Tools Display Modes
Old 11th November 2004, 01:24 PM   (permalink)
SnM
Experienced Member
SnM is on a distinguished road
Send a message via AIM to SnM
Default 12f629 - int on pin change, and tmr0 not working together...

I burned a project that had pin 3 of my 12f629 enabled for interrupt on pin change. I did this so I can put the pic to sleep, and wake it back up when a certian switch is enabled. it works great.

now I am rewriting the code so I can use the tmr0 feature. this is so I can have accurate timing thoughout my code. everything works fine in MPLAB with this enabled, and the interrupt on pin change disabled.

Now I decided to include the interrupt on pin change, but after I write my settings to the intcon register, INTCON bit 0 goes high (if pin 3 is high), and then goes to my interrupt routine. Even in my interrupt routine, I clear that bit, and it goes back to high as soon as I clear it. This is with the input high, and not changing states. it is treating it as the pin state has changed, every time, even though it has not.

I noticed if i don't enable the tmr0 interrupt, then it works fine. so i am thinking that either the interrupt on pin change, and tmr0 don't like to be set together, or maybe MPLAB has an issue???

Thanks.
steve
SnM is offline   Reply With Quote
Old 12th November 2004, 04:47 AM   (permalink)
Experienced Member
sardineta is on a distinguished road
Default

check if inside the ISR_routine there are lines that check from where the interrupt is coming.


ISR_routine

btfsc INTF
goto RB0_int

btfsc T0IF
goto TMR0_int

etc...
sardineta is offline   Reply With Quote
Old 12th November 2004, 10:52 AM   (permalink)
SnM
Experienced Member
SnM is on a distinguished road
Send a message via AIM to SnM
Default

Well I figured out a work around, but I still don't get it. I would have figured out what caused the interrupt in my interrupt sub routine, but i didn't get that far.

what i noticed was that the bit that goes high when a pin change happens is always high. even if i clear that bit, it come back at the next instruction cycle, and that is without any additional pin changes....
SnM is offline   Reply With Quote
Old 16th November 2004, 05:37 PM   (permalink)
Experienced Member
sardineta is on a distinguished road
Default

ok at INTCON register

GIE, and RBIE have to be 1 in order you to have the interruption enable,
any change on RB4, RB5 RB6 and RB7 will fix RBIF be 1,
so you have to check it, or change this interruption pin by using RB0.

even if you have cleared RBIF inside the ISR routine it will be 1 if something happens so it will be called again.

TMR0 has no problem, it will call ISR routine every time it overflows.

what do you want to do?
how many external interruptions are you handling ?

sorry for the delay
sardineta is offline   Reply With Quote
Old 16th November 2004, 06:00 PM   (permalink)
SnM
Experienced Member
SnM is on a distinguished road
Send a message via AIM to SnM
Default

actually the problem is that the GPIF bit gets set after I clear it with no changes to any of the pins. not sure why...... could it be something wrong with MPLAB?
SnM is offline   Reply With Quote
Old 16th November 2004, 06:20 PM   (permalink)
Super Moderator
 
Nigel Goodwin is a splendid one to beholdNigel Goodwin is a splendid one to beholdNigel Goodwin is a splendid one to beholdNigel Goodwin is a splendid one to beholdNigel Goodwin is a splendid one to beholdNigel Goodwin is a splendid one to behold
Default

Quote:
Originally Posted by SnM
actually the problem is that the GPIF bit gets set after I clear it with no changes to any of the pins. not sure why...... could it be something wrong with MPLAB?
Try it in a real PIC, a simulator is just that, it's not like the real world. Certainly in the older PIC simulators there were various limitations, but I've not used one this century :lol:
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is online now   Reply With Quote
Old 16th November 2004, 06:55 PM   (permalink)
Experienced Member
sardineta is on a distinguished road
Default

mmmm I do not know, if mplab has mistakes

read page 19 of the datasheet
also read page 13 and 21

GPIF is set when GP5:GP0 has changed, the datahseet says something important on page 21 in the gray box

you have to configure also IOC register
in summarize
INTCON
OPTION_REG
TRISIO
WPU
IOC

check if you are on the correct bank, everytime you set or clear a bit flag or register, always work on bank 0, go to bank 1 when needed by a register
sardineta is offline   Reply With Quote
Old 16th November 2004, 07:30 PM   (permalink)
SnM
Experienced Member
SnM is on a distinguished road
Send a message via AIM to SnM
Default

everything appears to be setup correctly. i'll have to double check tomorrow.... i'll post back what i find.

thanks
SnM is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes




All times are GMT. The time now is 10:52 PM.


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