diff --git a/articles/2012/avr-lcd-panel-waitc.md b/articles/2012/avr-lcd-panel-waitc.md new file mode 100644 index 0000000000000000000000000000000000000000..36f05edb0496e8290cc2ff2da6fd497df3f9ed5f --- /dev/null +++ b/articles/2012/avr-lcd-panel-waitc.md @@ -0,0 +1,95 @@ ++++ + +title = "AVR - LCD panel - wait.c" +perex_e = " + +KompatibilnĂ zapojenĂ: LCD panel s ATmega8 + +Ke staĹľenĂ: wait.c == wait.pdf == wait.htm +. +. +" +tags = ["ÄŚlánek"] ++++ + + + +KompatibilnĂ zapojenĂ: LCD panel s ATmega8 + +Ke staĹľenĂ: wait.c == wait.pdf == wait.htm +. +. + +* * * + +<title>Untitled</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta name="generator" content="SynEdit HTML exporter"> <style type="text/css">&lt;!-- body { color: #000000; background-color: #FFFFFF; } .cpp1-assembler { } .cpp1-brackets { } .cpp1-comment { color: #008000; font-style: italic; } .cpp1-float { color: #000080; } .cpp1-hexadecimal { color: #000080; } .cpp1-character { } .cpp1-identifier { } .cpp1-illegalchar { } .cpp1-number { color: #000080; } .cpp1-octal { color: #0000FF; } .cpp1-preprocessor { } .cpp1-reservedword { font-weight: bold; } .cpp1-space { color: #008080; } .cpp1-string { color: #800000; } .cpp1-symbol { } --&gt;</style> + +``` +/*--------------------------------------------------------------------------- + +soubor: wait.c +verze: 1.0 +datum: 9.1.2012 +popis: + +Cekaci rutiny a makra pro bitove operace +Cekaci rutiny jsou mnohem uspornejsi nez bezne "delay.h" + +Tento soubor vynikl ze souboru "mojelib.h" jehoz autora bohuzel neznam. + +---------------------------------------------------------------------------*/ + +// Zmena bitu portu, IO registru nebo promenne: +#define setb(bajt,bit) bajt |= 1<<(bit) //nastav bit +#define clrb(bajt,bit) bajt &= ~(1<<(bit)) //nuluj bit +#define negb(bajt,bit) bajt ^= 1<<(bit) //neguj bit + +// Casove smycky: +void wait_ms (unsigned int c); // cekej milisekund(max65553): +void wait_us (unsigned int c); // cekej mikrosekund(max65553): + +//cekej milisekund: +unsigned char reg21 = F_CPU / 60000; // F_CPU = frekv. oscilatoru [Hz], + // (vnitrni konstanta prekladace) +void wait_ms (unsigned int c) +{ + asm("push r20"); + asm("push r21"); +asm("_Wms0:"); + asm("ldi r20,0x14"); +asm("_Wms1:"); + asm("lds r21,reg21"); +asm("_Wms2:"); + asm("dec r21"); + asm("brne _Wms2"); + asm("dec r20"); + asm("brne _Wms1"); + asm("dec r24"); + asm("brne _Wms0"); + asm("dec r25"); + asm("brpl _Wms0"); + asm("pop r21"); + asm("pop r20"); +} + +//cekej mikrosekund: +unsigned char reg20 = F_CPU / 6000000 + 1; +void wait_us(unsigned int c) +{ + asm("push r20"); +asm("_wus0:"); + asm("lds r20,reg20"); // 1-6MHz: r20=1 6-12MHz: r20=2 +asm("_wus1:"); + asm("dec r20"); + asm("brne _wus1"); + asm("dec r24"); + asm("brne _wus0"); + asm("dec r25"); + asm("brpl _wus0"); + asm("pop r20"); +} + +//eof +//(c) OK1ZKV 2012 + +``` \ No newline at end of file