CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

interrupts causes chip to freeze after intput() command

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
grasspuddle



Joined: 15 Jun 2006
Posts: 66

View user's profile Send private message

interrupts causes chip to freeze after intput() command
PostPosted: Mon Jul 10, 2006 2:36 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Jul 10, 2006 2:47 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Jul 10, 2006 3:02 pm     Reply with quote

errors is in the #use command

it locks up with ANY interrupt not just serial ints Sad
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Jul 10, 2006 3:08 pm     Reply with quote

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

View user's profile Send private message Send e-mail Visit poster's website

Re: interrupts causes chip to freeze after intput() command
PostPosted: Mon Jul 10, 2006 6:25 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Jul 11, 2006 9:42 am     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Jul 11, 2006 11:53 am     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Jul 11, 2006 11:58 am     Reply with quote

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

View user's profile Send private message Send e-mail

PostPosted: Tue Jul 11, 2006 8:52 pm     Reply with quote

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.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group