Код: void RTCC_Unlock(){ asm volatile("disi #5"); asm volatile("mov #0x55, w7"); // write 0x55 and 0xAA to asm volatile("mov w7, _NVMKEY"); // NVMKEY to disable asm volatile("mov #0xAA, w8"); // write protection asm volatile("mov w8, _NVMKEY"); asm volatile("bset _RCFGCAL, #13"); // set the RTCWREN bit asm volatile("nop"); asm volatile("nop"); }
void RTCC_Init(void){ __builtin_write_OSCCONL(2); RCFGCAL = 0x0000; RTCC_Unlock(); RCFGCALbits.RTCEN = 1; }
|