Jinzpaul4u
Full Member level 4
- Joined
- Feb 1, 2012
- Messages
- 231
- Helped
- 59
- Reputation
- 118
- Reaction score
- 60
- Trophy points
- 1,328
- Location
- India
- Activity points
- 2,822
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.
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.