View previous topic :: View next topic |
Author |
Message |
Spaark Guest
|
I2C Hardwaremode Problem |
Posted: Wed May 07, 2003 2:47 am |
|
|
<font face="Courier New" size=-1>Im programming an EEPROM with a PIC18F252 and the I2C functions.
Till now i used the Softwaremode, but since i want to switch from I2C-Fastmode to I2c-Slowmode with pressing a key i have to use the Hardwaremode according to this:
<a href="http://www.pic-c.com/forum/general/posts/14091.html" TARGET="_blank"> <a href="http://www.pic-c.com/forum/general/posts/14091.html" TARGET="_blank"> <a href="http://www.pic-c.com/forum/general/posts/14091.html" TARGET="_blank">http://www.pic-c.com/forum/general/posts/14091.html</a></a></a>
Now ive switched to Hardwaremode but there appears a Problem in this part of the software, while it works with softwaremode:
----
setup_timer_1(T1_INTERNAL);
I2CWrite(0x02, Value); //This is a function that writes
//the Value to the adress 0x02 of
//the EEPROM
set_timer1(0);
do{
i2c_start();
ack=i2c_write(0xa0);
}while(ack==true);
Delay=get_timer1();
i2c_stop();
delay_ms(5);
---
This part measures the WriteTime(With WriteCycle Polling Method) that the EEPROM need to write down one byte and it works in softwaremode well. But in Hardwaremode it get stuck. I think it get stuck somewhere in the do-while. Perhaps theres not coming a Acknowledge bit?
But if i put a delay after the I2CWrite function of some milliseconds, it works. But i dont want a delay there because it falsifys the measurment.
Any ideas?
PS: Im using Compilerversion 3.110
Thanks
Spaark
</font>
___________________________
This message was ported from CCS's old forum
Original Post ID: 14230 |
|
|
Spaark Guest
|
Re: I2C Hardwaremode Problem |
Posted: Wed May 07, 2003 5:31 am |
|
|
<font face="Courier New" size=-1>Oh well i tried the hardwaremode again and now the programm get stuck in every I2C function i programmed but i works well with softwaremode
could this be a compiler or a hardware bug?
Compiler: PCH 3.110
PIC: 18F252</font>
___________________________
This message was ported from CCS's old forum
Original Post ID: 14231 |
|
|
PicFan Guest
|
Re: I2C Hardwaremode Problem |
Posted: Wed May 07, 2003 7:50 am |
|
|
:=<font face="Courier New" size=-1>Im programming an EEPROM with a PIC18F252 and the I2C functions.
:=Till now i used the Softwaremode, but since i want to switch from I2C-Fastmode to I2c-Slowmode with pressing a key i have to use the Hardwaremode according to this:
:=
:= <a href="http://www.pic-c.com/forum/general/posts/14091.html" TARGET="_blank"> <a href="http://www.pic-c.com/forum/general/posts/14091.html" TARGET="_blank"> <a href="http://www.pic-c.com/forum/general/posts/14091.html" TARGET="_blank"> <a href="http://www.pic-c.com/forum/general/posts/14091.html" TARGET="_blank">http://www.pic-c.com/forum/general/posts/14091.html</a></a></a></a>
:=
:=Now ive switched to Hardwaremode but there appears a Problem in this part of the software, while it works with softwaremode:
:=
:=----
:=setup_timer_1(T1_INTERNAL);
:=I2CWrite(0x02, Value); //This is a function that writes
:= //the Value to the adress 0x02 of
:= //the EEPROM
:=set_timer1(0);
:=do{
:= i2c_start();
:= ack=i2c_write(0xa0);
:=}while(ack==true);
:=
:=Delay=get_timer1();
:=i2c_stop();
:=delay_ms(5);
:=---
:=
:=This part measures the WriteTime(With WriteCycle Polling Method) that the EEPROM need to write down one byte and it works in softwaremode well. But in Hardwaremode it get stuck. I think it get stuck somewhere in the do-while. Perhaps theres not coming a Acknowledge bit?
:=But if i put a delay after the I2CWrite function of some milliseconds, it works. But i dont want a delay there because it falsifys the measurment.
:=
:=Any ideas?
:=
:=PS: Im using Compilerversion 3.110
:=
:=Thanks
:=Spaark
:= </font>
I recently tried the (24256.c) driver file that demonstrates polling for an ack during the data write cycle. It doesn't work for me either (v3.147), it only hangs.
In looking at the assembly listing, I noticed that it appears the CCS is testing the wrong register for an ACKSTAT bit. The ACKSTAT bit is in the SSPCON2.6 (0xFC5.6) register but I think they are testing the STATUS.2 (0xFD8.2) register instead.
.................... while(status==1)
2996: MOVLW 00
2998: BTFSC 37.0
299A: MOVLW 01
299C: SUBLW 01
299E: BTFSS FD8.2 **THIS IS THE STATUS REGISTER**
29A0: GOTO 29D8
.................... {
.................... i2c_start();
29A4: BCF FA1.3
29A6: BCF FC6.7
29A8: BSF FC5.0
29AA: BTFSC FA1.3
29AC: GOTO 29A4
29B0: BTFSC FC6.7
29B2: GOTO 29A4
29B6: BTFSC FC5.0
29B8: GOTO 29B6
.................... status=i2c_write(0xa0);
29BC: MOVLW A0
29BE: MOVWF 3A
29C0: CALL 0B64
29C4: MOVF 01,W
29C6: BTFSS FD8.2 **THIS IS ALSO THE STATUS REGISTER**
29C8: GOTO 29D2
29CC: BCF 37.0
29CE: GOTO 29D4
29D2: BSF 37.0
.................... }
I'll probably call them later this morning to ask about this.
Best Regards,
PicFan
___________________________
This message was ported from CCS's old forum
Original Post ID: 14236 |
|
|
PicFan Guest
|
Re: I2C Hardwaremode Problem |
Posted: Wed May 07, 2003 8:03 am |
|
|
Sorry, it does appear the SSPCON2.6 is accessed in the CALL 0B64 routine...
:=.................... status=i2c_write(0xa0);
:=29BC: MOVLW A0
:=29BE: MOVWF 3A
:=29C0: CALL 0B64 **checks correct bit at target code**
:=29C4: MOVF 01,W
:=29C6: BTFSS FD8.2
:=29C8: GOTO 29D2
:=29CC: BCF 37.0
:=29CE: GOTO 29D4
:=29D2: BSF 37.0
:=.................... }
But it still doesn't appear to work in my test app.
-PicFan
___________________________
This message was ported from CCS's old forum
Original Post ID: 14238 |
|
|
Spaark Guest
|
Re: I2C Hardwaremode Problem |
Posted: Sun May 11, 2003 11:19 pm |
|
|
Does no one have any ideas?
___________________________
This message was ported from CCS's old forum
Original Post ID: 14368 |
|
|
|