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

INT_RB problem [solved]

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



Joined: 11 Mar 2010
Posts: 19506

View user's profile Send private message

PostPosted: Mon May 16, 2011 2:54 pm     Reply with quote

Key is that on the chip you have, INT_RB, is available on all eight pins of PORTB, not just the high four pins. The reference in the manual does tell you that extra features are available on some chips, and to check the .h file for your chip.

Code:

   clear_interrupt(INT_RB);
   clear_interrupt(INT_EXT);
   enable_interrupts(INT_EXT_H2L);
   //enable_interrupts(INT_RB); This would turn on _all_ RB interrupts
   enable_interrupts(INT_RB4|INT_RB5|INT_RB6|INT_RB7);
   //Turn on INT_RB for the high four pins only - unlike other interrupt
   //enables, these can be 'ored' together
   enable_interrupts(GLOBAL);


The reason for INT_RB, having priority over INT_EXT, would be down to the order the two routines are declared, and that INT_RB will remain triggered unless the port is read (level triggered), while INT_EXT, is an edge triggered routine.

Best Wishes
Stormrider



Joined: 15 May 2011
Posts: 6
Location: San José, CR

View user's profile Send private message MSN Messenger

PostPosted: Mon May 16, 2011 4:51 pm     Reply with quote

@ PCM Programmer

Thanks again for scanning the code thoroughly, I have some comments to say:
1. The ADC at this time is not crucial, it was meant for interfacing the LM35 (analog thermometer) but found out the digital DS1631 is far better. The ADC as it is works fine, only from 0 to 10V with an error of 0.1V (way to high for the LM35), to fix this I know I have to change the REF it uses, but is not important at this moment.
2. I'm not including the .h from my project, it has the fuses and some defines, like

Code:
#define RE0 PIN_E0
#define RE1 PIN_E1
#define RE2 PIN_E2


which makes more easy just to write RE0 and so on.

3. By changing IOCB=0xF0 the problem of B0 triggering INT_RB was solved, and this leads me to a new conclusion:

4. My only interest is to implement push buttons on port B (IOC and not necessarily flank detection), I was just playing with INT_EXT while the problem of INT_RB was solved (the wrong address registers you suggested). At this moment I'm just planning of deleting INT_EXT and using the whole INT_RB interruption.

@Ttelmah

5. I did read the 16F887.h and noticed there were INT_RB, INT_EXT, INT_RB0,..., INT_RB7, but tried to implement the ISR as INT_RB7 and the compiler complaint about it, I didn't know it had to be like this:
Code:
enable_interrupts(INT_RB4|INT_RB5|INT_RB6|INT_RB7);

At this time I just blew out the INT_EXT and I'm currently working with just EXT_RB managing all the pins.

Anyhow, my deepest thanks to both of you, I just finished this routine successfully.
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