Giúp em viết chương trình tạo sóng tam giác với tần số 1Khz bằng VDK 8051,
Xin cam on!
Xin cam on!
counter = 0;
port = 0;
flag = 0;
if (flag == 0)
if (counter < 256)
counter = counter + 1 ;
port = counter;
Delay;
else
flag = 1;
end;
else
if (counter > 0)
counter = counter -1;
port = counter;
Delay;
else
flag = 0;
end;
end;
counter = 0;
port = 0;
flag = 0;
if (flag == 0)
if (counter < 256)
counter = counter + 1 ;
port = counter;
Delay;
else
flag = 1;
end;
else
if (counter > 0)
counter = counter -1;
port = counter;
Delay;
else
flag = 0;
end;
end;
counter = 0;
port = 0;
flag = 0;
if (flag == 0)
if (counter < 256)
counter = counter + 1 ;
port = counter;
Delay;
else
flag = 1;
end;
else
if (counter > 0)
counter = counter -1;
port = counter;
Delay;
else
flag = 0;
end;
end;
Comment