?? prog.txt
字號:
/* Boot Loader.c */
unsigned short CalculateCCITT(unsigned short CurrentCRC, unsigned char NextByte);
#define FLASH 0
#define SRAM 1
sbit TalkTo = P1^5;
void main(void)
{
unsigned char xdata *FlashPointer = 0;
unsigned int CRC_CCITT = 0;
unsigned int i;
// setup the processor for the boot code
// display the message "Verifying Software"
/*
Loop through all but the last byte of the flash (since j is only
two bytes I have to stop when j == 65536; otherwise the loop would
never end).
*/
for (j = 0; j < 65535; j++, FlashPointer++)
CRC_CCITT = CalculateCCITT(CRC_CCITT, *FlashPointer);
// add the last byte
CRC_CCITT = CalculateCCITT(CRC_CCITT, *FlashPointer);
TalkTo = SRAM;
// if the CRC failed...
// display message "VERIFICATION FAILED!"
// start the download procedure
// else run the application
} /* main */
unsigned short CalculateCCITT(unsigned short CurrentCRC, unsigned char NextByte)
{
char i;
for (i = 0; i < 8; i++)
{
if ((NextByte ^ CurrentCRC) & 1)
CurrentCRC = (CurrentCRC >> 1) ^ 0x8408;
else
CurrentCRC >>= 1;
NextByte >>= 1;
} /* for */
return (CurrentCRC);
} /* CalculateCCITT */
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -