I2C from PBP3 to Swordfish (no EEprom)
Posted: Mon Apr 24, 2017 11:59 am
For many years (2001) I used PicBasicPro and until yesterday I used PBP3 which was perfect for my projects. Now I've been to Swordfish and I'm converting PBP3 programs into Swordfish
Swordfish is more powerful and more suitable for my new exegesis, in mariculture math is very interesting. Unfortunately I have encountered some obstacles to the use of I2C libraries for now.
Read data in to device from the Microchip ADC MCP3421, by I3C bus:
a) Old PBP3 instruction code that works perfectly
I2Cread sda, scl, $D5, [B3,B2,B1,B0]
b) New code education in Swordfish:
Dim B0, B1, B2, B3 As Byte
I2C.Start
I2C.WriteByte($D5)
B3 = I2C.ReadByte
I2C.Acknowledge(I2C_NOT_ACKNOWLEDGE)
B2 = I2C.ReadByte
I2C.Acknowledge(I2C_NOT_ACKNOWLEDGE)
B1 = I2C.ReadByte
I2C.Acknowledge(I2C_NOT_ACKNOWLEDGE)
B0 = I2C.ReadByte
I2C.Acknowledge(I2C_NOT_ACKNOWLEDGE)
I2C.Stop
It's correct?
Thanks
Umberto
Swordfish is more powerful and more suitable for my new exegesis, in mariculture math is very interesting. Unfortunately I have encountered some obstacles to the use of I2C libraries for now.
Read data in to device from the Microchip ADC MCP3421, by I3C bus:
a) Old PBP3 instruction code that works perfectly
I2Cread sda, scl, $D5, [B3,B2,B1,B0]
b) New code education in Swordfish:
Dim B0, B1, B2, B3 As Byte
I2C.Start
I2C.WriteByte($D5)
B3 = I2C.ReadByte
I2C.Acknowledge(I2C_NOT_ACKNOWLEDGE)
B2 = I2C.ReadByte
I2C.Acknowledge(I2C_NOT_ACKNOWLEDGE)
B1 = I2C.ReadByte
I2C.Acknowledge(I2C_NOT_ACKNOWLEDGE)
B0 = I2C.ReadByte
I2C.Acknowledge(I2C_NOT_ACKNOWLEDGE)
I2C.Stop
It's correct?
Thanks
Umberto