Hi,
Basicly you can have as many interrupts sources as the PIC has (TMR0, TMR1, USART, RB0, RBChange, CMP, ADC, whatever.....). When the program interrupts and starts executing the ISR (InterruptServiceRoutine) you need to check what caused the interrupt and act uppon it accordingly.
My approach to this would be to use an external 32.768kHz xtal, set the TMR of your choise up to generate an interrupt at 100Hz, then in the ISR count those ticks. When you have 100 ticks you have a second. When you have 216 ticks, toggle your step pin.
This is completely untested and just something to show you one approach. Also, I suggest you'll have a look at Darrel Taylors Instant Interrupts, search the forum, it makes interrupts a breeze but MAY be overkill in this application.Code:Ticks var byte '1/100th seconds StepTicks Var Byte '1/100th seconds, used for step pulse timing Seconds var Byte 'Seconds Minutes Var Byte 'Minutes Hours var Byte 'Hours Days var Byte 'Days, perhaps change this to a Word. Goto Main 'Jump over ISR. DISABLE ISR: 'Reload timer with correct value here, and restart it. Ticks = Ticks + 1 If Ticks = 100 then Ticks = 0 Seconds = Seconds + 1 If Seconds = 60 then Seconds = 0 Minutes = Minutes + 1 If Minutes = 60 then Minutes = 0 Hours = Hours + 1 If Hours = 24 Then Hours = 0 Days = Days + 1 Endif Endif Endif Endif StepTicks = StepTicks + 1 If StepTicks = 216 then '2.16s, time to toggle the step pin. StepTicks = 0 Toggle StepPin Endif RESUME ENABLE Main: '--------------------------------------------- 'Your main code here....... 'remember, NO time consuming commands, like Pause, sleep, nap etc. '---------------------------------------------- Goto Main
About that LCD, if your connections ARE fine and matches your DEFINES then the only thing I can think of is a longer pause at the beginning OR you could try to increase the command and data delay with:
/Henrik Olsson.Code:DEFINE LCD_COMMANDUS 2000 '<-----Increase this... DEFINE LCD_DATAUS 50 '<----and this.




Bookmarks