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 support@ccsinfo.com

I2C Hardwaremode Problem

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







I2C Hardwaremode Problem
PostPosted: Wed May 07, 2003 2:47 am     Reply with quote

<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
PostPosted: Wed May 07, 2003 5:31 am     Reply with quote

<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
PostPosted: Wed May 07, 2003 7:50 am     Reply with quote

:=<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
PostPosted: Wed May 07, 2003 8:03 am     Reply with quote

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
PostPosted: Sun May 11, 2003 11:19 pm     Reply with quote

Does no one have any ideas?
___________________________
This message was ported from CCS's old forum
Original Post ID: 14368
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