MrDEB
Well-Known Member
using LEDs in breadboard
programming the PIC using the Junebug
with following code timer 2 flashes (duh at 5ms)
the timer 1 comes on for about 5 seconds then off for about same THEN a short burst then it comes on for 5 seconds again.
going to add the other 3 timers, maybe have something to do with timer handler?
the 2000ms is not 20000.
I am just changing values to do some trial and error (maybe learn something?? learn by doing)
programming the PIC using the Junebug
with following code timer 2 flashes (duh at 5ms)
the timer 1 comes on for about 5 seconds then off for about same THEN a short burst then it comes on for 5 seconds again.
going to add the other 3 timers, maybe have something to do with timer handler?
the 2000ms is not 20000.
I am just changing values to do some trial and error (maybe learn something?? learn by doing)
Code:
// 18F1320@ 8MHz - they are just used here for clarity...
Device = 18F1320
Clock = 8
Include "ISRTimer.bas"
// constant ID to 4 * 16 bit timers...
Const
Timer1 = 0,
Timer2 = 1,
Timer3 = 2,
Timer4 = 3
// OnTimer1 event...
Event OnTimer1()
Toggle(PORTB.0)//pin 8
End Event
Event OnTimer2()
Toggle(PORTB.1)//pin 9
End Event
// activate the timer module...
Timer.Initialize
// initialise the timers - refresh every 1000Hz (1ms)...
Timer.Items(Timer1).Interval = 50 // 50ms
Timer.Items(Timer1).OnTimer = OnTimer1 // timer event handler
Timer.Items(Timer2).Interval = 5 // 50ms
Timer.Items(Timer2).OnTimer = OnTimer2
// timer event handler
Timer.Items(Timer4).Interval = 200 // 2000ms, no event handler
// enable the timers...
Timer.Items(Timer1).Enabled = true
Timer.Items(Timer2).Enabled = true
Timer.Items(Timer4).Enabled = true
// start processing all timers...
Timer.Start
// main program loop...
While true
// this is a polled timer, not event driven - check to see
// if it has timeout...
If Not Timer.Items(Timer4).Enabled Then
Toggle(PORTB.0)//pin 8
Toggle(PORTB.1)//pin 9
Timer.Items(Timer4).Enabled = true
EndIf
Toggle(PORTB.1)//pin 8
Wend