The interrupts will not wait for PBP statements to finish.
Ok fine, ... for many years I've resisted making a count down elapsed timer for humanitarian reasons.
But if you guys are going to do it anyhow, I might as well make a new version of the Elapsed Timer.
I can only hope that if somebody uses it for nefarious purposes, they end up blowing themselves up.
Here's the test circuit.
Here's the test program ...
' Define LCD connections DEFINE LCD_DREG PORTC ' Set LCD Data port DEFINE LCD_DBIT 4 ' Set starting Data bit (0 or 4) if 4-bit bus DEFINE LCD_RSREG PORTC ' Set LCD Register Select port DEFINE LCD_RSBIT 2 ' Set LCD Register Select bit DEFINE LCD_EREG PORTC ' Set LCD Enable port DEFINE LCD_EBIT 3 ' Set LCD Enable bit DEFINE LCD_BITS 4 ' Set LCD bus size (4 or 8 bits) DEFINE LCD_LINES 2 ' Set number of lines on LCD DEFINE LCD_COMMANDUS 2000 'Command delay time in us DEFINE LCD_DATAUS 50 'Data delay time in us DEFINE OSC 4 INCLUDE "Elapsed_DN.bas" ; Elapsed Timer Routines ZERO_LED VAR PORTB.3 ANSEL = 0 ' All Digital ANSELH = 0 LOW ZERO_LED ' start with LED OFF OPTION_REG.7 = 0 ' enable PORTB pull-ups PAUSE 250 LCDOUT $FE,1 ' Initialize LCD PAUSE 250 Days = 1 ' set initial time Hours = 1 Minutes = 3 Seconds = 10 GOSUB StartTimer ' Start the Elapsed Timer Main: CountDown = !PORTB.0 IF SecondsChanged = 1 THEN SecondsChanged = 0 LCDOUT $FE,2, DEC Days,"d-",DEC2 Hours,":",DEC2 Minutes,":",DEC2 Seconds ENDIF IF ZERO_LED != ZERO THEN ZERO_LED = ZERO GOTO Main
If it is not pressed, it counts up.
The LED comes on when it reaches 0.
If you are using the countdown for a movie set, it has to stop at 1 second.
Put this in the main loop.
IF (CountDown=1) AND (Days=0) AND (Hours=0) AND (Minutes=0) and (Seconds=1) _ THEN GOSUB StopTimer
Re: What is the dv/dt side of an inductor
Sure, do it if you can. Will not hurt. On the contrary.
Ioannis Today, 09:35The EMI will be less but i bet you won't be able to check the difference without proper tools (EMI antennas and Analyzers).
Ioannis