TDK29
Joined: 14 Jun 2010 Posts: 2
|
18F67J50 with HMC6352 |
Posted: Wed Apr 11, 2012 1:23 pm |
|
|
Hi,
I hope anyone here can help me.
I try to get the HMC6352 working with my PIC.
Routine:
start
send slave write adress (0x42)
send slave adress to read (0x00)
delay
start
send slave read adress (0x43)
read register
stop
The only answer i will get ist 0xFF.
I also checked the communication with an oscilloscope, the voltage level is within the borders. 10k PullUps installed (the rising edge is a little bit sloped, lower pull-ups would resolve this, but still the same response)
Here's the code:
Code: | #include <18F67J50.h>
#fuses INTRC
#use delay(crystal=8000000)
#use rs232(baud=57600,uart2, parity=n, bits=8, stream=rs2)
#use rs232(baud=9600, uart1, parity=n, bits=8, stream=rs1)
#use i2c(Master, scl=pin_c3, sda=pin_c4, FORCE_HW)
int data1, data2;
//int16 data3;
void read_hmc()
{
i2c_start();
i2c_write(0x42);
i2c_write(0x00);
delay_ms(10);
i2c_write(0x43);
data1 = i2c_read();
i2c_stop();
}
void main()
{
setup_oscillator(OSC_8MHZ);
while(1)
{
read_hmc();
fprintf(rs2, "Test %u", data1);
delay_ms(200);
}
}
|
Thanks
Best regards
TDK29[/code] |
|