Работает на LPC1769 и LPC2387: void rtc_init( void ) { /// Enable power for RTC PCONP_bit.PCRTC = 1; // CTC reset and select RTC clock from 32 Khz.oscillator #if __CORE__ < 7 if(LPC_RTC->CCR != 0x11) LPC_RTC->CCR = 0x12;
#else // If RTC is stopped, clear STOP bit. if ( LPC_RTC->RTC_AUX & (0x1<<4) ) { LPC_RTC->RTC_AUX |= (0x1<<4); LPC_RTC->CCR = 0x12; } #endif // Clear RTC interrupt register LPC_RTC->ILR = 0xFF; // Dasable all the alrams. LPC_RTC->AMR = 0xFF; // Enable only second count interrupt. LPC_RTC->CIIR = 0x01; // Disable all subsecond interrupts. #if __CORE__ < 7 // Enable RTC LPC_RTC->CCR = 0x11; #else LPC_RTC->CALIBRATION = 0; LPC_RTC->CCR = 0x11; #endif rtc_read(0); }
|