View previous topic :: View next topic |
Author |
Message |
grasspuddle
Joined: 15 Jun 2006 Posts: 66
|
interrupts causes chip to freeze after intput() command |
Posted: Mon Jul 10, 2006 2:36 pm |
|
|
using pic18f452 and a program i wrote worked fine, until i add an INPUT(PIN) command. Main code runs basically like:
Code: |
#interruptcodehere
{}
while(1)
{
if(Input(pin_b4)
...
}
|
The code seems to work fine when it starts up, but when an interrupt is fired (either data from serial port or button being pressed) the pic refuses to respond to anything else. The interrupts work fine with the Input() code commented out. All I am trying to accomplish is to run some code when the pin is high. It has no effect on the interrupts and is seperate from all the other code. Anyone know why the interrupts don't like this command? Also, when I run this program I check the input() returned value in a serial port monitor and it does work. |
|
|
Fro_Guy
Joined: 26 Apr 2006 Posts: 12
|
|
Posted: Mon Jul 10, 2006 2:47 pm |
|
|
You said it may be the serial, did you put the the errors into yout #use rs232 statement?
ie.
#use rs232(errors,baud=56000,parity=N,ENABLE=PIN_C5,xmit=PIN_C6,rcv=PIN_C7,bits=8)
If there is an error it can cause the PIC to freeze up
good luck |
|
|
grasspuddle
Joined: 15 Jun 2006 Posts: 66
|
|
Posted: Mon Jul 10, 2006 3:02 pm |
|
|
errors is in the #use command
it locks up with ANY interrupt not just serial ints |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Jul 10, 2006 3:08 pm |
|
|
Post a small test program, because I don't understand the code
fragments and pseudo-code that you've posted. Make the test
program be very small, and post all the #fuses, #include and #use
statements. |
|
|
asmallri
Joined: 12 Aug 2004 Posts: 1634 Location: Perth, Australia
|
Re: interrupts causes chip to freeze after intput() command |
Posted: Mon Jul 10, 2006 6:25 pm |
|
|
Code: |
#interruptcodehere
{}
while(1)
{
if(Input(pin_b4) <=====
...
}
|
Where's the closing brace on the if line? _________________ Regards, Andrew
http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!! |
|
|
grasspuddle
Joined: 15 Jun 2006 Posts: 66
|
|
Posted: Tue Jul 11, 2006 9:42 am |
|
|
that just shows the basic flow of the code and i didn't check it for perfect 'grammar'
the real code has the parenthesis, it compiles only with the infinite loop warning |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Tue Jul 11, 2006 11:53 am |
|
|
It doesn't sound like a known bug. Most likely it is a programming error, maybe something as simple as an extra colon in the while statement (I allways have to be carefull with that one).
As PCM already told you, without you showing us some actual code we can't help you any further. |
|
|
newguy
Joined: 24 Jun 2004 Posts: 1907
|
|
Posted: Tue Jul 11, 2006 11:58 am |
|
|
Don't know if this applies or not, but if you enable any interrupt without having a handler for it as well, that will lock up the PIC too. |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Tue Jul 11, 2006 8:52 pm |
|
|
newguy wrote: | Don't know if this applies or not, but if you enable any interrupt without having a handler for it as well, that will lock up the PIC too. | Especially if you enable an interrupt and use the wrong interrupt handler, or put the noclear flag in and do not clear the interrupt. |
|
|
|