crash@home
New Member
I am trying to multiplex a 3 digit 7 segment display, because my processor is to be performing additional tasks while multiplexing a delay between switching is undesirable. i have found an article about how to combat this problem from "gooligum.com" but i am still a little hazy, could somebody please indicate how changing of bit 2 indicates a time of 2μs. What i struggle to understand is that with a counter or in this case timer 0 bit 2 will not change its state on every instruction cycle so this logic to me is flawed because the switching wouldn't be at regular intervals.
below is the extract:
and the example code segment:
please help me to understand or point me in the right direction
Thanks
below is the extract:
But a timer can still be used to good advantage when implementing multiplexing on a baseline PIC. It would be impractical to try to use programmed delays while multiplexing; there’s too much going on. But Timer0 can provide a steady tick that we can base our timing on – displaying each digit for a single tick, and then counting ticks to decide when a certain time (e.g. 1 sec) has elapsed and we need to perform an action (such as incrementing counters).
If the tick period is too short, there may not be enough time to complete all the program logic needed between ticks, but if it’s too long, the display will flicker.
Many PIC developers use a standard 1 ms tick, but to simplify the task of counting in seconds, an (approximately) 2 ms tick is used in this example. If each of three digits is updated at a rate of 2 ms per digit, the whole 3-digit display is updated every 6 ms, so the display rate is 1 ÷ 6 ms = 167 Hz – fast enough to avoid perceptible flicker.
To generate an approximately 2 ms tick, we can use Timer0 in timer mode (based on the 1 MHz instruction clock), with a prescale ratio of 1:256. Bit 2 of Timer0 will then be changing with a period of 2048 μs.
and the example code segment:
Code:
To display a single digit, such as minutes, the code becomes:
; display minutes for 2.048 ms
w60_hi btfss TMR0,2
goto w60_hi
movf mins,w
pagesel set7seg
call set7seg
pagesel $
bsf MINUTES
w60_lo btfsc TMR0,2
goto w60_lo
; wait for TMR0<2> to go high
; output minutes digit
; enable minutes display
; wait for TMR<2> to go low
please help me to understand or point me in the right direction
Thanks
Last edited: