Shop OBEX P1 Docs P2 Docs Learn Events
DS1302 WriteRam — Parallax Forums

DS1302 WriteRam

hmlittle59hmlittle59 Posts: 404
edited 2008-12-10 05:10 in General Discussion
Hello All,

I want to be sure about what I doing here. Do I need to "CLEAR" the write protect Bit when writing DATA to the RAM location? The documentation does not really say unless I just missed it. I tried it in my test program and then removed it and it still worked, so I'm going to assume its not needed. thanks.

SET Clock time:
1) Clear Write Protect
2) Set time
3) Set Write Protect

WriteRAM:

1) Set up location
2) Write data
3) done

no Clear or set of any Bits

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
I HAVE LEARN SO MUCH...BUT STILL KNOW SO LITTLE!!!

hmlittle59

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2008-12-09 23:42
    As per the documentation...

    Bit 7 of the control register is the write protect bit. The
    first seven bits (bits 0 – 6) are forced to zero and will
    always read a zero when read. Before any write operation
    to the clock or RAM, bit 7 must be zero. When high,
    the write protect bit prevents a write operation to any
    other register. The initial power on state is not defined.
    Therefore the WP bit should be cleared before attempting
    to write to the device.

    In my own applications I clear it before doing writes and set it after, just in case the power gets cut suddenly and things get into a weird state.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Engineering
  • hmlittle59hmlittle59 Posts: 404
    edited 2008-12-10 00:48
    Thanks Chris,

    I'll have to put it back in my code. Don't know why it was working without it unless it was never (SET) from the first time during my testing.



    thanks again

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I HAVE LEARN SO MUCH...BUT STILL KNOW SO LITTLE!!!

    hmlittle59
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2008-12-10 05:10
    If you don't enable write protection it wouldn't normally be on.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Engineering
Sign In or Register to comment.