对于需求STM32F0 IAP升级的朋友,这个例程不要错过,足够你在研发使用了
单片机源程序如下:
- #include "stm32f0xx.h"
- #include "main.h"
- #include "delay.h"
- #include "tim1.h"
- #include "usart.h"
- #include "iap.h"
- #include "gpio.h"
- uint32_t TimingDelay;
- uint32_t Program_Addr1=0x8002000; //FLASH前8K直接给BootLoad
- uint32_t Program_Addr2=0x8002400;
- uint32_t Program_Addr3=0x8002800;
- uint32_t Program_Addr4=0x8002C00;
- uint8_t RX_Value;
- int main(void)
- {
- uint32_t CNT;
- // //void IAP_Set(void)
- uint32_t i = 0;
- /* Relocate by software the vector table to the internal SRAM at 0x20000000 ***/
- /* Copy the vector table from the Flash (mapped at the base of the application
- load address 0x08003000) to the base address of the SRAM at 0x20000000. */
- FLASH_Unlock();
- for(i = 0; i < 48; i++)
- {
- *((uint32_t*)(0x20000000 + (i << 2)))=*(__IO uint32_t*)(APPLICATION_ADDRESS + (i<<2));
- }
- /* Enable the SYSCFG peripheral clock*/
- FLASH_Lock();
- RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);
- /* Remap SRAM at 0x00000000 */
- SYSCFG_MemoryRemapConfig(SYSCFG_MemoryRemap_SRAM);
- if (SysTick_Config(SystemCoreClock / 1000)) //1ms中断一次
- {
- /* Capture error */
- while (1);
- }
- while(1)
- {
-
- LED_Init();
- STM32_USART_Init();
- while(1)
- {
-
- GPIOF->ODR|=1<<7;
- delay_ms(500);
- GPIOF->ODR&=~(1<<7);
- delay_ms(300);
- if(RX_Value==0x05) GPIOB->ODR^=3;
- }
- }
- }
复制代码
所有资料51hei提供下载:
STM32F030IAP.7z
(174.19 KB, 下载次数: 128)
|