📄 ckmain.c
字号:
#include <htc.h>#include "cksum.h"/** A simple example of how one can runtime-verify a checksum * that was generated using the compiler's --checksum option * The pre-compiled result is found in the const variable, _checksum0. * The header, cksum.h has settings that need to be adjusted to match the * --checksum specifications. */void main(void){ TRISB = 0; // output mode PORTB = 0xFF; if( cksum() != _checksum0){ while(1); // checksum error - no effect on PORTB /* My calculated checksum doesn't match the pre-compiled result... * 1) do all of the variables in cksum.h match the --checksum settings? * 2) are the ranges of calculation realistic? * 3) the size of calculation range should be a multiple of the algorithm variable. */ }else{ unsigned int delay; while(1){ // success for(delay=1000;delay;delay--) PORTB ^= 0xFF; // blink all of PORTB } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -