Use Keil's compilation environment to download, it is indeed possible to download, but the address of the entry is shown in the yellow line below. If single-step execution (F11) or full-speed operation (F5), the program will always stay in the original position (0x1FFF4252) Forcibly modify the value of the PC pointer and the value of SP to 0x8000000 and 0x2000000, and then click to run, you can run to the main() function, and then run at full speed, you can see the flashing of the LED lights on the customer board. But if the PC and SP pointer values ​​are not forcibly modified, the program will not execute. So the question becomes why the address after downloading the program is 0x1FFF4252? What address is 0x1FFF4252? Check the corresponding manual and found that 0x1FFF4252 is in the Systemmemory area. I measured the level of the Boot0 pin on the customer board with a multimeter, and found that the level was wrong, reaching 1.6V. Such a high level can be regarded as a high level. According to the customer's schematic diagram, Boot has pull-up and pull-down resistors. When soldering, both resistors are soldered on. Remove the pull-up resistor and ground the BOOT0 pin to low level, then compile and download to enter In Keil's environment, the program can be executed normally. The problem is found. For the initial test, the hardware is the same and the software is the same. However, IAR can run normally, but KEIL can't execute it. I don't understand. The setting of the IAR compilation environment can be more intelligent. Question 2: Debugging into the HardFault_Handler function On the Internet, such as stack overflow and memory overflow reasons, Compared with the above method, it is not resolved. It is found that it may be the reason why the stm32L series uses the internal clock HSI. Before configuring the system clock for the stm32L low-power chip, it is necessary to configure the access mode of the flash to ACC64 and LATENCY, as well as the adjustable voltage range of the kernel VOS[1:0]. Otherwise, even the highest frequency of 32MHz cannot be used as the system clock. Reprinted from: http://bbs.eeworld.com.cn/thread-490070-1-1.html Add the following lines of code to the beginning of the systeminit function. FLASH_ReadAccess64Cmd( DISABLE);//The system default is 32-bit access, according to the situation, it can be configured to 64-bit FLASH_SetLatency(FLASH_Latency_0); //FLASH zero Latency cycle Electric Test Pen ,Battery Detector,Circuit Tester,Voltage Test Pen YINTE TOOLS (NINGBO) CO., LTD , https://www.yinte-tools.com
//Enable PWR clock SET_BIT(RCC->APB1ENR, RCC_APB1ENR_PWREN);
while(!READ_BIT(RCC->APB1ENR, RCC_APB1ENR_PWREN))
_ _NOP();
//Configure the core voltage, the CPU is high-performance. In this example, the system clock is up to 16MHz
PWR_VoltageScalingConfig(PWR_VoltageScaling_Range1);