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 support@ccsinfo.com

Obscure issue with the PCM compiler!

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







Obscure issue with the PCM compiler!
PostPosted: Sun Jan 25, 2009 2:09 pm     Reply with quote

Hi all

I am having a seemingly strange problem compiling a program for a PIC16F876A with the PCM compiler; apologies for the slightly long description!

I have written a program that uses the RB0 interrupt to trigger various actions on a button press. The program was running absolutely fine, when each press would toggle the appropriate action as part of a simple state machine (debouncing routine included!). However, I added a 'printf' statement to a function called from within the RB0 interrupt routine, and now the program will only enter the interrupt handler once after reset! The first time the button is pressed, the program runs correctly, but with the extra printf command, the PIC does not even enter the interrupt handler for a second time; especially strange since the program counter hasn't even got to the offending printf yet!

Using a debugger to pause execution when the PIC has 'crashed', MPLAB reports it to be at the line which sets up I2C ('#use i2c...etc)!

I'm afraid I am at a loss as to how adding a call to printf would cause the program to fail before it has even got to that line of code! Could it be something to do with using a bit more ROM and therefore the compiler placing the instructions in a bit of memory not accessable by simply calling the function?! (Apologies for the un-educated guess - I'm a hardware engineer trying to solve a software problem!)

Any help would be greatly appreciated!
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Jan 25, 2009 3:09 pm     Reply with quote

It could be the delay time. At 9600 baud, it takes about 1 ms to transmit
one character. If the UART's transmit buffer and output shift register are
empty at the time the printf begins, two characters can be transmitted
with no delay. But any number of characters beyond two, will cause the
equivalent of a delay_ms(1) statement, per character.

Calculate the number of characters you are sending (including CR & LF)
and insert a delay_ms() statement for the equivalent delay. Comment
out the printf statement. See if you still get the problem. If so, it's due
to the delay time in the printf.

I found an old thread with the same type of problem:
http://www.ccsinfo.com/forum/viewtopic.php?t=26883
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