#定义阈值10 main(){静态int j d;# asm ld, 0 x51 ioi ld (WDTTR),一个ld, 0 x54 ioi ld (WDTTR),一个# endasm # nodebug WrPortI (SPCR &SPCRShadow 0 x84);WrPortI(病人、&PEFRShadow 0 x00);WrPortI (PEDDR &PEDDRShadow 0 x00);BitWrPortI (PADR &PADRShadow 1,1);/ /预设门电路输出高,(1){而(1){/ *带来PA0低,然后再高,离开PA1高。让这内联汇编减少了时间这需要从15比1我们。* / # asm ld, 0 x03 ioi ld (PADR)、ld (PADRShadow),一个ld, 0 x02 ioi ld (PADR)、ld (PADRShadow),一个nop nop nop nop nop nop # endasm d = RdPortI(面);j = 0;/ /延迟如果阈值(d >){打破; } } /* If the count goes over the threshold for two consecutive cycles, then trip the gate. For speed, the second test is inlined instead of being made into some sort of loop with a variable check. */ #asm ld a, 0x03 ioi ld (PADR), a ld (PADRShadow), a ld a, 0x02 ioi ld (PADR), a ld (PADRShadow), a nop nop nop nop nop nop #endasm d = RdPortI(PEDR); j = 0; if(d > THRESHOLD) { //BitWrPortI(PADR, &PADRShadow, 0, 1); // Set the gate output low #asm xor a, a ioi ld (PADR), a ld (PADRShadow), a #endasm while(1) { /* check to see if the reset switch has been pressed */ d = RdPortI(PBDR); if(!(d & 0x04)) { BitWrPortI(PADR, &PADRShadow, 1, 1); break; } } } } }