' ******************************************************************************
' * Title : Exp.08.bas *
' * Target Board : Mini-Phoenix - REV 1.00 *
' * Target MCU : ATMega32A *
' * Author : Walid Balid *
' * IDE : BASCOM AVR 2.0.7.3 *
' * Peripherals : Pull-Up Resistors *
' * Description : GPIOs as Input; Active Low (GND) *
' ******************************************************************************
' Set the SW Jumbers to GND (Active Low)
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'-----------------------[Definitions]
$regfile = "m32def.dat"
$crystal = 8000000
$baud = 9600
'-----------------------
'-----------------------[GPIO Configurations]
Config Portc = &B00000111
Led1 Alias Portc.0 : Led2 Alias Portc.1 : Led3 Alias Portc.2
Set Led1 : Set Led2 : Set Led3
Config Pind.2 = Input : Sw_1 Alias Pind.2 : Portd.2 = 1 'PU Internal Resistor
Config Pind.3 = Input : Sw_2 Alias Pind.3 : Portd.3 = 1
Config Pinb.2 = Input : Sw_3 Alias Pinb.2 : Portb.2 = 1
'-----------------------
'-----------------------[Variables]
Dim Count1 As Byte , Count2 As Byte , Count3 As Byte
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'--->[Main Program]
Print "Hello!"
Do
If Sw_1 = 0 Then Gosub Sw_r1
If Sw_2 = 0 Then Gosub Sw_r2
If Sw_3 = 0 Then Gosub Sw_r3
Loop
End
'---<[End Main]
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'--->[Print]
Sw_r1:
Toggle Led1 : Count1 = Count1 + 1
Print "Sw1 has Pressed! > " ; Count1
Return
'---<
Sw_r2:
Toggle Led2 : Count2 = Count2 + 1
Print "Sw2 has Pressed! > " ; Count2
Return
'---<
Sw_r3:
Toggle Led3 : Count3 = Count3 + 1
Print "Sw3 has Pressed! > " ; Count3
Return
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~