PIC JAL IO Routine

'84 4 digit 22925/22926 LED display driver in JAL

by Vasile Surducan

...a library wich I used it for x84 to control a 22925/22926, 4 digit multiplexed display driver for LED's. Hardware and one example will be presented soon into my page.

--
-- file      : 22925.jal
-- author    : Surducan Vasile 
-- date      : march 2000
-- purpose   : procedures for 4 digit multiplexed display 22925/6/ family
-- includes  : none
-- pins      : b0 clock, ( 22926 pin 12 )
--             b1 reset, ( 22926 pin 13 )
--             a4 memory, ( 22926 pin 5 and pin 6 ) must be used to avoid
--             flicker in count/egg/clock down display mode
-- Jal       : 04.18, 04.22, 04.24
-- copyleft  : V.Surducan............hi-hi..........copyright :V.Surducan
-- email     : vasile@l30.itim-cj.ro
-- URL       : http://www.geocities.com/vsurducan/pic.htm ( for hardware )
             
-- configure port_b

var byte count = 0
var byte seconds = 0
var byte hundred = 0
var byte minutes = 0
var bit clock is pin_b0
var bit reset is pin_b1
var bit memo is pin_a4
pin_b0_direction = output
pin_b1_direction = output
pin_a4_direction = output

-- initialize input levels

procedure _22926_init is
clock = high
reset = low
end procedure

-- reset will clear all 4 digits

procedure _22926_reset is
 reset = high
 asm nop
 reset = low
end procedure


-- writing ( nr_1 * nr_2 ) counts, up to 255 * 255

procedure _22926_write ( byte in nr_1, byte in nr_2 ) is
 for nr_1 loop
  for nr_2 loop
   clock = high
   clock = low
  end loop
 end loop
end procedure

-- increment less then n (<255) counts

procedure _22926_up ( byte in n ) is
-- _22926_init
 if count < n then
  count = count + 1
  clock = high
  clock = low
 end if
end procedure

-- increment less then (cicle +1)*n counts, example: 
-- ( 3 + 1 ) * 250 = 1000 counts
-- ( 9 + 1 ) * 100 = 10000 counts

procedure _22926_full_up ( byte in cycle, byte in n )  is
 if hundred <= cycle  then
  if count == n then
   count = 0
   hundred = hundred + 1
  elsif count < n then
   count = count + 1
   clock = high
   clock = low
  end if
 end if
end procedure


-- decrement less then 255 counts using a trick: reset and increment
-- ( count - 1 ) pulses

procedure _22926_down is
-- _22926_init
 if count > 0 then
  count = count - 1
  memo = low
  _22926_reset
   for count loop
    clock = high
    clock = low
   end loop
  memo = high
 end if
end procedure

-- decrement in decimal (less then 1000 counts)
 
procedure _22926_full_down ( byte in n )is
-- _22926_init
 if hundred >= 1 then
   count = count - 1
   if count == 0 then
      count = n
      hundred = hundred - 1
   end if
   memo = low
   _22926_reset
    for count loop
    clock = high
    clock = low
   end loop
 _22926_write ( hundred, n )
 memo = high
 elsif hundred == 0 then
  _22926_down
 end if
end procedure


-- clock increment procedure (seconds incremented in main program)

procedure _22926_clock_up ( byte in minutes_max ) is
if minutes < minutes_max then
 if seconds == 60 then
      seconds = 0
      minutes = minutes + 1
 end if

-- for a rollover clock_up procedure these lines should be added
-- and first if...end if condition should be removed

-- if minutes == minutes_max then
-- minutes = 0
-- end if

memo = low
 _22926_reset
 for seconds loop
  clock = high
  clock = low
 end loop
_22926_write ( minutes, 100 )
memo = high
end if
end procedure

-- clock decrement procedure, at 0.00 decrement stops
-- (seconds must be incremented in main program,
-- minutes must be defined before use)

procedure _22926_clock_down is
 if ( minutes > 0 ) | ( seconds < 60 )  then
   if seconds == 60 then
      minutes = minutes - 1
      seconds = 0
   end if  
   memo = low
   _22926_reset
    for ( 59 - seconds ) loop
     clock = high
     clock = low
    end loop
   _22926_write ( minutes, 100 )
   memo = high
 end if
end procedure

  

Questions: