avr threads
Pal Lukacs
ekegep at yahoo.com
Sat Sep 16 10:38:51 CEST 2006
Moczik Gabor <pm at progzmaster.hu> wrote:
volatile unsigned int cnt1,cnt2;
volatile unsigned char flag1, flag2;
unsigned int cnt1_threshold,cnt2_threshold;
void timer1_isr()
{
cnt1++;
if (cnt1==cnt1_threshold) {
cnt1=0;
flag1=1;
}
cnt2++;
if (cnt2==cnt2_threshold) {
cnt2=0;
flag2=1;
}
}
void main()
{
// periodus ido beallitas
cnt1_threshold=57;
cnt2_threshold=79;
enable_timer1();
for(;;) {
if (flag1) {
flag1=0;
// 1-es animacio egy lepese ide
}
if (flag2) {
flag2=0;
// 2-es animacio
}
// egyeb folyamatok...
}
}
Egy valamit nem ertek.Miert volatile a valtozok egy resze es a tobbi nem ?Ugyanugy van hasznalva main() ban meg megszakitasban is,nem?
Koszi.
---------------------------------
Do you Yahoo!?
Get on board. You're invited to try the new Yahoo! Mail.
More information about the Elektro
mailing list