AnsweredAssumed Answered

STM32f103 RTC Write Protection

Question asked by frun54 on Dec 12, 2015
Hello,
i try to get my program work, but im unable to modify the rtc registers. I know that there is a Write Protection, which you can unable by polling the RTOFF Bit and then set the CNF Bit. It doesnt work. I used the CubeMX Code, than my STM std. Lib and than i try it manually by the Debugger, there were no change in the registers. The seconds of the rtc run correct.

Cube MX
01.RTC_TimeTypeDef sTime;
02.  RTC_DateTypeDef DateToUpdate;
03.  RTC_AlarmTypeDef sAlarm;
04. 
05.    /**Initialize RTC and set the Time and Date
06.    */
07.  hrtc.Instance = RTC;
08.  hrtc.Init.AsynchPrediv = RTC_AUTO_1_SECOND;
09.  hrtc.Init.OutPut = RTC_OUTPUTSOURCE_ALARM;
10.  hrtc.DateToUpdate.WeekDay = RTC_WEEKDAY_MONDAY;
11.  hrtc.DateToUpdate.Month = RTC_MONTH_JANUARY;
12.  hrtc.DateToUpdate.Date = 1;
13.  hrtc.DateToUpdate.Year = 0;
14.  HAL_RTC_Init(&hrtc);
15. 
16.  sTime.Hours = 0;
17.  sTime.Minutes = 0;
18.  sTime.Seconds = 0;
19.  HAL_RTC_SetTime(&hrtc, &sTime, FORMAT_BIN);
20. 
21.  HAL_RTC_SetDate(&hrtc, &DateToUpdate, FORMAT_BIN);
22. 
23.    /**Enable the Alarm A
24.    */
25.  sAlarm.AlarmTime.Hours = 1;
26.  sAlarm.AlarmTime.Minutes = 2;
27.  sAlarm.AlarmTime.Seconds = 3;
28.  sAlarm.Alarm = RTC_ALARM_A;
29.  HAL_RTC_SetAlarm_IT(&hrtc, &sAlarm, FORMAT_BIN);

My onwn code:

set_alarm
01.while((RTC->CRL & RTC_FLAG_RSF) == 0) // wait for last task
02.{} 
03.  
04.RTC->CRL |= RTC_CRL_CNF; //enter configuration mode
05.  
06.RTC->ALRH = data>>16;
07.RTC->ALRL = data;
08.  
09.RTC->CRL &= ~RTC_CRL_CNF; //exit configuration mode
10.  
11.while((RTC->CRL & RTC_FLAG_RTOFF) == 0)   // wait for last task
12.{} 


the status after MX_RTC_Init()
CRH 0x02
CHL 0x38

PRLH 0x00
PRLL 0x00

DIVH 0x00
DIVL 0x7A28

CNTH 0x00
CNTL 0x00

ALRH 0x00
ALRL 0x00


Outcomes