mmilinkovic
Joined: 15 Jul 2010 Posts: 1
|
i2c_read function dsPIC30F6014 - now works |
Posted: Thu Jul 15, 2010 1:58 am |
|
|
Hi!
I had a problem working with function i2c_read (on dsPIC30F6014) while i2c_write was working fine... dsPIC was a master and FRAM FM31278 was a slave.
So, I solved the problem and here is the solution if anyone needs it.
To configure dsPIC I2C module I used this line:
Code: |
#use i2c(master, sda = PIN_G3, scl = PIN_G2, force_hw)
|
But, this way or any other way, as far as I know, using "use" directive you cannot disable General call option of I2C module. Anytime dsPIC sent byte 0x00 the RBF flag was set and next time the I2COV flag too. This happens because of the fact that anytime the byte 0x00 is sent this is seen as General call by I2C module. It doesn't matter if the byte was sent following the i2c_start call or later.
When this occurs i2c_read function doesn't work (it returns 0 or -1).
So, I did the following:
Code: |
#word I2CCON = 0x0206
I2CCON &= 0x0xFF7F; // General call disabled
|
Greetings,
Milan |
|