PDA

View Full Version : how to setup 7 digit led multiplexer code for running in background?



CuriousOne
- 19th January 2014, 07:35
Hello.

I want to drive 4 digit 7 segment led display directly with 16F870, without using MAX7219, HC595 or any other IC. I know how to wrote the needed code and when launched in loop, it works just fine. However, this code needs to be run constantly, to maintain the display reading. So, how to run other tasks together with this code? as I understand, I need to set up an timed loop interrupt, so my main code is interrupted 25 times per second (to avoid the flicker) and lcd indication code is launched?

I need a hint, how to set-up hardware in such way, that say MAINLOOP code is interrupted 25 times a second and DISPLAYLED code launched, completed and then execution returned to MAINLOOP.

mackrackit
- 19th January 2014, 07:46
I would look at DT's Instants
http://www.picbasic.co.uk/forum/showthread.php?t=3251

The elapsed timer might be what you need, with a little modification...
http://darreltaylor.com/DT_INTS-18/elapsed.html

CuriousOne
- 19th January 2014, 08:15
Thanks, looks interesting!

Demon
- 19th January 2014, 14:31
I'm doing it backwards. Mainloop turns on leds, start a timer, while timer runs gosub main code, turn off leds when timer over. Start a 2nd timer for off period, gosub main code until over. Rinse and repeat.

I adjust 2 timers until no more flicker.

Robert

CuriousOne
- 21st January 2014, 07:15
The problem is, when looking at that sample code, I see only the part of code, which runs on interrupt. I have no idea where to insert the "main" code?

Demon
- 21st January 2014, 16:10
In here:


Main:
IF SecondsChanged = 1 THEN
SecondsChanged = 0
LCDOUT $FE,2, DEC Days,"d-",DEC2 Hours,":",DEC2 Minutes,":",DEC2 Seconds
ENDIF
GOTO Main

You check the status of the timer flags to determine if things have changed, then reset them.

Robert