stm32f103vet6 LSE question - Page 1
Forum section: electronics / general

author: Karamel
author_rank: Regular Contributor
timestamp: August 29, 2015, 12:02:36 pm
content: Hi everyone,I am trying to active internal RTC unit of stm32f103vet6 via LSE. However, LSE osc is not able to open. I am using mikroc but It doesn't matter which platform we are using.Why can't I work it? I am publishing my codes.Code:char a;char ss2;char ss1;char dk2;char dk1;char sn2;char sn1;char text = "00:00:00";char tempstr;unsigned long time;void main() {GPIO_Digital_Output(&GPIOB_BASE, _GPIO_PINMASK_8);UART3_Init(9600); Delay_ms(100);// Init power and clock for RTCRCC_APB1ENR.BKPEN = 1; // Backup interface clock enableRCC_APB1ENR.PWREN = 1; // Power interface clock enablePWR_CR.DBP = 1; // Schreibschutz der BackupDomainRegister abschaltenRCC_BDCR.RTCSEL0 = 1; // 01: LSE oscillator clock used as RTCRCC_BDCR.RTCSEL1 = 0; // 01: LSE oscillator clock used as RTCRCC_BDCR.RTCEN = 1; // RTC clock enableRCC_BDCR.LSEON = 1; // External 32 kHz oscillator ONwhile(RCC_BDCR.LSERDY == 0); // microcontroller can not pass this code!RCC_BDCR.BDRST = 1;PWR_CR.DBP = 0; // Schreibschutz der BackupDomainRegister einschalten// RTC-Register sycned?RTC_CRL.RSF = 0;while (RTC_CRL.RSF == 0);// Config RTCwhile (RTC_CRL.RTOFF == 0);RTC_CRL.CNF = 1; // Configmode onRTC_PRLL = 0x7FFF; // RTC-clock-prescalerRTC_CRL.CNF = 0; // Configmode offwhile (RTC_CRL.RTOFF == 0);while(1){// Burada RTC yi basacagiztime = RTC_CNTL;a = (time % 60);sn2 = (a / 10) + 48;sn1 = (a % 10) + 48;a = ((time/60) % 60);dk2 = (a / 10) + 48;dk1 = (a % 10) + 48;a = ((time/60/60) % 60);ss2 = (a / 10) + 48;ss1 = (a % 10) + 48;UART3_Write(ss2); Delay_ms(10); UART3_Write(ss1); Delay_ms(10); UART3_Write(':'); Delay_ms(10);UART3_Write(dk2); Delay_ms(10); UART3_Write(dk1); Delay_ms(10); UART3_Write(':'); Delay_ms(10);UART3_Write(sn2); Delay_ms(10); UART3_Write(sn1); Delay_ms(10); UART3_Write(' '); Delay_ms(10); UART3_Write(' '); Delay_ms(10); UART3_Write(' ');GPIOB_ODR.F8 = 1; Delay_ms(460); GPIOB_ODR.F8 = 0; Delay_ms(460);}}as you can see, microcontroller can not pass this codewhile(RCC_BDCR.LSERDY == 0);because, it never become ready. I am working with simple pcb. I can work with HSE and I have chaged 32.768khz crystall twice. I checked it. all connections are okay but why can not open it?Best Regards,Karamel

author: Karamel
author_rank: Regular Contributor
timestamp: August 29, 2015, 12:05:09 pm
content: also, my microcontroller is working with HSE - 72 mhz when I am trying it.

author: HackedFridgeMagnet
author_rank: Super Contributor
timestamp: August 29, 2015, 03:50:55 pm
content: Your Low speed External oscillator is not oscillating.Possibly a hardware problem. Soldering problem, capacitance problem.OrHave you initialised everything you need to.Have a look at somebody elses RTC code, you may need to set a register or run some init code that does the same.I'm guessing thatQuoteis likeQuote

author: plex
author_rank: Newbie
timestamp: August 30, 2015, 09:06:32 am
content: I have not used the exact processor but in the STM32F4 there is a special unlock sequence after PWR_CR.DBP = 1; because the micro is probably in back up domain reset state.This is:RTC_WPR = 0xCA; //unlock write protectionRTC_WPR = 0x53; //unlock write protectionOnly after that can you change the clock source.Check the RTC initialization and configuration section of your processor reference manual very carefully.I hope this helps.

author: Karamel
author_rank: Regular Contributor
timestamp: August 30, 2015, 10:11:52 am
content: I have to ask one question, before I solve this problem.I know that, if stm32 m3 microcontrollers run in overclock, they can be broken unit of osc.I have broken one microprocessor like that. (HSE unit has broken) Therefore, I have to ask that, you can see my clock configuration bellow. Is it true? or Is there any overclock for any units?