Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

i2c with flowcode

Status
Not open for further replies.

andy001

New Member
I'm trying my best to muddle my way through microcontrollers and I'm stuck. I want to communicate with a RTC, and I'm trying to figure out how to control it using flowcode. Is anyone familiar with the program?

Should I use transmit byte to send information to the clock? Or maybe send byte transaction? The device address is 1101000, and it says the different registers are 00h through 07h. My main problem is I don't know what 00h or 01h really mean and how to address them using flowcode. The help file was (contrary to it's title) not that helpful.

Thanks in advance to anyone with any insight!
 
h means HEX, thus 00h is 0000 0000 binary and 07h is 0000 0111 in binary.

Conversion from binary to hex and back means separating the binary digits in groups of 4 and applying binary to hex conversion to each of the 4 binary digits.
FFh would be 1111 1111 binary. I added the spaces for clarity.
 
The device with an address of 11010000 is a DS1307. Binary 11010000 is 208 in decimal (128+64+16 as the one bits represent binary numbers 128,64,32,16,8,4,2,1). Binary 11010000 can also be written as 0d0h or 0xd0 which are hexidecimal representations of it. So, 00h to 07h are simply 0 to 7. Google for a good explanation of hexadecimal for more info.

If you look through the 1307 data sheet it explains what numbers to send and when to Acknowledge or not. Have a go and come back if (when) you get stuck. Note that in the diagrams an A is Acknowledge and an A with a bar above it means not Acknowledge.

Mike.
 
Thanks both of you. You can tell how new at this I am. I thought 00h was a hex number itself rather than the h just defining it as hex. Ill have more if (when) i get stuck, Im sure.
 
Last edited:
h means HEX, thus 00h is 0000 0000 binary and 07h is 0000 0111 in binary.

Conversion from binary to hex and back means separating the binary digits in groups of 4 and applying binary to hex conversion to each of the 4 binary digits.
FFh would be 1111 1111 binary. I added the spaces for clarity.

Thanks for the explaination of the conversion process. So any single hex digit is 1/2 a byte worth of information right?
 
Thanks for the explaination of the conversion process. So any single hex digit is 1/2 a byte worth of information right?

hi Andy,
The DS1307 uses 'packed BCD', this means the higher 4 bits of an 8bit BYTE represent a decimal number '0 thu 9' and its the same for the 4 lower bits of the byte, '0 thru 9'

So a packed BCD byte can represent 0,0 thru 9,9 decimal.
OK.?
 
Last edited:
Hi Eric,

Yeah, that helps to clarify quite a bit.

Would 0,0 in binary then be 00000000? And 1,1 = 00010001 thru to 9,9 = 10011001.
Similarly in decimal, 0,0 would be interperited as 0. With 1,1 = 17 and 9,9 = 153.

I'm playing with the code and I'll be able to run it on a microcontroller this coming weekend. Hopefully I'll get some good results in practice. I think the code will interperate the byte returned from the clock as an 8 bit decimal number and I may have to try a string function to break it into first and last four bits.
 
Last edited:
Hi Eric,

Yeah, that helps to clarify quite a bit.

Would 0,0 in binary then be 00000000? And 1,1 = 00010001 thru to 9,9 = 10011001.
Thats almost correct, but it wouldn't be Binary, but 'packed BCD'.
As Binary '00010001' would be '17 decimal' or '11h, hex'


Similarly in decimal, 0,0 would be interperited as 0. With 1,1 = 17 and 9,9 = 153.
See above explanation

I'm playing with the code and I'll be able to run it on a microcontroller this coming weekend. Hopefully I'll get some good results in practice. I think the code will interperate the byte returned from the clock as an 8 bit decimal number and I may have to try a string function to break it into first and last four bits.

hi,
The DS1307 also expects the data written [WRITE] to it be in 'packed BCD'.

Depending upon on how you are going to process the data you READ from the DS1307 it may be useful to create "Binary to packed BCD to Binary" subroutines to format the RTC data.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top