how does I2Cobj work when handeling a ds1624
darkxceed
Posts: 34
Hello people,
I am new to I2C with the propeller chip.
Now I want to read the temp of the ds1624(which is different than the ds1620).
The commandos have to be:
Start
%10010000
$AC
$00
Stop
Start
%10010000
$EE
Stop
Start
%10010000
$AA
Start
%10010001
RX··············· <receive temp reading 2 bytes long
Stop
There are ofcourse ACK after every byte that is send and·NACK after every byte that is received
How do I handle the I2Cobj.spin because I don't get it really.
I want to keep it as simple as those commando's, and no extra's like checking if there an error.
Best regards,
Bart Veenstra
I am new to I2C with the propeller chip.
Now I want to read the temp of the ds1624(which is different than the ds1620).
The commandos have to be:
Start
%10010000
$AC
$00
Stop
Start
%10010000
$EE
Stop
Start
%10010000
$AA
Start
%10010001
RX··············· <receive temp reading 2 bytes long
Stop
There are ofcourse ACK after every byte that is send and·NACK after every byte that is received
How do I handle the I2Cobj.spin because I don't get it really.
I want to keep it as simple as those commando's, and no extra's like checking if there an error.
Best regards,
Bart Veenstra
Comments
James
PUB i2cStop
PUB i2cStart
PUB i2cWrite(i2cData, i2cBits) : ackbit
PUB i2cRead(ackbit) : i2cData
But I dont know how to use it.
Should my code be like below
i2cObject.i2cStart
i2cObject.i2cWrite(%10010000, 8)
i2cObject.i2cWrite($AC, 8)
i2cObject.i2cWrite($00, 8)
i2cObject.i2cStop
if I want to send:
Start
%10010000
$AC
$00
Stop
to adres 4 for example.
Maybe some one help me a little bit, don't need much help.
You need to read the product datasheet, you seem to be missing some·steps from the communication.
The manual is here http://datasheets.maxim-ic.com/en/ds/DS1624.pdf
You really need to look at the DS1621 example as, from a brief look at the ds1624 datasheet, the two products protocols·should be nearly identitical.
James
~~Brian
try that. make sure you have pullups on your data and clock lines. it needs i2cobject.spin to be in the same folder (obviously).
good luck!
Start,%10010000,ACK,$AC,ACK,$00,ACK,Stop <==configuration register. 1shot
Start,%10010000,ACK,$EE,ACK,Stop <==Start convert.
Start,%10010000,ACK,$AA,ACK,Start,%10010001,ACK,Receivebyte,ACK,Receivebyte,NACK,Stop <==get 2 byte data
the last ACK and NACK must send from master to slave.
The ds1624 is connected to the prop with 2x 4k6 pull-up and 100Ohm resistor in serie to the prop output 28(SCL),29(SDA), the eeprom is also connected there for the propsoftware.
con
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000
deviceaddress = %10010000
obj
i2c : "i2cobject"
pub start (sda, scl)
i2c.start
i2c.init(sda, scl, FALSE)
pub Config : success························································· 'sends first command
success := i2c.writelocation (deviceaddress, $AC, $00, 8, 8)·····'sends device's address, then the register, then the data. 8 address bits, 8 data bits
return success
pub Convert····································································· 'use if no data is to be sent to $EE
i2c.i2cstart······································································ 'starts i2c
i2c.i2cwrite (deviceaddress, 8)············································· 'sends device address
i2c.i2cwrite ($EE, 8)··························································· 'sends convert prot.
i2c.i2cstop········································································'stops i2c
pub read1 : readdata
readdata := i2c.readlocation (deviceaddress, $AA, 8, 16)······· ··'reads 2 bytes from register $AA (8 address bits, 2 bytes at 8 bits each = 16 data bits)
return readdata
Post Edited (darkxceed) : 1/10/2007 7:05:58 AM GMT
But I don't know how to get the second byte of·temperatuur.
This byte contains the precision values lower than 1degree.
pub·read1·:·readdata
··readdata·:=·i2c.readlocation·(deviceaddress,·$AA,·8,·16)·········'reads·2·bytes·from·register·$AA·(8·address·bits,·2·bytes·at·8·bits·each·=·16·data·bits)
··return·readdata
In the upper syntax I set it to 16 to read 2 bytes but the second byte stays %00000000
If I have the second byte I than can manipulate is because only the last 5 bits contains a·measure value.
In total the tempreading is 13bits long.
If I try it in low level code I maybe understand it more.