I've been working with the HMC5883L electronic compass but was having problems with the HI2C NOT turning on when power was applied. This occured about 50% of the time. At first I thought it was a problem with the HMC5883L chip.
Today I removed the HMC5883L chip from the circuit, deleted the code that used the HMC5883L, and connected pull up resistors to the PIC's HI2C SDL and SDA lines. The problem was still there! About half the time the PIC did not produce the Clock or Data signals when power was applied. Only the +5 volts from the pull up resistors appeared at the PIC's SDL and SDA ports.
Below is the code I am uising. I would expect that the program to print "DoAgain", "START", and then get stuck in an endless loop printing "InLOOP" on the LCD. When it fails to turn on it prints "DoAgain" but nothing else, i.e. it hangs up at the 'HI2CStart' command.
You are doing nothing incorrect. In the next release there is a new hardware i2c driver and the release includes a fully test compass driver. There is a low level issue.
Send me an Personal Message and I will provide you the latest build. It would be good to get you to test the release. You need release candidate 013. Earlier versions will not fix your issue.
Anobium
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I've been working with the HMC5883L electronic compass but was having problems with the HI2C NOT turning on when power was applied. This occured about 50% of the time. At first I thought it was a problem with the HMC5883L chip.
Today I removed the HMC5883L chip from the circuit, deleted the code that used the HMC5883L, and connected pull up resistors to the PIC's HI2C SDL and SDA lines. The problem was still there! About half the time the PIC did not produce the Clock or Data signals when power was applied. Only the +5 volts from the pull up resistors appeared at the PIC's SDL and SDA ports.
Below is the code I am uising. I would expect that the program to print "DoAgain", "START", and then get stuck in an endless loop printing "InLOOP" on the LCD. When it fails to turn on it prints "DoAgain" but nothing else, i.e. it hangs up at the 'HI2CStart' command.
What am I doing wrong?
;Chip Settings
#chip 18F4550,48
#config PLLDIV=1, CPUDIV=OSC1_PLL2, OSC=HSPLL_HS, MCLRE=ON, LVP=OFF
;Defines (Constants)
#define LCD_IO 2
#define LCD_CB PORTC.1
#define LCD_DB PORTC.2
#define HI2C_BAUD_RATE 100
#define HI2C_DATA PORTB.0
#define HI2C_CLOCK PORTB.1
#define HMC5883L_WRITE_address 60 ;0x3C
'
Dir HI2C_DATA in
Dir HI2C_CLOCK in
'
HI2CMode Master
'
locate 0, 0
print "Test_I2C"
wait 1 s
cls
wait 500 ms
'
DoAgain:
locate 0, 0
print "DoAgain"
'
HI2CSTART
locate 1, 0
print "START"
'
Do
HI2CReStart
HI2CSend HMC5883L_WRITE_address'inidcate a write
locate 1, 5
print "InLOOP"
loop While HI2CAckPollState
HI2CSTOP
'
Goto DoAgain
You are doing nothing incorrect. In the next release there is a new hardware i2c driver and the release includes a fully test compass driver. There is a low level issue.
Send me an Personal Message and I will provide you the latest build. It would be good to get you to test the release. You need release candidate 013. Earlier versions will not fix your issue.
Anobium
Sorry, I should make it clear. You have hit a known issue that is resolved in the next release.
0.13 fixed it!
Thanks.
Wonderful news.
I messed up the code in the v0.94 release for HWI2C 18f support! I admit it! :-)
Evan where do I find release 13? Thanks, Ed.
I just sent you a PM with the lastest build version and location.