2020-06-26 10:51 AM
Hello everybody,
i have a problem with the RTC Calib Out (1Hz) on PB2 and TimeStamp Input PC13 (Board: NUCLEO-L4R5ZI).
Calib Out on PB2
With the following code works the calib out pin fine.
hrtc.Instance = RTC;
hrtc.Init.HourFormat = RTC_HOURFORMAT_24;
hrtc.Init.AsynchPrediv = 127;
hrtc.Init.SynchPrediv = 255;
hrtc.Init.OutPut = RTC_OUTPUT_DISABLE;
hrtc.Init.OutPutRemap = RTC_OUTPUT_REMAP_POS1;
hrtc.Init.OutPutPolarity = RTC_OUTPUT_POLARITY_HIGH;
hrtc.Init.OutPutType = RTC_OUTPUT_TYPE_OPENDRAIN;
HAL_RTC_Init(&hrtc);
HAL_RTCEx_SetCalibrationOutPut(&hrtc, RTC_CALIBOUTPUT_1HZ);
HAL_StatusTypeDef HAL_RTCEx_SetCalibrationOutPut(RTC_HandleTypeDef *hrtc, uint32_t CalibOutput)
{
__HAL_LOCK(hrtc);
hrtc->State = HAL_RTC_STATE_BUSY;
__HAL_RTC_WRITEPROTECTION_DISABLE(hrtc);
hrtc->Instance->CR &= (uint32_t)~RTC_CR_COSEL; /* Clear flags before config */
hrtc->Instance->CR |= (uint32_t)CalibOutput; /* Configure the RTC_CR register */
__HAL_RTC_CALIBRATION_OUTPUT_ENABLE(hrtc); // ((hrtc)->Instance->CR |= ((0x1UL << (23U))))
__HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
hrtc->State = HAL_RTC_STATE_READY;
__HAL_UNLOCK(hrtc);
return HAL_OK;
}
TimeStamp Input on PC13
Is only only the TimeStamp function configured, then it works also as expected. Blue is a clock with e.g. 1 Hz and the red signal is a gpio which will be toggled by the TimeStamp callback function. It works also as expected.
hrtc.Instance = RTC;
hrtc.Init.HourFormat = RTC_HOURFORMAT_24;
hrtc.Init.AsynchPrediv = 127;
hrtc.Init.SynchPrediv = 255;
hrtc.Init.OutPut = RTC_OUTPUT_DISABLE;
hrtc.Init.OutPutRemap = RTC_OUTPUT_REMAP_POS1;
hrtc.Init.OutPutPolarity = RTC_OUTPUT_POLARITY_HIGH;
hrtc.Init.OutPutType = RTC_OUTPUT_TYPE_OPENDRAIN;
HAL_RTC_Init(&hrtc);
HAL_RTCEx_SetTimeStamp_IT(&hrtc, RTC_TIMESTAMPEDGE_RISING, RTC_TIMESTAMPPIN_DEFAULT); // default PC13
HAL_StatusTypeDef HAL_RTCEx_SetTimeStamp_IT(RTC_HandleTypeDef *hrtc, uint32_t TimeStampEdge, uint32_t RTC_TimeStampPin)
{
uint32_t tmpreg;
__HAL_LOCK(hrtc);
hrtc->State = HAL_RTC_STATE_BUSY;
/* Get the RTC_CR register and clear the bits to be configured */
tmpreg = (uint32_t)(hrtc->Instance->CR & (uint32_t)~(RTC_CR_TSEDGE | RTC_CR_TSE));
tmpreg |= TimeStampEdge;
/* Disable the write protection for RTC registers */
__HAL_RTC_WRITEPROTECTION_DISABLE(hrtc);
/* Configure the Time Stamp TSEDGE and Enable bits */
hrtc->Instance->CR = (uint32_t)tmpreg;
__HAL_RTC_TIMESTAMP_ENABLE(hrtc);
/* Enable IT timestamp */
__HAL_RTC_TIMESTAMP_ENABLE_IT(hrtc, RTC_IT_TS);
/* RTC timestamp Interrupt Configuration: EXTI configuration */
__HAL_RTC_TAMPER_TIMESTAMP_EXTI_ENABLE_IT();
__HAL_RTC_TAMPER_TIMESTAMP_EXTI_ENABLE_RISING_EDGE();
__HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
hrtc->State = HAL_RTC_STATE_READY;
__HAL_UNLOCK(hrtc);
return HAL_OK;
}
Both together (doesn't work)
If I try both together, the calib out will work, but I won't get any TimeStamp events anymore. The signal at the TS input has only a voltage of 1.4 volts. Only the COE and COSEL bits are changed by the pin calib out. What happens here?
hrtc.Instance = RTC;
hrtc.Init.HourFormat = RTC_HOURFORMAT_24;
hrtc.Init.AsynchPrediv = 127;
hrtc.Init.SynchPrediv = 255;
hrtc.Init.OutPut = RTC_OUTPUT_DISABLE;
hrtc.Init.OutPutRemap = RTC_OUTPUT_REMAP_POS1;
hrtc.Init.OutPutPolarity = RTC_OUTPUT_POLARITY_HIGH;
hrtc.Init.OutPutType = RTC_OUTPUT_TYPE_OPENDRAIN;
HAL_RTC_Init(&hrtc);
HAL_RTCEx_SetTimeStamp_IT(&hrtc, RTC_TIMESTAMPEDGE_RISING, RTC_TIMESTAMPPIN_DEFAULT); // default PC13
HAL_RTCEx_SetCalibrationOutPut(&hrtc, RTC_CALIBOUTPUT_1HZ);
Can someone explain what changes to PC13 when the COE bit is set to 1?
2020-07-03 05:10 AM
And what's in the RTC registers now?
JW
2020-07-03 06:32 AM
Same as in case 2
2020-07-03 06:51 AM
So, you set RTC registers as in case 2, and input signal is OK? And then when you change PC13 GPIO_MODER from the default Analog to In, the input signal suddenly changed amplitude, correct?
JW
2020-07-03 09:52 AM
Yes i set the RTC registers as in case 2.
The input signal is always a 1 Hz clock with amplitude 3.3 V.
The amplitude changes when COE bit set. If this bit isn't set, then the PC13 works as expected as normal gpio exti or as RTC_TS (see case 1). Always when the COE bit is set, the amplitude of PC13 is 1.4 V.
I guess, when the RTC COE bit is set, the PC13 gpio registers are ignored.
2020-07-05 05:04 AM
OK, so the bug is, that if RTC_CR.COE=1 and RTC_OR.RTC_OUT_RMP=1, PC13 is *not* controlled by GPIO as it should, and is turned to output.
@Vincent Onde , this appears to be a genuine hardware bug, can you please have a look at it.
JW
2020-07-05 06:03 AM
Few days ago while calibrating RTC I discovered exactly the same thing. When COE=1 and RTC_OUT_RMP=1 even with OSEL=00b, GPIO settings for PC13 are overriden and it is switched to output with value 0.
I can confirm this behavior on STM32L431CBT6 and STM32L433CCU6.
2020-07-05 06:17 AM
Thanks for confirming this.
JW
2020-07-06 07:23 AM
Hello @Community member,
Thanks for reporting this. I'll have it circulated internally.
Best regards,
Vincent
2020-07-06 02:02 PM
Thanks, Vincent.
Jan
2020-09-01 05:24 AM
Hello,
Sorry for the delay in getting back to you.
I confirm this issue and the team is currently working on updating the Errata sheets .
Best Regards,
Imen