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 CCS Technical Support

I need help!! (i2c, picdem 2 board)

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



Joined: 24 Aug 2010
Posts: 3
Location: south korea, incheon,

View user's profile Send private message MSN Messenger

I need help!! (i2c, picdem 2 board)
PostPosted: Tue Aug 24, 2010 8:17 pm     Reply with quote

Sad

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!! Question Question Exclamation

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 );

}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Aug 24, 2010 8:53 pm     Reply with quote

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.
choosujin



Joined: 24 Aug 2010
Posts: 3
Location: south korea, incheon,

View user's profile Send private message MSN Messenger

THANK YOU!! THANK YOU!!
PostPosted: Tue Aug 24, 2010 11:24 pm     Reply with quote

PCM programmer wrote:
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.


THANK YOU!! THANK YOU!! THANK YOU!! Very Happy

It does work!!! Smile
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