Hi All
Below some results of trying to write 7 bytes at once as required by docs.
Before Program dump.
Where did all these values after 0x6 come from ?
0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
00: 21 42 89 04 22 14 35 0a 05 10 07 20 00 00 00 84 !B??"?5???? ...?
10: 80 00 00 39 90 03 08 07 20 20 00 00 00 00 00 00 ?..9???? ......
Start of Program to write Date/Time
-----i2cSetTime-----
Time wDay: Date
2:40:10 3: 8-7-20
BCD
2:64:10 3 8-7-32
Init Result = 0
Open Handle = 4
Buffer before write;
00000010 Secs ;2
01000000 Mins ;40
10010000 Hrs ;144
00000011 dWeek ;3
00001000 Day ;8
00000111 Mnth ;7
00100000 Year ;20
Result of Time Write = 7
Buffer after write;
00000010 Secs ;2
01000000 Mins ;40
10010000 Hrs ;144
00000011 Week ;3
00001000 Day ;8
00000111 Mnth ;7
00100000 Year ;20
Close Result = 0
End of Program dump.
00: 28 42 00 00 03 08 07 20 05 10 07 20 00 00 00 84 (B..??? ??? ...?
10: 80 00 00 39 90 03 08 07 20 20 00 00 00 00 00 00 ?..9???? ......
Result of Time write shows 7, which I assume is 7 bytes written.
BUT, look what happened in the dump after write.
28 secs should be no more then 4 or 5, so it incremented from before (21)
42 Mins has not changed, should be 40.
00 Hrs should be 144 (1001 0000) 10 o’clock.
After that it looks like the fields have shifted to the right by 1 byte.
So now I clear the bytes from 0x11 to 0x19 manually and from 0x07 to 0x0e,
then run the program again.
`
Dump before write
00: 12 05 01 00 03 08 07 00 00 00 00 00 00 00 00 84 ???.???........?
10: 80 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ?...............
Program prints same data here as shown above.
Result of Time Write = -1
Buffer after write;
01010011 Secs ;53
00000010 Mins ;2
10010001 Hrs ;145
00000011 Week ;3
00001000 Day ;8
00000111 Mnth ;7
00100000 Year ;20
Close Result = 0
End of Program
Buffer after write (even though an error -1 was reported.
0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
00: 19 05 01 00 03 08 07 00 00 00 00 00 00 00 00 84 ???.???........?
10: 80 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ?...............
I don’t know if the fault lies with the iobb library command
.Result = i2c_write(.Handle, pBuffer, .Length)
or with the SD2405
Regards