📄 main.c
字号:
#include <hidef.h> /* for EnableInterrupts macro */
#include "derivative.h" /* include peripheral declarations */
extern char __SEG_START_RELOCATABLE[];
extern char __SEG_SIZE_RELOCATABLE[];
extern char __SEG_END_RELOCATABLE[];
#pragma DATA_SEG MY_ZEROPAGE
unsigned char near gnTest;
#pragma DATA_SEG DEFAUTL_ROM
char CHKSUM @ 0xF309;
#pragma CODE_SEG RELOCATABLE
void vfnDummy(void);
#pragma CODE_SEG DEFAULT_ROM
void MCU_init(void); /* Device initialization function declaration */
void CopyCode(char*);
void main(void) {
/* Uncomment this function call after using Device Initialization
to use the generated code */
/* MCU_init(); */
char *p;
gnTest = 0;
EnableInterrupts; /* enable interrupts */
/* include your code here */
p = __SEG_START_RELOCATABLE;
CopyCode(p);
for(;;) {
vfnDummy();
__RESET_WATCHDOG(); /* feeds the dog */
} /* loop forever */
/* please make sure that you never leave this function */
}
void CopyCode(char * Src)
{
char Counter = (char)__SEG_SIZE_RELOCATABLE;
char LocalChkSum = 0;
volatile char * Dst;
Dst = (char*)vfnDummy;
do{
*Dst = *Src++;
LocalChkSum ^= *Dst++;
} while(--Counter);
if(LocalChkSum != CHKSUM)
{
asm("BGND");
}
}
#pragma CODE_SEG RELOCATABLE
void vfnDummy(void)
{
volatile unsigned char Dummy;
Dummy=0;
Dummy++;
Dummy--;
gnTest++;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -