Starting from 51, the MCU has been playing for a long time, there are 51, PIC, AVR, etc., I have long wanted to play ARM with the trend, but it has not started, the reason ----- I don't know what to do with ARM ( For myself). If you study for study, you definitely can't learn well. Then cortex-m3 came out. It is said that this thing can replace the microcontroller, so I immediately began to pay attention. I also started learning at the first time, but unfortunately I was a little wrong at the beginning and chose the wrong type (still for myself). I hope that this chip should be full of streets, and you can buy it anywhere, but the first one I chose is obviously not available. For this reason, I have probably wasted more than a year. Now, returning to the road that is right for me, I will learn something while learning.
Gossip is a little more, right now. The following is ready to begin.
RTC Practice of Small TIps of STM32 Microcontroller
BKP has not finished yet, how to switch to the RTC, because RTC and BKP have some connections, it is not enough to think about it.
The following is an introduction to the RTC in the data sheet:
****** introduction started
15.1 Introduction to RTC
The real time clock is an independent timer. The RTC module has a set of counters that count continuously and provides the clock calendar function in the appropriate software configuration. Modify the value of the counter to reset the current time and date of the system.
The RTC module and the clock configuration system (RCC_BDCR register) are in the backup area, ie the RTC settings and time remain unchanged after a system reset or wake-up from standby mode.
After the system is reset, access to the backing register and RTC is prohibited, preventing accidental writes to the backup area (BKP). Perform the following to enable access to the backing registers and RTC:
â— Set the PWREN and BKPEN bits of the RCC_APB1ENR register to enable the power and backup interface clocks.
â— Set the DBP bit of register PWR_CR to enable access to the backing register and RTC.
****** introduction ends
Let's play this RTC with the examples in the library, just to solve the TAMPER pin problem.
The example to use this time is this:
There is nothing to say about the configuration, the last example: BKP-"Backup_Data modified:
Stm32_eval.c
Stm3210e_eval.h
Stm32_eval.h
The three files were copied over, the project was built, and the road was smooth, compiled and linked very smoothly, and then entered the debugging. As a result, there was a problem, see below:
Entering the debugging interface stops at the disassembly interface. Once the program is executed, it stops immediately. What is this BKPT instruction? Checked the instruction list, it turned out to be a breakpoint instruction, so why stop here? The omnipotent net, a search came out, thanks to the efforts of the predecessors, thanks to the great network. ..
The conclusion is: "Whenever you use printf, you will have this problem."
Solution:
Open the OpTIons for Target item, tick the front of the Use MicroLIB, and recompile the link.
The reason for the problem, the online explanation is: This is a problem with the Printf library function, you need to use the MicroLIB library instead of the default library. The reason is that the default printf is not using a serial port, so it should be changed.
There is a function like this in main.c:
/**
* @brief Retargets the C library printf funcTIon to the USART.
* @param None
* @retval None
*/
PUTCHAR_PROTOTYPE
{
/* Place your implementaTIon of fputc here */
/* eg write a character to the USART */
USART_SendData(EVAL_COM1, (uint8_t) ch);
/* Loop until the end of transmission */
While (USART_GetFlagStatus(EVAL_COM1, USART_FLAG_TC) == RESET)
{}
Return ch;
}
According to the description of this function, it is to do this.
Guangzhou Bolei Electronic Technology Co., Ltd. , https://www.nzpal.com