2012-07-18 01:11 PM
Hi I am trying to write date and time to the RTC which I later will read.
But something in my RTC configuration doesn’t work and reading the values in debug mode shows that the RTC registers that I try to set never get the new values.
Here is my code:
void Set_RTC(){/* Enable the PWR clock */RCC_APB1ENR.PWREN = 1;/* Allow access to RTC */PWR_CR.DBP = 1;/* LSE used as RTC source clock */RCC_BDCR.LSEON = 1; //External low-speed oscillator enable /* Wait till LSE is ready */while(RCC_BDCR.LSERDY != 1){}/* Select the RTC Clock Source to LSE */RCC_BDCR.F8 = 1;RCC_BDCR.F9 = 0;/* Wait for RTC APB registers synchronisation */while(RTC_ISR.RSF != 1){}RCC_BDCR.RTCEN = 1; //Enable RTC clock <<<RTC_WPR = 0xCA; //unlock write protectionRTC_WPR = 0x53; //unlock write protection/* Configure the RTC prescaler */RTC_PRER = 0x7f00ff; // set SynchPrediv to FF and AsynchPrediv to 7F//RCC_BDCR.RTCEN = 1; //Enable RTC clock <<<RTC_ISR.INIT = 1; //enter initialization mode <<<<<< THIS REGISTER NEVER GETS THE NEW VALUEwhile(RTC_ISR.INITF != 1) //poll INITF{}/* Configure the RTC PRER */ RTC_PRER = 0x7F; RTC_PRER |= 0xFF << 16; RTC_TR = 0x123500; //setting time to 12.35.00 RTC_DR = 0x126718; // set date to 2012-07-18 RTC_CR.F6 = 0; // set FMT 24H format RTC_ISR.INIT = 0; //exit initialization mode /* Enable the write protection for RTC registers */ RTC_WPR = 0xFF;}I am using a STM32F407 @ 140Mz internal HSI oscillator.
What am I doing wrong?
2015-09-30 06:11 AM
At present time it is not possible to download because probably the CPU is broken
With power on it heats up2015-09-30 07:28 AM
Related to the code you downloaded, or something else you were doing to the board?
Do you have a schematic for what you've built? You can redact anything that's sensitive, but let's start with the STM32 and all the components and supplies connected to it.Do you have any high loading on PC13?2015-10-06 09:37 AM