微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 微波和射频技术 > 天线设计和射频技术 > Rtc program not working in stm32f407vgt6

Rtc program not working in stm32f407vgt6

时间:04-06 整理:3721RD 点击:
Hi there,

Good wishes.

I've been working on RTC MODULE in STM32F4 Microcontroller using MIKRO-C Compiler(from mikroelectronika). I've configured RTC based on STM product datasheet , but I'm not getting desired output from RTC data register.

Here is my code:

void main()
{
/*main clock */
RCC_AHB1ENR = 0xFF; //Enable clock for AHB1
RCC_APB2ENR=0xFFFFFFFF; // Enable clock for APB2
RCC_APB1ENR=0xFFFFFFFF; //Enable clock for APB1

/*CLOCK RTC SETTINGS*/
PWR_CRbits.DBP=1; // Allow access to BKP Domain
RCC_BDCRbits.BDRST=1; // Reset Backup Domain
RCC_BDCRbits.BDRST=0; //set Backup Domain
RCC_BDCRbits.LSEON=1; // Enable the LSE OSC
RCC_CSRbits.LSION=0 ; // Disable the LSI OSC
while(!RCC_BDCRbits.LSERDY); //Waiting for enabling rtc clock source
RCC_BDCRbits.RTCSEL0=0; // Select the RTC Clock Source as LSE
RCC_BDCRbits.RTCSEL1=1; // Select the RTC Clock Source as LSE
RCC_BDCRbits.RTCEN=1; // enable RTC Clock

/*RTC REGISTER CONFIGURATION */
RTC_TR=0x00000000;
RTC_DR=0x00000000; // reset time,date,min and hr
RTC_CR=0x00000000;
RTC_PRER=0x007F00FF; // SYNC_PRESCALE =0xFF; ASYNC_PRESCALE=0x7F;

/*GPIO*/
GPIOC_MODER=0x55555555; // GPIO C as a output pin
GPIOC_ODR=0; // Reset GPIO C
while(1)
{

GPIOC_ODR=RTC_DR; // Reading RTC Data to GPIOC
Delay_100ms(); // Delay
}// end of while

}// end of main


can anybody tell me what went wrong? Could you please guide me on how to solve this problem.

Any kind of feedback would be appreciated

Thanks in advance.
上一篇:Low Impedance Ground [hlp]
下一篇:最后一页

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top