Using RTC on Arduino Due

Hello Friends, I am trying to access the on chip RTC on arduino due. I am using ASF to achieve this task. I am able to successfully read and write the time keeper registers but when I reset the chip the time also gets reset. I know we have to connect a backup battery on the controller pins so that the rtc is working and I had connected a 3V battery between the VDDBU and GND pin so that my rtc is not erased, but still it gets reset when I remove the power. What could be the problem ? Did I connect the battery to wrong pins?

AFAIK you just connect the battery to VDDBU, but I've not done it myself.

when I reset the chip the time also gets reset

Which reset are you using? IIRC the standard reset (NRSTB pin) does clear everything, you need to use the NRST pin to preserve the backup registers and RTC.

BTW, NRST is not connected on the Due, a shortcoming of the design I think.