怎么写一个方波程序

1.如何设计一个方波发生器程序CODE SEGMENT
ASSUME CS:CODE
ORG 10A0H
DAPORT EQU 0020H
F DW 00H ;初始化
J DB 00H
S DB 01H
ORG 10A0H
START: ;init 8255A
MOV DX,0FF2BH
MOV AL,10000001B;方式命令字,PC0~PC3输入
OUT DX,AL
;control pc
BEGIN: MOV DX,0FF2AH
IN AL,DX ;读PC口值
MOV BL,AL ;存入BL
CMP BL,02H ;"跳跃表",选择波形
JB FWAVE ;方波00~01,锯齿波02~03,三角波,04~05
CMP BL,04H
JB JWAVE
CMP BL,06H
JB SWAVE
JMP BEGIN
;FWAVE
F01: MOV F,0300H ;改变频率
JMP FDACON1
FWAVE: MOV AL,0FFH
CMP BL,01H ;选择频率
JE F01
MOV F,0400H
FDACON1:
CALL RDPC ;调用键扫子程序
MOV DX,DAPORT
OUT DX,AL
MOV CX,F
FDACO2:
LOOP FDACO2
NOT AL
JMP FDACON1
;JWAVE
JUMP1: JMP BEGIN ;充当键扫子程序 RDPC 的跳板 。*.*
J01: MOV J,02H ;改变频率
JMP JDACON1
JWAVE: MOV AL,0H
CMP BL,03H ;选择频率
JE J01
MOV J,01H
JDACON1:
CALL RDPC ;调用键扫子程序
MOV DX,DAPORT
OUT DX,AL
ADD AL,J
JMP JDACON1
;SWAVE
S01: MOV AL,0H ;恢复AL为0
MOV S,02H ;改变频率
JMP L1
SWAVE: MOV AL,0H
CMP BL,05H ;选择频率
JE S01
MOV S,01H
L1: CALL RDPC ;调用键扫子程序
MOV DX,DAPORT
OUT DX,AL
ADD AL,S
CMP AL,0FCH ;若AL=0FEH则置AL=0FFH,下坡
JNA L1
MOV AL,0FFH
L2: CALL RDPC ;键扫
OUT DX,AL
SUB AL,S
CMP AL,02H ;若AL<02H,则上坡
JNB L2
JMP L1
RDPC PROC NEAR ;键扫子程序
PUSH AX
PUSH DX
MOV DX,0FF2AH ;键扫
IN AL,DX
CMP BL,AL ;有没键按下
JNE JUMP1
POP DX
POP AX
RET
RDPC ENDP
CODE ENDS
END START
2.如何用c语言编写一段方波最好还是不要用延时函数2113
比较准确的方法是利5261用定时4102器
以c51为例:
/*********定时器1653方波************/
/*********16位定时器************/
/************机器周期1us********/
/*********占空比50%*************/
/*********方波周期1s*************/
int a; // 定义全局整形变量
void int() interrupt 1
{
设置专定时器初值为500;
a++;
if(a == 1000)
{
"输出属取反"
}
}
3.怎样用C语言编写一个方波函数附上代码,讲解在后面:
public class Program
{
static void Main(string[] args)
{
List<Point> range = new List<Point>(5 * 5);
for (int i = 0; i < 5; i++)
{
for (int j = 0; j < 5; j++)
{
range.Add(new Point { X = j, Y = i });
}
}
//移动方向的顺序
MoveDirection[] md = new[]
4.51单片机不同方波的KEIL程序怎么写^#include<reg51.h>
sbit P__25MS = P1^0;
sbit P_100MS = P1^1;
unsigned uchar tt;
main()
{
TMOD = 0x01;
TH0 = (65536 - 25000) / 256; //定时25ms
TL0 = (65536 - 25000) % 256;
TR0 = 1;
ET0 = 1;
EA = 1;
while(1);
}
void t0isr() interrupt 1
{
TH0 = (65536 - 25000) / 256; //定时25ms
TL0 = (65536 - 25000) % 256;
P__25MS = ~P__25MS;
tt++;
if(tt == 4) {tt = 0; P_100MS = ~P_100MS;}
}
【怎么写一个方波程序】

怎么写一个方波程序

文章插图