3. Practical Class 2 Programming Microcontrollers
Set/Reset ·
Set bit /
Reset bit /
Toggle bit /
·
If Expression1 Then
Statements1
...
Elseif Expression2 Then
Statements2
11
...
Else 22
Statements3
... 3
End If
SELECT CASE var
Case Test1 : Statements1
Case Test2 : Statements2 1 var = Test1
Case Else : Statements3 2 var = Test2
3
END SELECT
·
Do
Statements
Loop [until Expression]
While Condition
Statements
Wend
For Var = Start To End [step Value]
Statements End Start
Next Var .step
Exit For For
Exit Do Do
Exit While While
Faculty of Electrical and Electronic Eng. 43 Automatic Control & Automation Dept.
4.
SRAM ·
Dim Var1 As Bit 0 or 1
Dim Var2 As Byte 0 to 255
Dim Var3 As Integer -32,768 to +32,767
Dim Var4 As Word 0 to 65535
Dim Var5 As Long -2147483648 to 2147483647
Dim Var6 As Single 1.5 x 10^–45 to 3.4 x 10^38
Dim Var7 As Double
Dim Var8 As String * 1 * chr_num
Dim Array(8) As Byte
Const Symbol = Numconst
Ex. Const Pi = 3.14159265358979
Const Symbol = Stringconst
Ex. Const S = "TEST"
Const Symbol = Expression
Ex. Const E =(b1 * 3) + 2
Local Var As Type
·
Px.y
Debounce Px.y , state , label , Sub
Ex. Debounce Key1 , 0 , Sw1 , Sub
state
label
Debounce
Config Debounce = time
Bitwait x , Set/reset
Ex. Bitwait Pinb.7 , reset
44