-
大小: 869KB文件類型: .zip金幣: 2下載: 1 次發布日期: 2021-03-29
- 語言: 其他
- 標簽: bootloader??PIC18F25K80??
資源簡介
寫這個程序廢了好多事,到處查資料看網上的資料也不多,調試成功了就傳上來給大家分享一下。
代碼片段和文件信息
#include?“mcc_generated_files/mcc.h“
//extern?bit?keyflag;
extern?bit?REflag;
//extern?bit?bootwriteflag;
extern?unsigned?char?temp_D[8];
extern?unsigned?char?temp_DLC;
extern?unsigned?char?BOOTCANHBOOTCANL;
//extern??unsigned?char?cStartFlg;
//extern??unsigned?long?cEndFlg;
unsigned?char?maxv=0maxv1=0;
unsigned?char?delay_bootbootloader_flag;
#define?BOOTDELAYTIME?30
#define?_str(x)??#x
#define?str(x)??_str(x)
void?main(void)
{
????SYSTEM_Initialize();
//????variate_init();
????INTCONbits.GIE=1;
????INTCONbits.PEIE=1;
???//?WDTCON=0X09;
????RS_SetLow();?
??//?CanSendBuffer(0x7dfCAN_rx_buf8);
????T0CON?=?0x87;//使能定時器0256分頻
????//8M/128?*1000?=?62.5???1ms???
????TMR0H?=?0xE7;
????TMR0L?=?0x95;
????delay_boot?=?0;
????bootloader_flag?=?0;
????while(delay_boot?????{???
?????//???CANincident();
????????if(INTCONbits.T0IF?==?1)?
????????{???
????????????INTCONbits.T0IF?=?0;
????????????TMR0H?=?0xE7;
????????????TMR0L?=?0x95;
????????????delay_boot++;
????????????//??等待升級的倒計時
????????????CanSendBuffer(0x7df&delay_bootsizeof(delay_boot));
????????????if?((BOOTDELAYTIME-1)==delay_boot)?
????????????{???
????????????????//??沒有升級請求,跳入運行空間執行正常程序。
????????????????unsigned?char?ch[]={‘G‘‘o‘‘t‘‘o‘‘A‘‘p‘‘p‘};
????????????????CanSendBuffer(0x7dfchsizeof(ch));
????????????????STKPTR?=?0x00;
????????????????asm?(“pagesel?“?str(NEW_RESET_VECTOR));
????????????????asm?(“goto??“??str(NEW_RESET_VECTOR));
????????????}
????????}
????????if(PIR5bits.RXB0IF?==?1)
????????{???
????????????//??在倒計時內收到中斷請求,做升級相關工作。
????????????PIR5bits.RXB0IF?=?0;
//????????????RXB0CONbits.RXFUL?=?0;
????????????RXB0CONbits.RXB0FUL=0;
????????????BOOTCANH?=?RXB0SIDH;
????????????BOOTCANL?=?RXB0SIDL;
????????????temp_DLC?=?RXB0DLC;
????????????temp_D[0]?=?RXB0D0;
????????????temp_D[1]?=?RXB0D1;
????????????temp_D[2]?=?RXB0D2;
????????????temp_D[3]?=?RXB0D3;
????????????temp_D[4]?=?RXB0D4;
????????????temp_D[5]?=?RXB0D5;
????????????temp_D[6]?=?RXB0D6;
????????????temp_D[7]?=?RXB0D7;
????????????switch?(?temp_D[1])?
????????????{
????????????????case?0xAA:??????????????????//擦除0x1600-0xffff地址塊
????????????????{???
????????????????????//??擦除Flash
????????????????????Erase_Whole_Flash();
????????????????????unsigned?char?ch[]={‘A‘‘c‘‘k‘‘-‘‘-‘‘-‘0xAA};
????????????????????CanSendBuffer(0x7dfchsizeof(ch));
????????????????????bootloader_flag?=?1;
????????????????????break;
????????????????}
????????????}
????????????delay_boot?=?200;
????????????CanSendBuffer(0x7dftemp_D8);
????????}
????}
????while(1)
????{???
??????//?CANincident();????????
????????//進入升級程序
????????if(bootloader_flag?==?1)
????????{
????????????#define?ENDFLGDELAYTIME?0xFFFFF
????????????static?unsigned?char?chdata[64];
????????????static?unsigned?char?cStartFlg=0;
????????????static?unsigned?long?cEndFlg=ENDFLGDELAYTIME;
????????????static?unsigned?char?i=0j=0;
????????????static?uns
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2019-07-04?16:23??PIC18F25K80bootloader程序.X\
?????文件????????3381??2017-10-24?09:04??PIC18F25K80bootloader程序.X\Makefile
?????文件??????616063??2017-10-24?09:16??PIC18F25K80bootloader程序.X\MyConfig.mc3
?????目錄???????????0??2019-07-04?16:23??PIC18F25K80bootloader程序.X\build\
?????目錄???????????0??2019-07-04?16:23??PIC18F25K80bootloader程序.X\build\default\
?????目錄???????????0??2019-07-04?16:23??PIC18F25K80bootloader程序.X\build\default\production\
?????文件??????728535??2019-07-04?08:49??PIC18F25K80bootloader程序.X\build\default\production\main.p1
?????文件?????????290??2019-07-04?08:49??PIC18F25K80bootloader程序.X\build\default\production\main.p1.d
?????文件??????389573??2019-07-04?08:49??PIC18F25K80bootloader程序.X\build\default\production\main.pre
?????目錄???????????0??2019-07-04?16:23??PIC18F25K80bootloader程序.X\build\default\production\mcc_generated_files\
?????文件??????723712??2019-07-04?08:49??PIC18F25K80bootloader程序.X\build\default\production\mcc_generated_files\ecan.p1
?????文件?????????245??2019-07-04?08:49??PIC18F25K80bootloader程序.X\build\default\production\mcc_generated_files\ecan.p1.d
?????文件??????388605??2019-07-04?08:49??PIC18F25K80bootloader程序.X\build\default\production\mcc_generated_files\ecan.pre
?????文件??????715357??2019-07-04?08:49??PIC18F25K80bootloader程序.X\build\default\production\mcc_generated_files\flash.p1
?????文件?????????179??2019-07-04?08:49??PIC18F25K80bootloader程序.X\build\default\production\mcc_generated_files\flash.p1.d
?????文件??????385934??2019-07-04?08:49??PIC18F25K80bootloader程序.X\build\default\production\mcc_generated_files\flash.pre
?????文件??????714834??2019-07-04?08:49??PIC18F25K80bootloader程序.X\build\default\production\mcc_generated_files\mcc.p1
?????文件?????????347??2019-07-04?08:49??PIC18F25K80bootloader程序.X\build\default\production\mcc_generated_files\mcc.p1.d
?????文件??????388310??2019-07-04?08:49??PIC18F25K80bootloader程序.X\build\default\production\mcc_generated_files\mcc.pre
?????文件??????709496??2019-07-04?08:49??PIC18F25K80bootloader程序.X\build\default\production\mcc_generated_files\pin_manager.p1
?????文件?????????203??2019-07-04?08:49??PIC18F25K80bootloader程序.X\build\default\production\mcc_generated_files\pin_manager.p1.d
?????文件??????383511??2019-07-04?08:49??PIC18F25K80bootloader程序.X\build\default\production\mcc_generated_files\pin_manager.pre
?????目錄???????????0??2019-07-04?16:23??PIC18F25K80bootloader程序.X\debug\
?????目錄???????????0??2019-07-04?16:24??PIC18F25K80bootloader程序.X\debug\default\
?????目錄???????????0??2019-07-04?16:23??PIC18F25K80bootloader程序.X\dist\
?????目錄???????????0??2019-07-04?16:23??PIC18F25K80bootloader程序.X\dist\default\
?????目錄???????????0??2019-07-04?16:23??PIC18F25K80bootloader程序.X\dist\default\production\
?????文件?????3144718??2019-07-03?16:07??PIC18F25K80bootloader程序.X\dist\default\production\V6812MCfutianbootloader20190703-5-nointerrupt.X.production.bin
?????文件???????88847??2019-07-03?16:07??PIC18F25K80bootloader程序.X\dist\default\production\V6812MCfutianbootloader20190703-5-nointerrupt.X.production.cmf
?????文件???????21677??2019-07-03?16:07??PIC18F25K80bootloader程序.X\dist\default\production\V6812MCfutianbootloader20190703-5-nointerrupt.X.production.elf
?????文件????????4479??2019-07-03?16:07??PIC18F25K80bootloader程序.X\dist\default\production\V6812MCfutianbootloader20190703-5-nointerrupt.X.production.hex
............此處省略52個文件信息
評論
共有 條評論