📄 sci.frm
字号:
VERSION 5.00
Object = "{648A5603-2C6E-101B-82B6-000000000014}#1.1#0"; "MSCOMM32.OCX"
Begin VB.Form Form1
BorderStyle = 1 'Fixed Single
Caption = "输出比较 方波测试 苏州大学freescale MCU&DSP研发中心 2006年12月版"
ClientHeight = 6240
ClientLeft = 4575
ClientTop = 3135
ClientWidth = 8985
BeginProperty Font
Name = "黑体"
Size = 15.75
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Icon = "SCI.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 6240
ScaleWidth = 8985
StartUpPosition = 2 '屏幕中心
Begin MSCommLib.MSComm MSComm1
Left = 4650
Top = 7950
_ExtentX = 1005
_ExtentY = 1005
_Version = 393216
DTREnable = -1 'True
InputMode = 1
End
Begin VB.CommandButton CmdCLR
Caption = "清空"
BeginProperty Font
Name = "宋体"
Size = 14.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 6000
TabIndex = 3
Top = 7980
Width = 1545
End
Begin VB.CommandButton CmdEXIT
Caption = "退出"
BeginProperty Font
Name = "宋体"
Size = 14.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 7770
TabIndex = 2
Top = 7980
Width = 1275
End
Begin VB.Frame Frame1
BackColor = &H8000000A&
Caption = "状态窗口"
BeginProperty Font
Name = "黑体"
Size = 15.75
Charset = 134
Weight = 400
Underline = 0 'False
Italic = -1 'True
Strikethrough = 0 'False
EndProperty
Height = 1095
Left = 480
TabIndex = 0
Top = 120
Width = 7875
Begin VB.TextBox TxtRe
BackColor = &H00FFFFFF&
BeginProperty Font
Name = "黑体"
Size = 18
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 480
Left = 1080
MaxLength = 30
TabIndex = 1
Top = 360
Width = 5385
End
End
Begin VB.Frame Frame2
Caption = "产生方波"
Height = 3375
Left = 480
TabIndex = 4
Top = 1440
Width = 7935
Begin VB.CommandButton Command1
Caption = "启动"
Height = 615
Index = 7
Left = 6000
TabIndex = 13
Top = 2160
Width = 1335
End
Begin VB.CommandButton Command1
Caption = "启动"
Height = 615
Index = 6
Left = 4200
TabIndex = 12
Top = 2160
Width = 1335
End
Begin VB.CommandButton Command1
Caption = "启动"
Height = 615
Index = 5
Left = 2400
TabIndex = 11
Top = 2160
Width = 1335
End
Begin VB.CommandButton Command1
Caption = "启动"
Height = 615
Index = 4
Left = 600
TabIndex = 10
Top = 2160
Width = 1335
End
Begin VB.CommandButton Command1
Caption = "启动"
Height = 615
Index = 3
Left = 6000
TabIndex = 9
Top = 1080
Width = 1335
End
Begin VB.CommandButton Command1
Caption = "启动"
Height = 615
Index = 2
Left = 4200
TabIndex = 8
Top = 1080
Width = 1335
End
Begin VB.CommandButton Command1
Caption = "启动"
Height = 615
Index = 1
Left = 2400
TabIndex = 7
Top = 1080
Width = 1335
End
Begin VB.CommandButton Command1
Caption = "启动"
Height = 615
Index = 0
Left = 600
TabIndex = 5
Top = 1080
Width = 1335
End
Begin VB.Label Label1
Caption = "通道7"
Height = 375
Index = 7
Left = 6240
TabIndex = 20
Top = 1800
Width = 855
End
Begin VB.Label Label1
Caption = "通道6"
Height = 375
Index = 6
Left = 4440
TabIndex = 19
Top = 1800
Width = 855
End
Begin VB.Label Label1
Caption = "通道5"
Height = 375
Index = 5
Left = 2640
TabIndex = 18
Top = 1800
Width = 855
End
Begin VB.Label Label1
Caption = "通道4"
Height = 375
Index = 4
Left = 840
TabIndex = 17
Top = 1800
Width = 855
End
Begin VB.Label Label1
Caption = "通道3"
Height = 375
Index = 3
Left = 6240
TabIndex = 16
Top = 720
Width = 855
End
Begin VB.Label Label1
Caption = "通道2"
Height = 375
Index = 2
Left = 4440
TabIndex = 15
Top = 720
Width = 855
End
Begin VB.Label Label1
Caption = "通道1"
Height = 375
Index = 1
Left = 2640
TabIndex = 14
Top = 720
Width = 855
End
Begin VB.Label Label1
Caption = "通道0"
Height = 375
Index = 0
Left = 840
TabIndex = 6
Top = 720
Width = 855
End
End
Begin VB.Label Label3
Caption = "提示:"
Height = 375
Left = 480
TabIndex = 22
Top = 4920
Width = 2055
End
Begin VB.Label Label2
Caption = "产生方波时引脚电压2.5V;方波停止时引脚电压5V。"
Height = 495
Left = 960
TabIndex = 21
Top = 5400
Width = 7695
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'程序描述:
' (1)通道0~7的方波启动和停止
' (2)接收窗口中显示修改是否成功
'-------------------------------------------------------
Option Explicit '检查未经声明的变量
Dim SendData() As Byte '发送数据数组
Dim RecvData() As Byte '接收数据数组
Dim Btn_Num As Byte '记录被按下的按钮号
Private Sub Command1_Click(Index As Integer)
'控件数组
ReDim SendData(1)
If Command1(Index).Caption = "启动" Then
SendData(0) = Asc(CStr(Index)) '通道号
SendData(1) = Asc("S") '启动
MSComm1.Output = SendData
End If
If Command1(Index).Caption = "停止" Then
SendData(0) = Asc(CStr(Index)) '通道号
SendData(1) = Asc("E") '停止
MSComm1.Output = SendData
End If
Btn_Num = Index
End Sub
Private Sub Form_Load()
'串行口初始化
Call SCIinit(MSComm1, 1, "9600,N,8,1")
' '清空有关文本框
TxtRe.Text = ""
'开放串行中断
MSComm1.RThreshold = 1
End Sub
Public Sub MSComm1_OnComm() '串行接收中断
Dim i As Integer
Dim Re_Flag As Byte
MSComm1.RThreshold = 0 '关闭串行中断
RecvData = MSComm1.Input
For i = LBound(RecvData) To UBound(RecvData)
Re_Flag = RecvData(i)
Next i
'根据返回值和按钮状态来切换按钮显示的内容
If Re_Flag = 86 Then
If Command1(Btn_Num).Caption = "停止" Then
Command1(Btn_Num).Caption = "启动"
TxtRe.Text = "通道" + CStr(Btn_Num) + "方波停止!"
GoTo Re_exit
End If
If Command1(Btn_Num).Caption = "启动" Then
Command1(Btn_Num).Caption = "停止"
TxtRe.Text = "通道" + CStr(Btn_Num) + "产生方波!"
End If
End If
Re_exit:
MSComm1.RThreshold = 1 '开放串行中断
End Sub
Private Sub CmdCLR_Click() '单击"清空"按钮
TxtRe.Text = ""
End Sub
Private Sub CmdEXIT_Click() '单击"退出"按钮
If MSComm1.PortOpen = True Then MSComm1.PortOpen = False
End
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -