timer worked before?

Coding and general discussion relating to the compiler

Moderators: David Barker, Jerry Messina

Post Reply
MrDEB
Posts: 12
Joined: Fri Apr 24, 2009 1:45 am
Location: Salmon, Idaho

timer worked before?

Post by MrDEB » Mon Jun 22, 2009 9:19 pm

I had this timer code working but now it dosn't want to work??
I made several changes as I only need 2 timers.
end result I am after is a 20 minute low time then a short high, 20 minute low

Code: Select all

// 18F1320@ 8MHz - they are just used here for clarity...
Device = 18F1320
Clock = 8

Include "ISRTimer.bas"
include "INTOSC8.bas"          

// constant ID to 4 * 16 bit timers...
Const
   Timer1 = 0,
   Timer4 = 2
// OnTimer1 event...
Event OnTimer1()
   Toggle(PORTB.0)//pin 8
   DelayMS(10)
   
End Event

// OnTimer2 event...
Event OnTimer2()
   Toggle(PORTB.1)//pin9
    DelayMS(10)
   
End Event

// OnTimer3 event...
Event OnTimer3()
   Toggle(PORTB.2)//pin 17
End Event

// activate the timer module...
Timer.Initialize

// initialise the timers - refresh every 1000Hz (1ms)...
Timer.Items(Timer1).Interval = 10        // 50ms
Timer.Items(Timer1).OnTimer = OnTimer1   // timer event handler
 //
 // timer event handler
Timer.Items(Timer4).Interval = 40      // 2000ms, no event handler

// enable the timers...
Timer.Items(Timer1).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
       DelayMS(30)
      Toggle(PORTB.3)
      Timer.Items(Timer4).Enabled = true
   EndIf
      
   // background flash LED...
   High(PORTB.2)//pin 13
   DelayMS(50)
   Low(PORTB.2)//pin 13
   DelayMS(50)
Wend

Post Reply