i have place compass sensor HMC6352 in my project..
the problem is i don't know the sensor is still ok or not bcause while solder the 4 pin the temperature is about 250-300 Celsius..then when i download the program and the result is nothing happen..
my program:
- CODE: SELECT_ALL_CODE
#include <16F877A.H>
#fuses HS, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock=20000000)
#use i2c(Master, sda=PIN_C4, scl=PIN_C3, FORCE_HW)
#include <lcd_module.c>
#define HMC6352_I2C_WRITE_ADDRESS 0x42
#define HMC6352_I2C_READ_ADDRESS 0x43
#define HMC6352_GET_DATA_COMMAND 0x41
int16 heading;
void setup()
{
lcd_init();
}
int16 HMC6352_read_heading(void);
void clearLCD();
//===================================
void main()
{
setup();
clearLCD();
while(1)
{
//heading = HMC6352_read_heading();
//heading=heading/100;
//lcd_gotoxy(1,1);
printf(lcd_putc, "heading");
lcd_gotoxy(1,2);
printf(lcd_putc,"%lu", heading);
delay_ms(1000); }
}
//==================================
int16 HMC6352_read_heading(void)
{
int8 lsb;
int8 msb;
i2c_start();
i2c_write(HMC6352_I2C_WRITE_ADDRESS);
i2c_write(HMC6352_GET_DATA_COMMAND);
i2c_stop();
delay_ms(7);
i2c_start();
i2c_write(HMC6352_I2C_READ_ADDRESS);
msb = i2c_read();
lsb = i2c_read(0);
i2c_stop();
return((int16)lsb | ((int16)msb << 8 )) ;
}
//==================================================
void clearLCD()
{
printf(lcd_putc, "\f");
delay_ms(100);
}
i don't know neither the sensor or program is not function..