Skip to content
Snippets Groups Projects
Commit 18161602 authored by Michal Rybka's avatar Michal Rybka
Browse files

Přidán článek AVR - LCD panel - wait.c

(Autoexportován z Joomly)
parent f387678f
No related branches found
No related tags found
No related merge requests found
+++
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">&amp;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 { } --&amp;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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment