Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

PIC16F877A I2C: I2C works with the pic kit 2 in debug mode but not without

Status
Not open for further replies.

Rangersfan

Newbie level 4
Joined
Jun 7, 2011
Messages
7
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,338
Hello Everyone,

I have been working on this code for a number of weeks and it is still not working. The area of concern is the PIC16877A interface to the RTC DS1307.

With the Pic Kit2 debugger hooked up in MPLAB the program gets stuck the second time it enters the WaitMSSP loop waiting for btfss PIR1,SSPIF.

When I press "F6" Processor Reset, the circuit works fine I can write and read all the data I want with the PIC Kit 2 debugger connected and it works repeatedly. When ever there is a new build or update to the chip programming the code gets stuck again at the btfss PIR1,SSPIF or if i try to see the information outside the MBLAB debug environment with the UART to my PC it does not work either, even if I cycle the circuit power.
I have tried to create a counter that will cause the program to jump to the reset vector (wishing) if this doesn't initiate properly but it just jumps to org 0000 which is unfortunately not creating the outcome I desire. I have tried to compare the file registers between the working and not working condition but so far it hasn't helped much.

i am continuously modifying the code, it is attached to this post..

Does anyone have any idea what could be going on here? I am running out of ideas and I would be appreciate any help you have to offer.

Thank you,
View attachment decisioncode with UART2.txt
 

The original WaitMSSP function was this:


WaitMSSP
BANKSEL PIR1 ; BANK 0
btfss PIR1,SSPIF ; 0C Check if I2C operation done
goto $-1 ; I2C module is not ready yet
bcf PIR1,SSPIF ; I2C ready, clear flag
return
 

It seems like there is something funny going on with portc and trisc.
There is a difference between the way these two registers react after a build and after a reset.
After watching the values for both of the registers stepping line by line the I2C works when after the function below PORTC=C0 and TRISC=80
I2C does not work when this is not the case, which is no surprise since the MSSP interface in on PORTC, but why these registers are updating differently after a build rather than a reset I have no idea why?

I2CStart:
; Send START condition and wait for it to complete
BANKSEL SSPCON2 ; BANK 1
bsf SSPCON2,SEN ; Generate START Condition
 

The issue where TRISC and PORTC begin to vary is at the line:
banksel SSPCON2
bsf SSPCON2,PEN

I have tried to take snapshots of the file registers before and after these two lines are executed in both after a processor reset(working) and after a build(not working). I have attached this photo, if you have time please look at this. I am pretty stuck. I2C issue.jpg

The issue where TRISC and PORTC begin to vary is at the line:
banksel SSPCON2
bsf SSPCON2,PEN

I have tried to take snapshots of the file registers before and after these two lines are executed in both after a processor reset(working) and after a build(not working). I have attached this photo, if you have time please look at this. I am pretty stuck.

before:
banksel SSPCON2
bsf SSPCON2,PEN
TRISC should be 98
PORTC should be D8
and after those 2 lines
TRISC should be 98
PORTC should be D8
this occurs after I do a processor reset in MPLAB with the pic kit 2 connected and everything works fine
but what happens after a build:
TRISC is 98
PORTC is D8
after:
banksel SSPCON2
bsf SSPCON2,PEN
TRISC is 88
PORTC is D8 (after a rebuild they do not change in synch it seems)
after the next line is executed: banksel TEMPF
PORTC is C8
 
Last edited:

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top