Log in

View Full Version : Pic16f88-I2c-Interrupt PORTB...



robert0
- 24th February 2006, 17:18
I'm using a Pic16f628 , a PCF8524 to drive some Leds and a 24c08
Now i added a PIC16F88 to use its hardware I2c.
At this point everything ok reading and writing on I2c bus.

Problems arise when i set the interrupt on PORTB on pic16F88.
I thought about SCL pin (PORTB4) wasn't affected by interrupt because used by I2C Hardware but i get interrupt everytime the other Pic read or write on I2c network BUT i want an interrupt only on the three left pins of portB.

I2c hardware does not overrides PORTb interrupt so PORTB4 (SCL) is a normal input port like PORTB.5/6/7.

Am I missing some register settings?
I set :
CMCON=$07
ANSEL=0
ADCON0=0
SSPCON=%00100000 'MASTER I2C

Thanks.
Roberto


Greetings from 2006 Winter Olympic City

BigWumpus
- 25th February 2006, 17:26
Oh,

out of the datasheets there is no solution...

It looks like the SSP-device is interfering the PortB-Change-INT.

Has You asked the technicans on support.microchip.com ? Just open a new ticket !

robert0
- 28th February 2006, 08:57
Answer From Microchip ticket:


I'm sorry, but this is a known errata issue.

http://ww1.microchip.com/downloads/en/devicedoc/80171j.pdf

7. Module: PORTB Interrupts
When the PORTB interrupt-on-change feature and
a PORTB peripheral are enabled simultaneously,
the PORTB peripheral input signal’s rising and
falling edges will trigger an interrupt-on-change
event. This is due to the interrupt-on-change
feature not being disabled on the respective pin for
that peripheral when it is enabled.
The affected pins and peripheral signals on
PORTB are RB4: SCK and SCL, RB5: SS and
RB6: T1CKI. The functionality of T1OSI (RB7),
T1OSO (RB6) and TX/CK (RB5) is not affected by
this issue.
Work around
None.

But the big problem are the last words.......Work around = none.

Roberto

BobK
- 28th February 2006, 12:12
Hi Roberto,

Why not consider using a 16F872 or another PIC (16F877) that has the SCK and SCL on Port C so that you can continue using the Port B interrupt change? More pins, more possibilities!

BobK

robert0
- 28th February 2006, 12:35
Hi BobK,

yes i did it, considering 16F876.
Unfortunately i have to make again the pcb , and the most part of pins are useless to my project ( i use 8 pins only)...but things are gone this way.

So if you use I2c slave DONT use portB interrupt.

I regret that i spent a lot of time thinking i was writing bad code or made bad soldering..but i thanks MicroChip staff for their quick response to my question.



Roberto

Ioannis
- 14th September 2007, 13:50
I know its been too long but now I am in the I2C too and looking around for Interrupt solutions found this thread.

If I may suggest to use interrupts on PORT B but discriminate in the ISR where that interrupt came from in the first place. If it was by I2C then serve I2C_ISR else serve OTHER_BIT_ON_PORTB_ISR.

Just an idea if it is not tooo late!

Ioannis

tenaja
- 23rd September 2007, 03:38
The 16F88 doesn't have a hardware Master I2C. It's got Slave & Master SPI, but for I2C it's only Slave. You have to hard-code (i.e. use your basic commands for s/w I2C) the I2C master on this one.

See the datasheet...pg 89 shows the only master option as "firmware controlled" (meaning it's not in hardware). Besides that, your SSPCON settings were for SPI master, despite your comment indicating I2C.