标题:
STM8s的IAP升级源程序 bootloader与APP
[打印本页]
作者:
王杰
时间:
2019-10-9 17:36
标题:
STM8s的IAP升级源程序 bootloader与APP
测试有效,仅供参考
单片机源程序如下:
/*****
Copyright 2016-2020 Alex.Fang All rights reserved.
Header: stm8s105c6t6 IAP code
File Name: main.c
Author: Alex.Fang
Date: 2016-07-22
免责声明:
此代码你可以用来学习和交流。不得商用!应用此程序酿成事故由你自己承担!
本人不负责维护和支持此代码!如有疑问和看不懂别来烦我! ^_^
openedv论坛好友可以随便下载和转给他人参阅学习。
版权遵循 = GPL
Disclaimer of liability:
This code you can use to learn and communicate. No commercial!
Use this procedure to cause accidents by yourself!
I am not responsible for the maintenance and support of this code!
If you have any questions and cannot read don't bother me! ^_^
Openedv forum friends can easily download and
transfer to other people see learning.
copyright = GPL
********/
/* Includes ------------------------------------------------------------------*/
#include <string.h>
#include <stdio.h>
#include "stm8s.h"
#include "stm8s_clk.h"
#include "main.h"
//#include "stm8s_wwdg.h"
#include "delay.h"
#include "flash.h"
#include "stm8s_flash.h"
#include "config.h"
#include "IO_config.h"
#include "crc16.h"
#include "xmodem.h"
#include "stm8s_uart2.h"
#include "uart2.h"
//#include "stm8s_tim2.h"
//#include "wwdg.h"
//#define NGI() _asm("sim"); /* 禁止全局中断 */
//#define EGI() _asm("rim"); /* 使能全局中断 */
//#define WFI() _asm("halt"); /*进入到低功耗模 WFI */
/* Private defines -----------------------------------------------------------*/
/* Private function prototypes -----------------------------------------------*/
/* Private functions ---------------------------------------------------------*/
//address for GO command
//TFunction GoAddress;
void STM8_CLK_Init(void)
{
CLK_DeInit();//复位时钟寄存器
CLK_HSICmd(ENABLE);//HSI = 16MHz
CLK_HSIPrescalerConfig(CLK_PRESCALER_HSIDIV1); //f_psc = 16MHz/1
//CLK_ClockSecuritySystemEnable();//开启时钟安全系统
//enableInterrupts();
}
void system_init(void)
{
STM8_CLK_Init();
FLASH_DeInit();
Init_GPIO();
Init_UART2();
}
void main(void)
{
//_asm("sim");//关全部中断
disableInterrupts();
system_init();
//_asm("rim");//开全部中断
enableInterrupts();
uart2_data("\r\n\r\n",4);
uart2_data("Bootloader Start...\r\n",21);
uart2_data("Ver=20160722_1.0\r\n",18);
disableInterrupts();
//unlock_PROG();
//unlock_DATA();
//Print("goto app...\r\n");
//goto_app();
//Print("Failed!\r\n");
//waiting_time_count=200;
Xmoden_STate = IDLE;
//RS232_Tran_Chr(NAK);
disp_menu();
while (1)
{
RS232_ISR();
RS232_Rec_Xmodem();
}//end while
}
复制代码
所有资料51hei提供下载:
bootloader.7z
(3.99 MB, 下载次数: 86)
2019-10-10 01:18 上传
点击文件名下载附件
下载积分: 黑币 -5
APP.7z
(3.98 MB, 下载次数: 64)
2019-10-10 01:18 上传
点击文件名下载附件
下载积分: 黑币 -5
作者:
jeeseliu
时间:
2019-11-16 17:04
感谢分享
作者:
jeeseliu
时间:
2019-11-17 12:36
能简单说一下如何使用吗?
作者:
王杰
时间:
2019-11-26 15:44
jeeseliu 发表于 2019-11-17 12:36
能简单说一下如何使用吗?
先把BootLoader1程序烧进板子,然后用上位机给MCU发送APP代码,让mcu自己写进flash里面去执行
作者:
dreamfly
时间:
2020-1-5 15:51
上位机工具有提供吗?
作者:
张明211
时间:
2020-6-19 19:57
学习了!
欢迎光临 (http://www.51hei.com/bbs/)
Powered by Discuz! X3.1