M41T81 I2C RTC, Help with data format needed

08 Jan 2011

Hi

Can anyone help me with M41T81 I2c RTC as fitted to a small module (BV4237) from byvac.co.uk.

I have it working but the data is strange because some of the bytes are arranged with 10's of units in the top 4 bits and the units are at the bottom 4 bits.

The result is it counts up to 9 then jumps to 16 and so on.

If you look at the register map in the datasheet link below you can see my problem.

http://www.st.com/stonline/products/literature/ds/7529/m41t81.pdf

Any ideas how to format this data would be very helpful.

I know its going to be simple but I have got a bit stuck.

Mbed has its own RTC but this module comes with a-d converters and temp sensor in one small unit.

Many thanks

Paul

 

 

08 Jan 2011

A quick look in the datasheet reveals that data is coded in BCD (see chapter 3 at the beginning), i.e. 4 bits for the first DECIMAL digit and 4 bits for the SECOND decimal digit.

so 00(decimal) is repesented as 0000 0000 (binary) 01 is represented as 0000 0001 . . 10 is repesented as 0001 0000 and so on. the series of 0/1 above is spit the 4 bit groups for easier reading

Simply do some thing like

value = (10 * (data >> 4)) + (data & 15)

where data is the information read from the RTC and value is the binary representation of the value you are looking for

Louis

09 Jan 2011

Thanks Louis

Works perfectly!!