![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
choosujin
Joined: 24 Aug 2010 Posts: 3 Location: south korea, incheon,
|
I need help!! (i2c, picdem 2 board) |
Posted: Tue Aug 24, 2010 8:17 pm |
|
|
Sorry, i'm not english native.
I need help!!
this is my code to operate termperature sensor!!
It does not work!! T^T
Help me!! what is going on my code?
I think, is it i2c setting wrong?
Result is 0xff...always,...help!!
I used PICDEM 2 PLUS board, PIC16F877A ,ccs-c, mplab 7.31
Code: |
#include <16F877A.H>
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP,nocpd,nolvp
#use delay(clock = 4000000)
#include "flex_lcd.c"
#use i2c(master,sda=PIN_C4,scl=PIN_C3,FAST)
int8 temp;
void lcd_out(int8 j);
//void ch();
void main()
{
unsigned char cmd_byte=1;
//int i;
lcd_init(); //lcd init
i2c_start();
i2c_write(0X9A);
i2c_write(cmd_byte);
i2c_start(); //restart.
i2c_write(0X9B);
//i2c_write(0);
i2c_stop();
lcd_out(temp);
}
void lcd_out(int8 j)
{
lcd_init();
lcd_gotoxy(1,1);
lcd_putc("Temperature!!\n");
lcd_gotoxy(1,2);
printf(lcd_putc, "temp: %u(Degree)", j );
} |
|
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Aug 24, 2010 8:53 pm |
|
|
Download the TC74 data sheet:
http://ww1.microchip.com/downloads/en/DeviceDoc/21462c.pdf
Look on page 8, in this section:
Quote: | TABLE 4-1: COMMAND BYTE
DESCRIPTION |
What command byte should you send to read the temperature ?
What are sending ? Look at your code. |
|
![](templates/subSilver/images/spacer.gif) |
choosujin
Joined: 24 Aug 2010 Posts: 3 Location: south korea, incheon,
|
THANK YOU!! THANK YOU!! |
Posted: Tue Aug 24, 2010 11:24 pm |
|
|
THANK YOU!! THANK YOU!! THANK YOU!!
It does work!!! ![Smile](images/smiles/icon_smile.gif) |
|
![](templates/subSilver/images/spacer.gif) |
|
|
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
|