Hi,
Can I use the RB0 Int. and RB4-7 Port Change Int. in the same program?
When I simulate it in Flow Code works well but doesn't run on the real 16F876?
Any ideas?
Thanks
Pinto
Using Interrupts
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: Using Interrupts
Hello Pinto
Yes you should be able to include both interrupts into a single program.
Does the hardware work with only one interrupt enabled? Could be that something is causing the interrupts to fail. If the single interrupt works ok then are you using multiple enable / disable calls that refer to different interrupt handler macros.
Yes you should be able to include both interrupts into a single program.
Does the hardware work with only one interrupt enabled? Could be that something is causing the interrupts to fail. If the single interrupt works ok then are you using multiple enable / disable calls that refer to different interrupt handler macros.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Flowcode v5 User
- Posts: 71
- Joined: Fri Nov 03, 2006 2:28 pm
- Location: RSA
- Been thanked: 1 time
Re: Using Interrupts
THanks for the info,
PIC16F876:
I discovered that I wasn't exiting the Interrup routine that's why I was having problems. I 've RB0 Int. now working everytime I push the Button.
The other problem I'm having is with Port Change Int. When I press a button conected to pins PB4,5,6,7 the program interrupts and increments a counter, exits the Int. Routine and resume were the counter was when the interrupt occour, when it finds the counter checks if it's set and than directs the program to the corretct place resets the counter and waits for the next interrupt.
Ok, this all happens with Flowcode works no problem until I load the program in to the actual chip. If I don't activate the Interrupt the programs runs Ok, but if i push a switch on the interrupt ports the programs appears to freeze and nothing happens, but the processor is not actually froze it's still working but it appear to me that on exiting the interrup corrupts some registers. Not Sure.
A friend told me that he had similar problems (he writes ASM) and he had to save some of the registers at the begin of the interrupt and restore when exiting the interrupt. I find this vefry unlikely. What do you think? Is there anything I'm not doing regarding implementing the interrup?
Regards
Pinto
PIC16F876:
I discovered that I wasn't exiting the Interrup routine that's why I was having problems. I 've RB0 Int. now working everytime I push the Button.
The other problem I'm having is with Port Change Int. When I press a button conected to pins PB4,5,6,7 the program interrupts and increments a counter, exits the Int. Routine and resume were the counter was when the interrupt occour, when it finds the counter checks if it's set and than directs the program to the corretct place resets the counter and waits for the next interrupt.
Ok, this all happens with Flowcode works no problem until I load the program in to the actual chip. If I don't activate the Interrupt the programs runs Ok, but if i push a switch on the interrupt ports the programs appears to freeze and nothing happens, but the processor is not actually froze it's still working but it appear to me that on exiting the interrup corrupts some registers. Not Sure.
A friend told me that he had similar problems (he writes ASM) and he had to save some of the registers at the begin of the interrupt and restore when exiting the interrupt. I find this vefry unlikely. What do you think? Is there anything I'm not doing regarding implementing the interrup?
Regards
Pinto
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: Using Interrupts
Hello Pinto
BoostC does all the messy assembler work for you so you dont have to worry about saving registers etc. I've never had to anyway.
Few things I can think of:
Are you using multiple enable / disable icons for a single interrupt? Or are you using a single macro for both interrupts?
Also does the RB0 interrupt work ok once you have the port change interrupt included in your program?
If you post up your code or email it to me I will take a quick look for you.
BoostC does all the messy assembler work for you so you dont have to worry about saving registers etc. I've never had to anyway.
Few things I can think of:
Are you using multiple enable / disable icons for a single interrupt? Or are you using a single macro for both interrupts?
Also does the RB0 interrupt work ok once you have the port change interrupt included in your program?
If you post up your code or email it to me I will take a quick look for you.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel