Bug fix in RTC & BKP initialization

This commit is contained in:
Alexey Bazlaev 2023-03-06 17:34:00 +07:00
parent a39a483b53
commit d16d60fd14
3 changed files with 267 additions and 422 deletions

File diff suppressed because one or more lines are too long

View File

@ -153,56 +153,7 @@
<Name>UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0GD32F10x_CL -FS08000000 -FL040000 -FP0($$Device:GD32F107VC$Flash\GD32F10x_CL.FLM))</Name>
</SetRegEntry>
</TargetDriverDllRegistry>
<Breakpoint>
<Bp>
<Number>0</Number>
<Type>0</Type>
<LineNumber>603</LineNumber>
<EnabledFlag>1</EnabledFlag>
<Address>0</Address>
<ByteObject>0</ByteObject>
<HtxType>0</HtxType>
<ManyObjects>0</ManyObjects>
<SizeOfObject>0</SizeOfObject>
<BreakByAccess>0</BreakByAccess>
<BreakIfRCount>0</BreakIfRCount>
<Filename>.\FreeRTOS\source\portable\NetworkInterface\board_family\NetworkInterface.c</Filename>
<ExecCommand></ExecCommand>
<Expression></Expression>
</Bp>
<Bp>
<Number>1</Number>
<Type>0</Type>
<LineNumber>642</LineNumber>
<EnabledFlag>1</EnabledFlag>
<Address>0</Address>
<ByteObject>0</ByteObject>
<HtxType>0</HtxType>
<ManyObjects>0</ManyObjects>
<SizeOfObject>0</SizeOfObject>
<BreakByAccess>0</BreakByAccess>
<BreakIfRCount>0</BreakIfRCount>
<Filename>.\FreeRTOS\source\portable\NetworkInterface\board_family\NetworkInterface.c</Filename>
<ExecCommand></ExecCommand>
<Expression></Expression>
</Bp>
<Bp>
<Number>2</Number>
<Type>0</Type>
<LineNumber>602</LineNumber>
<EnabledFlag>1</EnabledFlag>
<Address>0</Address>
<ByteObject>0</ByteObject>
<HtxType>0</HtxType>
<ManyObjects>0</ManyObjects>
<SizeOfObject>0</SizeOfObject>
<BreakByAccess>0</BreakByAccess>
<BreakIfRCount>0</BreakIfRCount>
<Filename>.\FreeRTOS\source\portable\NetworkInterface\board_family\NetworkInterface.c</Filename>
<ExecCommand></ExecCommand>
<Expression></Expression>
</Bp>
</Breakpoint>
<Breakpoint/>
<WatchWindow1>
<Ww>
<count>0</count>
@ -373,7 +324,19 @@
<pMultCmdsp></pMultCmdsp>
<SystemViewers>
<Entry>
<Name>System Viewer\ENET_DMA</Name>
<Name>System Viewer\BKP</Name>
<WinId>35902</WinId>
</Entry>
<Entry>
<Name>System Viewer\PMU</Name>
<WinId>35904</WinId>
</Entry>
<Entry>
<Name>System Viewer\RCU</Name>
<WinId>35903</WinId>
</Entry>
<Entry>
<Name>System Viewer\RTC</Name>
<WinId>35905</WinId>
</Entry>
</SystemViewers>
@ -438,7 +401,7 @@
<GroupNumber>1</GroupNumber>
<FileNumber>5</FileNumber>
<FileType>1</FileType>
<tvExp>1</tvExp>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>.\PHY\PHY_DP83848C.c</PathWithFileName>
@ -462,7 +425,7 @@
<Group>
<GroupName>FreeRTOS</GroupName>
<tvExp>1</tvExp>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
<RteFlg>0</RteFlg>
@ -470,7 +433,7 @@
<GroupNumber>2</GroupNumber>
<FileNumber>7</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>.\FreeRTOS\source\portable\NetworkInterface\Common\phyHandling.c</PathWithFileName>

26
main.c
View File

@ -207,31 +207,39 @@ static void vInitMCU(void)
rcu_periph_clock_enable(RCU_AF);
rcu_periph_clock_enable(RCU_ENET);
rcu_periph_clock_enable(RCU_ENETTX);
rcu_periph_clock_enable(RCU_ENETRX);
rcu_periph_clock_enable(RCU_BKPI);
rcu_periph_clock_enable(RCU_ENETRX);
rcu_periph_clock_enable(RCU_PMU);
rcu_periph_clock_enable(RCU_RTC);
rcu_periph_reset_enable(RCU_BKPIRST);
rcu_periph_reset_disable(RCU_BKPIRST);
rcu_periph_clock_enable(RCU_BKPI);
/* Configure RTC */
#ifndef DEBUG_RTC_LXTAL
gpio_init(OSC32_PORT, GPIO_MODE_AF_PP, GPIO_OSPEED_2MHZ, OSC32_IN);
gpio_init(OSC32_PORT, GPIO_MODE_AF_PP, GPIO_OSPEED_2MHZ, OSC32_OUT);
if (FALSE == rtc_counter_get() & FALSE == rtc_flag_get(RTC_CTL_OVIF))
{
{
pmu_backup_write_enable();
bkp_deinit();
rcu_osci_on(RCU_LXTAL);
rcu_periph_clock_enable(RCU_RTC);
rcu_rtc_clock_config(RCU_RTCSRC_LXTAL);
rcu_rtc_clock_config(RCU_RTCSRC_LXTAL);
while (RESET == (RCU_BDCTL & RCU_BDCTL_LXTALSTB)) {}
rtc_lwoff_wait();
rtc_lwoff_wait();
rtc_counter_set(0xA5A5);
rtc_lwoff_wait();
rtc_lwoff_wait();
rtc_prescaler_set(0);
rtc_lwoff_wait();
pmu_backup_write_disable();
}
else if (TRUE == rtc_flag_get(RTC_CTL_OVIF))
rtc_flag_clear(RTC_CTL_OVIF);
#endif
/* Configure GPIO Alternate UART function */
gd_eval_com_init(EVAL_COM1);