STM32 IAP升级方法
单片机源程序如下:
- #include "led.h"
- #include "delay.h"
- #include "key.h"
- #include "sys.h"
- #include "lcd.h"
- #include "usart.h"
- #include "usmart.h"
- #include "rtc.h"
-
- int main(void)
- {
- u8 t=0;
-
- SCB->VTOR = FLASH_BASE | 0x10000; /* Vector Table Relocation in Internal FLASH. */
-
- delay_init(); //延时函数初始化
- NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);//设置中断优先级分组为组2:2位抢占优先级,2位响应优先级
- uart_init(115200); //串口初始化为115200
- LED_Init(); //LED端口初始化
- LCD_Init();
- usmart_dev.init(SystemCoreClock/1000000); //初始化USMART
- RTC_Init(); //RTC初始化
- POINT_COLOR=RED;//设置字体为红色
- LCD_ShowString(60,50,200,16,16,"WarShip STM32");
- LCD_ShowString(60,70,200,16,16,"RTC TEST");
- LCD_ShowString(60,90,200,16,16,"ATOM@ALIENTEK");
- LCD_ShowString(60,110,200,16,16,"2012/9/7");
- //显示时间
- POINT_COLOR=BLUE;//设置字体为蓝色
- LCD_ShowString(60,130,200,16,16," - - ");
- LCD_ShowString(60,162,200,16,16," : : ");
- while(1)
- {
- if(t!=calendar.sec)
- {
- t=calendar.sec;
- LCD_ShowNum(60,130,calendar.w_year,4,16);
- LCD_ShowNum(100,130,calendar.w_month,2,16);
- LCD_ShowNum(124,130,calendar.w_date,2,16);
- switch(calendar.week)
- {
- case 0:
- LCD_ShowString(60,148,200,16,16,"Sunday ");
- break;
- case 1:
- LCD_ShowString(60,148,200,16,16,"Monday ");
- break;
- case 2:
- LCD_ShowString(60,148,200,16,16,"Tuesday ");
- break;
- case 3:
- LCD_ShowString(60,148,200,16,16,"Wednesday");
- break;
- case 4:
- LCD_ShowString(60,148,200,16,16,"Thursday ");
- break;
- case 5:
- LCD_ShowString(60,148,200,16,16,"Friday ");
- break;
- case 6:
- LCD_ShowString(60,148,200,16,16,"Saturday ");
- break;
- }
- LCD_ShowNum(60,162,calendar.hour,2,16);
- LCD_ShowNum(84,162,calendar.min,2,16);
- LCD_ShowNum(108,162,calendar.sec,2,16);
- LED0=!LED0;
- }
- delay_ms(10);
- };
- }
复制代码
所有资料51hei提供下载:
实验15 RTC实验_FLASH_APP.rar
(381.18 KB, 下载次数: 12)
|