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

No temperature output on RS232

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



Joined: 15 Jul 2008
Posts: 2

View user's profile Send private message

No temperature output on RS232
PostPosted: Wed Jul 16, 2008 2:15 am     Reply with quote

Hi,
I am using PICDEM2 PLUS Demo Board. I used the codes (see below) to program my PIC18F4525 to read the temperature. It is working when i used a 4MHz crystal oscillator, however, when i changed my crystal to 20MHz and changed this to #use delay(clock=20000000), there's no output on my hyperterminal, can anyone guide me on this?..

Thank you.



#include <18F4525.H>
#fuses XT, NOWDT, PROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
#use i2c(master, sda=PIN_C4, scl=PIN_C3)

#define TC74_I2C_WRITE_ADDRESS 0x9A
#define TC74_I2C_READ_ADDRESS 0x9B
#define TC74_READ_TEMP_COMMAND 0x00
#define TC74_READ_CONFIG_COMMAND 0x01


signed int8 TC74_read_temperature(void);

//====================================
void main()
{
signed int8 temp;

while(1)
{
temp = TC74_read_temperature();
printf("Temperature (C) = %d\n\r", temp);
delay_ms(1000);
}

}

//====================================

// Read the temperature (in degrees Centigrade)
// from the TC74.

signed int8 TC74_read_temperature(void)
{
signed int8 retval;

i2c_start();
i2c_write(TC74_I2C_WRITE_ADDRESS);
i2c_write(TC74_READ_TEMP_COMMAND);

i2c_start(); // Re-start
i2c_write(TC74_I2C_READ_ADDRESS);
retval = i2c_read(0);
i2c_stop();

return(retval);
}
Ttelmah
Guest







PostPosted: Wed Jul 16, 2008 2:28 am     Reply with quote

You need to use the HS fuse for crystals above about 4MHz, or the oscillator won't work.
May be the whole problem. Smile

Best Wishes
black_nickle



Joined: 15 Jul 2008
Posts: 2

View user's profile Send private message

PostPosted: Wed Jul 16, 2008 10:40 am     Reply with quote

Oh yes!... my mistake.. !

Thanks for your help!!.......... 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