当前位置:网站首页>STM32F103 several special pins are used as ordinary io. Precautions and data loss of backup register 1,2

STM32F103 several special pins are used as ordinary io. Precautions and data loss of backup register 1,2

2022-07-28 12:42:00 yi_ tianchou

stm32F103C8T6 chip  

There are two possibilities for backup register data loss :

1、 Triggered an intrusion interrupt

PC13 As an ordinary IO When using To disable the intrusion interrupt function , Otherwise, the backup register data will be shut down , Data loss at startup ,( You can check other articles , Don't explain in detail )

2、  chip VBAT Power off when the machine is turned off . If you need to back up the register to save data when it is shut down , that VBAT Need to connect to button battery , If after shutdown VBAT Also power down , Backup registers cannot be saved , At that time, I was curious about why the backup register data was always lost , It turns out that VBAT Why , Later it was changed to flash Stored data , practice : Triggered when shutdown Low voltage interruption , Then save the data to flash.( It's usually used MCU Inside flash For storage ,100uF enough 512 Byte storage )

 

The following is a description of several special pins :

1、PC13   RTC

Introduction to intrusion function :

  Intrusion detection function analysis : Functional data backup .

1 BKP_CR Of TPAL position , Set the decision TAMPER The signal of the pin is determined by 0 change 1 Or another 1 change 0 Is a valid trigger signal , Generate intrusion detection event set flag position (BKR_CSR Of TEF).

2 After the intrusion detection event, all data backup registers will be reset .

3 One thing to notice is that : stay BKP_CR Of TPE Bit allows before enabling , An intrusion detection event generated by an intrusion detection pin is also effective . This is beneficial For better protection of data .

4. When TPAL=0( or 1), If you are in BKP_CR Of TPE Bit permission ( Intrusion detection pin allows bit ) Before enabling TPAL=1( or 0), Once the intrusion detection function is allowed , An additional intrusion event will occur . Even though BKP_CR Of TPE( Intrusion detection pin allows bit ) Position as 1 Then there is a new edge jump

5 After an intrusion detection event is detected and cleared , Intrusion detection pin should be prohibited . Reset before writing the data backup register again BKP_CR Of TPE position ( Intrusion detection pin allows bit ). In this way, it can avoid the intrusion detection event still occurring on the intrusion detection pin , Keep writing to the data backup register .

6VDD When the power supply is disconnected , Intrusion detection function is still valid , Bit to avoid unnecessary data backup register reset ,TAMPER The outside of the pin should be connected to the correct level .

 

initialization IO Add this full stop when :     

      PWR_BackupAccessCmd( ENABLE );/* Allow modification of RTC And backup registers */
     RCC_LSEConfig(RCC_LSE_OFF);// Turn off the external low-speed external clock signal function after ,PC13 PC14 PC15 Can be ordinary IO use .
     BKP_TamperPinCmd(DISABLE);  /* Turn off intrusion detection ,PC13 Can be used as ordinary IO*/
     BKP_ITConfig(DISABLE);       /* prohibit TAMPER interrupt */

 

2、 PA13  PA14  PA15    These three feet are   JTAG foot , Even according to ordinary IO Initialization is also not normal. You need to add

    GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable , ENABLE);

It can be regarded as normal IO Use

 

 

 

 

 

原网站

版权声明
本文为[yi_ tianchou]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/209/202207281140058579.html