View previous topic :: View next topic |
Author |
Message |
TYDOM17
Joined: 24 Apr 2017 Posts: 17
|
INT_SSP w/ INT_RB |
Posted: Fri Jun 23, 2017 4:01 pm |
|
|
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
|
|
Posted: Fri Jun 23, 2017 4:13 pm |
|
|
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
|
|
Posted: Fri Jun 23, 2017 4:27 pm |
|
|
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
|
|
Posted: Fri Jun 23, 2017 4:34 pm |
|
|
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
|
|
Posted: Fri Jun 23, 2017 4:48 pm |
|
|
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
|
|
Posted: Mon Jun 26, 2017 9:03 am |
|
|
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
|
|
Posted: Mon Jun 26, 2017 9:15 am |
|
|
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
|
|
Posted: Mon Jun 26, 2017 10:16 am |
|
|
Ttelmah,
Great information, thanks for sharing! |
|
|
|