Re: Осваиваем PIC24
'************************************************* *****************************
' инициализация the RTC on a PIC24 microcontroller
'************************************************* *****************************
sub procedure PIC24_RTC_Init ()
dim tempASM as word
tempASM = OSCCON ' Only for linker to include the register
' Unlock the OSCCON register and then enable SOSC to enable the 32.xxxkHz
' crystal for the RTC
asm
disi #7
mov OSCCON, W1
mov.b #0x02, W0
mov.b #0x46, W2
mov.b #0x57, W3
mov.b W2, [W1]
mov.b W3, [W1]
mov.b W0, [W1]
end asm
tempASM = NVMKEY ' Only for linker to include the register
tempASM = RCFGCAL ' Only for linker to include the register
RCFGCAL = 0x0000
' Unlock the RCFGCAL register and enable the RTC
asm
PUSH W12
DISI #9
MOV #0x55, W12
MOV W12, NVMKEY
MOV #0xAA, W12
MOV W12, NVMKEY
BSET RCFGCAL, #13
NOP
NOP
BSET RCFGCAL, #15
POP W12
end asm
End sub
типа вот так?
|