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

On-Change Interrupt

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



Joined: 04 Jul 2005
Posts: 8

View user's profile Send private message

On-Change Interrupt
PostPosted: Tue Jul 12, 2005 12:28 pm     Reply with quote

My program goes into the PORTB on change interrupt service routine, #INT_RB, even though I can't see any signals changing on these ports. I am using the CDC-library of CCS to send data via USB to the PC, but I can't find where CDC may be interfering with portB. Any suggestions?...

I use to setup port b pin b4:

port_b_pullups(true);
set_tris_b(0x10);
enable_interrupts(INT_RB);

Thanks,
Andy
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Jul 12, 2005 1:36 pm     Reply with quote

Do you mean that you get an INT_RB interrupt as soon as
you enable interrupts ?

If so, it's happening because you didn't clear the "change" condition
on Port B before you enabled interrupts.

You do this by reading port B.

Code:

#byte PortB = 6     // Address of Port B for the 16F series PICs

main()
{
char c;

port_b_pullups(true);
set_tris_b(0x10);
enable_interrupts(INT_RB);
c = PortB;    // Read PortB before enabling global interrupts.
enable_interrupts(GLOBAL);

while(1);
}
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

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

PostPosted: Tue Jul 12, 2005 6:09 pm     Reply with quote

Read this->
http://www.ccsinfo.com/forum/viewtopic.php?t=23421&highlight=portb+output+interrupt
alwaysfresh



Joined: 04 Jul 2005
Posts: 8

View user's profile Send private message

PostPosted: Wed Jul 13, 2005 7:47 am     Reply with quote

Works!... Thank you Mark your the best.

This morning I was starting to think the PIC's input at portB was broken or something. Safed again.


Andy
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