2013-10-31 07:08 AM
Hi everybody,
I'm using a STM32 L152CB microcontroller with external clock. Initially I used it without USB and the RTC_SetTime worked. Since I configured the USB, the function (RTC_SetTime) doesn't work and my RTC_TimeTypeDef struct is always to 0 for each parameters (day, month, etc..) The micro's frequency is 16Mhz and the USB's clock is 48Mhz. Have you suggestions? Thanks! #rtc #clock #usb2013-11-01 04:16 AM
Check your interrupt set up.
You mentioned the RTC is an external device - does it use IRQs?? The USB code relies heavily on IRQs, this may be interfering with the RTC code.2013-11-01 05:37 AM
Is the function ''RTC_SetTime'' reached or the execution is stuck somewhere before?
Try to check this. -Mayla-To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2013-11-01 06:45 AM
I'm not entirely convinced there is a conflict between the RTC and USB.
Perhaps you can modify a VCP or MSC example to demonstrate this?2014-10-13 12:44 AM
I also encountered this problem. It's stuck at RTC_EnterInitMode, waiting for RTC_ISR_INITF flag to be set. It succeeds before USB_Start, whereas fails after it.
2014-10-13 01:13 AM
When stuck, read out and post the content of RTC_ISR and RCC_CSR registers.
JW2014-10-13 01:32 AM
In STM32L1XX_StdPeriph_Lib_V1.2.0, there is no RCC_CSR, do you mean RCC_CR?
RCC_ISR: 0x00000234 (I also saw 0x0000003F before), RCC_CR: 0x00007340. This stuck occurs right after the following code: /*** Set interrupt mask ***/ wInterrupt_Mask = CNTR_RESETM | CNTR_SUSPM | CNTR_WKUPM; _SetCNTR(wInterrupt_Mask); Regards,2014-10-13 01:54 AM
> In STM32L1XX_StdPeriph_Lib_V1.2.0, there is no RCC_CSR, do you mean RCC_CR?
Who cares about the ''library''? See RM0038 ch.5.3.14.>This stuck occurs right after the following code:
> >/*** Set interrupt mask ***/ > wInterrupt_Mask = CNTR_RESETM | CNTR_SUSPM | CNTR_WKUPM; > _SetCNTR(wInterrupt_Mask); I have no idea, what is _SetCNTR(). Before, you told us that the stuck occurs at waiting for RTC_ISR.INITF. Show us the real code. JW2014-10-13 02:10 AM
Sorry, I typed RCC->CSR as RTC->CSR and got no result.
RTC->ISR: 0x00000234 RCC->CSR: 0x1E410300. Code: ErrorStatus RTC_EnterInitMode(void) { __IO uint32_t initcounter = 0x00; ErrorStatus status = ERROR; uint32_t initstatus = 0x00; /* Check if the Initialization mode is set */ if ((RTC->ISR & RTC_ISR_INITF) == (uint32_t)RESET) { /* Set the Initialization mode */ RTC->ISR = (uint32_t)RTC_INIT_MASK; /* Wait till RTC is in INIT state and if Time out is reached exit */ do { initstatus = RTC->ISR & RTC_ISR_INITF; initcounter++; } while((initcounter != INITMODE_TIMEOUT) && (initstatus == 0x00)); if ((RTC->ISR & RTC_ISR_INITF) != RESET) { status = SUCCESS; } else { status = ERROR; } } else { status = SUCCESS; } return (status); } INITMODE_TIMEOUT = 0x2000 Thanks.2014-10-13 02:51 AM
About _SetCNTR:
#define RegBase (0x40005C00L) /* USB_IP Peripheral Registers base address */ /* Control register */ #define CNTR ((__IO unsigned *)(RegBase + 0x40)) #define _SetCNTR(wRegValue) (*CNTR = (uint16_t)wRegValue) this function operates USB_CNTR register.