-- -------------------------------------------------------------------------- -- count_11LED.jal - 11-bit binary counter -- $Id: count_11LED.jal,v 1.1 2003/03/04 16:58:12 jerry Exp $ -- $Source: /home/cvsroot/projectsTop/picProjectBoard/examples/count_11LED.jal,v $ -- -- -------------------------------------------------------------------------- -- A binary count is displayed on D1-D4 and the first column of U5 (or -- U6). -- -------------------------------------------------------------------------- include f877_20 include jlib disable_a_d_functions pin_c0_direction = output pin_c1_direction = output pin_c2_direction = output pin_c3_direction = output -- control lines for the 5x7 display -- port D controls the rows, port B the columns port_d_direction = all_output pin_b0_direction = output pin_b1_direction = output pin_b2_direction = output pin_b3_direction = output pin_b4_direction = output var byte count_low var byte count_high count_low = 0 count_high = 0 -- a zero on the control line in port_b enables the column of LEDs port_b = ! 1 forever loop count_low = count_low + 1 if count_low > 15 then count_low = 0 count_high = count_high + 1 if count_high > 127 then count_high = 0 end if end if -- LEDs D1-D4 are 'on' when the assoicated bit in port C is 0, so invert the -- count before writing it to the port. port_c = ! count_low port_d = count_high delay_1ms( 10 ) end loop