Kód: Vybrat vše
#include <htc.h>
__CONFIG(INTRCRB4 & WDTDIS & UNPROTECT & MCLRDIS);
void init(void)
{
TRISB = 0;
PORTB = 0;
}
void DelayUs(unsigned char us)
{
unsigned char time;
time = (us/25);
while(--time != 0)
continue;
}
void main(void)
{
init();
while (1)
{
DelayUs(100);
RB1 = 0;
DelayUs(100);
RB1 = 1;
}
}pokud program spustim tak je výstup RB1 v log 1 místo toho aby se generoval signál s periodou 200us, ale pokud v delay odstranim deleni 25 a místo argumentu 100 napisi 4 tak se na výstupu generuje signál s periodou cca 200us