Příklady s časovým zpožděním v C pro 8051: Porovnání verzí
Skočit na navigaci
Skočit na vyhledávání
Založena nová stránka: zdroj informací: http://what-when-how.com/8051-microcontroller/data-types-and-time-delay-in-8051-c/ ==example 7-1== <source lang"asm"> #include <reg51.h> void main (voi... |
Bez shrnutí editace |
||
Řádek 1: | Řádek 1: | ||
zdroj informací: http://what-when-how.com/8051-microcontroller/data-types-and-time-delay-in-8051-c/ | zdroj informací: http://what-when-how.com/8051-microcontroller/data-types-and-time-delay-in-8051-c/ | ||
==example 7-1== | ==Unsigned char== | ||
===example 7-1=== | |||
<source lang"asm"> | <source lang"asm"> | ||
Řádek 10: | Řádek 11: | ||
{ | { | ||
unsigned char z; | unsigned char z; | ||
for (z=0;z<=255;z++) | for (z=0;z<=255;z++) | ||
P1=z; | P1=z; | ||
} | } | ||
</source> | </source> | ||
==example 7-2== | ===example 7-2=== | ||
<source lang"asm"> | <source lang"asm"> | ||
Řádek 28: | Řádek 27: | ||
unsigned char z; | unsigned char z; | ||
for (z=0;z<=10;z++) | for (z=0;z<=10;z++) | ||
P1 = mynum | P1 = mynum[z]; | ||
} | } | ||
</source> | </source> | ||
==example 7-3== | ===example 7-3=== | ||
<source lang"asm"> | <source lang"asm"> | ||
Řádek 52: | Řádek 51: | ||
</source> | </source> | ||
==Unsigned char== | |||
===example 7-4=== | |||
#include <reg51.h> | |||
void main (void) | |||
{ | |||
char mynum [] = {+1,-1,+2,-2,+3,-3,+4,-4}; | |||
unsigned char z; | |||
for (z=0;z<=8;z++) | |||
P1 = mynum[z]; | |||
} | |||
Verze z 28. 4. 2011, 18:43
zdroj informací: http://what-when-how.com/8051-microcontroller/data-types-and-time-delay-in-8051-c/
Unsigned char
example 7-1
#include <reg51.h>
void main (void)
{
unsigned char z;
for (z=0;z<=255;z++)
P1=z;
}
example 7-2
#include <reg51.h>
void main (void)
{
unsigned char mynum [] = "012345ABCD";
unsigned char z;
for (z=0;z<=10;z++)
P1 = mynum[z];
}
example 7-3
#include <reg51.h>
void main (void)
{
for (;;) //opakovani cyklu
P1=0x55;
P1=0xAA;
}
Unsigned char
example 7-4
- include <reg51.h>
void main (void)
{
char mynum [] = {+1,-1,+2,-2,+3,-3,+4,-4}; unsigned char z;
for (z=0;z<=8;z++) P1 = mynum[z];
}