4 digit counter by LDmicro

7seg-4digit

LDmicro export text
for ‘Atmel AVR ATmega8 28-PDIP’, 4.000000 MHz crystal, 5.0 ms cycle time

LADDER DIAGRAM:

|| ||
|| ; Sample program: how to drive a multiplexed 7-segment LED display. This is ||
001|| ; for a 3-digit common-cathode display but it is easy to modify. ||
|| ||
|| ||
|| ||
|| ||
|| ; With a 5 ms cycle time, this will oscillate at 100 Hz, which should be ||
002|| ; okay (33 Hz refresh rate, 1/3 duty cycle). ||
|| ||
|| ||
|| ||
|| ||
|| Rdosc Rdosc ||
003||——-]/[—————————————————————–( )——-||
|| ||
|| ||
|| ||
|| ||
|| Rdosc Cdigit ||
004||——-] [————————————————————–{CTC 0:3}—-||
|| ||
|| ||
|| ||
|| ||
|| ; Use the Ycom_digitx lines to drive the base/gate of the NPN transistor/ ||
005|| ; n-FET used to switch the cathode of digit x. ||
|| ||
|| ||
|| ||
|| ||
|| [Cdigit ==] Ycom_digit0 ||
006||—[ 0 ]–+———————————————————-(/)——-||
|| | ||
|| | {digit := } ||
|| +—————————————————-{ digit0 MOV}–||
|| ||
|| [Cdigit ==] Ycom_digit1 ||
||—[ 1 ]–+———————————————————-(/)——-||
|| | ||
|| | {digit := } ||
|| +—————————————————-{ digit1 MOV}–||
|| ||
|| [Cdigit ==] Ycom_digit2 ||
||—[ 2 ]–+———————————————————-(/)——-||
|| | ||
|| | {digit := } ||
|| +—————————————————-{ digit2 MOV}–||
|| ||
|| ||
|| ||
|| ||
|| [Cdigit ==] Ycom_digit3 ||
007||—[ 3 ]–+———————————————————-(/)——-||
|| | ||
|| | {digit := } ||
|| +—————————————————-{ digit3 MOV}–||
|| ||
|| ||
|| ||
|| ||
|| ; You can drive the segment pins of the display directly from the GPIO pins, ||
008|| ; Yseg_a to Yseg_b. ||
|| ||
|| ||
|| ||
|| ||
|| [digit /=] [digit /=] Yseg_a ||
009||—[ 1 ]——-[ 4 ]———————————————( )——-||
|| ||
|| [digit /=] [digit /=] Yseg_b ||
||—[ 5 ]——-[ 6 ]———————————————( )——-||
|| ||
|| [digit /=] Yseg_c ||
||—[ 2 ]————————————————————–( )——-||
|| ||
|| [digit /=] [digit /=] [digit /=] Yseg_d ||
||—[ 1 ]——-[ 4 ]——-[ 7 ]—————————-( )——-||
|| ||
|| [digit ==] Yseg_e ||
||—[ 0 ]—+———————————————————-( )——-||
|| | ||
|| [digit ==] | ||
||—[ 2 ]—+ ||
|| | ||
|| [digit ==] | ||
||—[ 6 ]—+ ||
|| | ||
|| [digit ==] | ||
||—[ 8 ]—+ ||
|| ||
|| [digit /=] [digit /=] [digit /=] [digit /=] Yseg_f ||
||—[ 1 ]——-[ 2 ]——-[ 3 ]——-[ 7 ]———–( )——-||
|| ||
|| [digit /=] [digit /=] [digit /=] Yseg_g ||
||—[ 0 ]——-[ 1 ]——-[ 7 ]—————————-( )——-||
|| ||
|| ||
|| ||
|| ||
|| ; Fill in your program here; just set the output that you want on digit0, ||
010|| ; digit1, and digit2. ||
|| ||
|| ||
|| ||
|| ||
|| {digit0 := } ||
011||———————————————————————{ 4 MOV}–||
|| ||
|| {digit1 := } ||
||———————————————————————{ 7 MOV}–||
|| ||
|| {digit2 := } ||
||———————————————————————{ 9 MOV}–||
|| ||
|| ||
|| ||
|| ||
|| {digit3 := } ||
012||———————————————————————{ 4 MOV}–||
|| ||
|| ||
|| ||
|| ||
|| ; by Jonathan Westhues, June 2005 ||
013|| ||
|| ||
|| ||
|| ||
||——[END]————————————————————————–||
|| ||
|| ||

I/O ASSIGNMENT:

Name | Type | Pin
—————————-+——————–+——
Ycom_digit0 | digital out | 14
Ycom_digit1 | digital out | 15
Ycom_digit2 | digital out | 16
Ycom_digit3 | digital out | 18
Yseg_a | digital out | 2
Yseg_b | digital out | 3
Yseg_c | digital out | 4
Yseg_d | digital out | 5
Yseg_e | digital out | 6
Yseg_f | digital out | 11
Yseg_g | digital out | 12
Rdosc | int. relay |
Cdigit | counter |
digit | general var |
digit0 | general var |
digit1 | general var |
digit2 | general var |
digit3 | general var |

Advertisements
Explore posts in the same categories: Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s


%d bloggers like this: