Code: Select all
Device = 18F27J13
Clock = 8
#option TIMER_TMR_SELECT = 3
#option TIMER_AUTO_RELOAD = true
Config IOL1WAY = OFF
// import modules...
Include "USART.bas"
Include "convert.bas"
Include "system.bas"
Include "setdigitalio.bas"
Include "ISRTimer.bas"
Include "utils.bas"
Private Dim
red As PORTA.7,
green As PORTA.6,
e32_aux As PORTC.0,
e32_snd As PORTC.1,
e32_rcv As PORTC.2,
e32_m0 As PORTB.0,
e32_m1 As PORTB.1,
pwr As PORTB.4
'****************************************************************************
OSCCON = $7F ' Interanl clock to 8mhz
OSCCON2 = $54
REFOCON = $00
OSCTUNE = $00
ADCON0 = $00 ' A/D disabled
ADCON1 = $00 ' A/D disabled
ANCON0 = $FF '
ANCON1 = $0F
REFOCON = $00
DSCONH = $00
DSCONL = $05
ODCON1 = $00
ODCON2 = $00
CCP4CON = $00 '
CCP5CON = $00
CCP6CON = $00
CCP7CON = $00
CCP8CON = $00
CCP9CON = $00
CCP10CON = $00
PMDIS3 = $FF ' Shut down peripherals
PMDIS2 = $FC ' Enable CCP4
PMDIS1 = $E0 ' Enable Timer 4, 3, 2, 1
PMDIS0 = $C4 ' Enable A/D, SPI1, UARTS
SetAllDigital()
SetAnalogPort(AN0, ANA) ' Set AN0 (RA0) to analog mode
SetAnalogPort(AN1, ANA) ' Set AN1 (RA1) to analog mode
Low(red)
Low(green)
Input(e32_aux)
High(e32_m1)
High(e32_m0)
Low(pwr)
// activate the timer module...
Timer.Initialize(3) ' If this is not (3), it doesnot work the first time *****
Timer.Items(0).Interval = 1000 ' If this is (3), it doesnot work the first time *****
Timer.Items(0).Enabled = true ' If this is (3), it doesnot work the first time *****
' I don't understand what the .items(x) means ****
'****************************************************************************
MAIN:
High(red) ' Make LED's blink so I can see program progression ****
DelayMS(100)
Low(red)
High(green)
DelayMS(20)
Timer.Start
While Timer.Items(0).Enabled ' This only delays once ****
Wend
Low(green)
DelayMS(500)
GoTo main