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_SSP w/ INT_RB

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



Joined: 24 Apr 2017
Posts: 17

View user's profile Send private message

INT_SSP w/ INT_RB
PostPosted: Fri Jun 23, 2017 4:01 pm     Reply with quote

Hello PicMasters,
Wondering if anyone else out there has used INT_SSP with INT_RB at the same time and run into the problem of I2C communication spuriously triggering INT_RB interrupts?

I can post my code but I wanted to see if anyone else has had this happen before? My o-scope is showing nochanges/activity on RB4..7 - zip, nada while receiving commands from the MASTER device however the INT_RB is firing away with no clear explanation. If I disconnect Master or stop sending commands, INT_RB is silent until I manually pull RB4...7 high.

I2C is using I2C1 pins C3,C4

PIC18F25K20
V 5.049 PCH
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Jun 23, 2017 4:13 pm     Reply with quote

If you have interrupt-on-change interrupts enabled, you should have
pull-up or pull-down resistors on those pins. You can enable the PortB
internal pull-ups to do this. The pins can't be left floating.
TYDOM17



Joined: 24 Apr 2017
Posts: 17

View user's profile Send private message

PostPosted: Fri Jun 23, 2017 4:27 pm     Reply with quote

PCM programmer,
Thank for the quick response.

I have defined pullups as follows in my main prior to enabling INT_RB:
Code:
//////////////////  PORT B SETUP FOR INT_RB /////////////////////////////////// 
                       
   port_b_pullups(TRUE);     
   delay_us(10);             
   portval=input_b();
   clear_interrupt(INT_RB); 
   
///////////////////////////////////////////////////////////////////////////////


In my hardware...
B4 is tied to an external pull-up resistor 560K
B5 is grounded
B6 is open (ICSP connector)
B7 is open (ICSP connector)

I'll check the datasheet to see if the pullups are all supported on this part.
TYDOM17



Joined: 24 Apr 2017
Posts: 17

View user's profile Send private message

PostPosted: Fri Jun 23, 2017 4:34 pm     Reply with quote

from page 125,126 of the datasheet, all RB0-7 have a programmable weak pull-up available.

On my schematic:
B0 floating
B1 is pulled high through external 2k resistor
B2 is pulled high through external 2k resistor
B3 is tied to gnd
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Jun 23, 2017 4:48 pm     Reply with quote

Post the code that enables the int_rb interrupts.

In your PIC, the int_rb interrupts can be enabled on a "per pin" basis for
PortB. The same thing with pullups. Your parameter of 'TRUE' only
enables pullups on pin B0, because TRUE equates to 1. To enable the
internal weak pullups on all PortB pins, you would use a parameter of 0xFF.

Also, I don't let the PGC and PGD pins float if the programmer is removed.
I set the pins low in my initialization routine that runs at the start of main():
Code:

output_low(ICSP_CLK);  // Not Used -- Except during ICSP programming
output_low(ICSP_DATA); // Not Used -- Except during ICSP programming
TYDOM17



Joined: 24 Apr 2017
Posts: 17

View user's profile Send private message

PostPosted: Mon Jun 26, 2017 9:03 am     Reply with quote

PCM programmer,

Here is my interrupt enable code:
Code:
///////////////////////////  INITIALIZE INTERRUPTS  ///////////////////////////
   ENABLE_INTERRUPTS(INT_SSP);             
   ENABLE_INTERRUPTS(INT_RB4);         
   ENABLE_INTERRUPTS(GLOBAL);                 
                                               
/////////////////////////////////////////////////////////////////////////////// 


Thanks for pointing out the issue with pull-ups TRUE, I will fix this and great idea on the ICSP lines, I will try this as well.

As I am using this PIC in a battery design with target current usage for the PIC being under 100uA while in sleep mode, I do need to be careful with how I use the pullups.
The Tips and Tricks Chapter 2 has been helpful for sure - in your experience have you been able to see much of a current draw from using the weak internal pullups to Vcc?

Some information I have found on the forum and web point to the pullups being ~ 200kohm.
Ttelmah



Joined: 11 Mar 2010
Posts: 19552

View user's profile Send private message

PostPosted: Mon Jun 26, 2017 9:15 am     Reply with quote

The current depends on what they are actually drawing 'up'.
An unloaded line, and the current will be almost zero.
All the internal pullups are, is a small FET current source. The circuit itself draws almost nothing. However if you pulled up a pin that is shorted to ground, then you will be delivering about 60uA.
TYDOM17



Joined: 24 Apr 2017
Posts: 17

View user's profile Send private message

PostPosted: Mon Jun 26, 2017 10:16 am     Reply with quote

Ttelmah,
Great information, thanks for sharing!
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