The Elektor Forum will close. See also this link. From Friday March 1st it is no longer possible to log in to the forum. However, the content of the forum will remain visible until the end of March. As of April 1st the forum will definitely go off the air.

I2C problem with TC74 and standby mode

An Elektor Distance Learning Course

Postby chuckie » Sun May 19, 2013 12:00 am

I am having a problem getting my TC74 into standby mode using the source code from the course.
There is minimal change (1.29mA to 1.28mA) in the current to the TC74 after "stand-by mode" appears in the LCD.

This is the relevant line of code: (Line numbers are from the program tc74_in_standby_mode.c source on the course CD.)

72// send 7 bit address and write bit (1)
73i2c_write(0b10010001);

Line 73 above is a read operation but I think it should be a write.
When I change this line to

72// send 7 bit address and write bit (0)
73i2c_write(0b10010000);

and run the program I get a current change from 1.28mA to 1.07mA (a difference of 0.210mA) which is roughly what the TC74 datasheet page 1 states:

normal operation quiescent current 0.2mA
standby operation quiescent current 0.005mA
a difference of 0.195mA

The code in tc74_in_standby_mode.c does not check ACK responses from the TC74 and the text "stand-by mode" appears if the TC74 is in stand-by mode or not.
The i2c_write statements on 79 and 85 are both not acknowledged by the TC74 (sspcon2:ackstat = 1) using the code from the course.

If you replace the code after line 92 with the following error checking code, 'error' is shown on the LCD if line 73 has the write bit set = (1).
If line 73 has the write bit cleared = (0), the LCD correctly shows 'stand-by mode' and the current to the TC74 drops from 1.28mA to 1.07mA.

91i2c_stop;
92
93// add error checking code
94lcd_locate(0,0);
95// check if error condition
96if (reply) lcd_printf("error ");
97else
98{
99// display standby mode
100lcd_locate(0,1);
101lcd_printf("stand-by mode");
102}
chuckie
 
Posts: 2
Joined: Thu Jan 02, 2014 10:49 am

Postby geenbert » Sun May 19, 2013 12:00 am

You are absolutely correct. Even though the comment says "write" the read/write bit is set to read. Lines 72 and 73 should indeed be:

72// send 7 bit address and write bit (0)
73i2c_write(0b10010000);

Checking the ACK response isn't discussed till the next section, but you made very clever use of it in this part to locate the error!

I'll make sure this is added to the errata, and corrected in future prints. Thanks for taking the time to post this error.
geenbert
 
Posts: 83
Joined: Thu Jan 02, 2014 10:41 am


Return to Programming Embedded PIC Microcontrollers using Assembly, C and Flowcode

Who is online

Users browsing this forum: No registered users and 1 guest