|
Hi Sattipandu,
I reviewed your code sequence and found that there are two steps which you need to include for working with RTC.
1. It is must to set the ‘w’ bit in the flag register before initiating a write to RTC register
2. You must send the complete write command which include RTC write opcode, address, data with CS low. You have toggled CS between your steps 3 and 4.
Please follow the below steps and modify your code accordingly.
Step1: Set the “WEN” bit in the status register. (You can read the status register and verify the "WEN" bit status- It must be set to “1” before going for further steps of writing)
CS_LOW
WREN =0x06
CS_HIGH
Step 2: Set the "w" bit (Bit 2) in the RTC flag register (0x00) before initiating write into any RTC register (You can read the flag register and verify the "w" bit status- It must be set to “1”)
CS_LOW
WRITE Cmd =0x12
Address = 0x00
data bytes = 0x02
CS_HIGH
Step 3: Once step 1 and step 2 are successful, the following Step 3 should be used to write a new value in the RTC time keeping registers.
CS_LOW
WRITE Cmd =0x12
Address = as desired
data bytes = as desired data byte/bytes (in bulk write mode)
CS_HIGH
Once you complete RTC register/s write cycle , you can read back and confirm whether the data written is updated correctly or not? Please note that after a successful RTC register write, you should clear the ‘w’ bit so that the RTC registers (second, minutes, hrs….) starts getting updated automatically.
Please let me know if you have any further clarification.
Shivendra Singh
Cypress Semiconductor
|