black_nickle
Joined: 15 Jul 2008 Posts: 2
|
No temperature output on RS232 |
Posted: Wed Jul 16, 2008 2:15 am |
|
|
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);
} |
|