Algorytm u?ycia 74HC595N

Robię krok dalej i chciałem użyć układu 74HC595N, Cel : Obsługa matrycy 8x8. Spotkałem się z algorytmem :

Od i=1 do i=8 {

1* na nóżkę 'data' podaj bit i; 2* ustaw pin11 HIGH; } 3* ustaw pin12 HIGH;

tym sposobem wyjścia układu 74HC595N przyjmą stan bitów jak ustawiono od 1 do 8. (nie podoba mi się w zasadzie to, że pinem "pin11" clock, trzebaby chyba mrygać,a tu tego nie ma ?) Czy to zadziała, jeśli nie, to jak zrobić, żeby zadziałało? Jak połączyć kilka układów 74HC595N ?

Dzięki.

Reply to
Jan Górski | gdL
Loading thread data ...

Jan Górski | gdL schrieb:

używałem 595 do wysterowania matrycy 2x(5x5-1), ale w sumie to samo co ty chcesz. Do tego cemu miałem ATTiny12 i 6x74HC595. Połączone "szeregowo", znaczy Q7' jednego idzie na DS następnego. MR, SH_CP i ST_CP równolegle do wsiech. Teraz trochę pływam, bo było to testowanie 3 lata temu i dokumentacja do dupy. Ale jak patrzę na kod, to mrygam SH_CP I ST_CP jednocześnie, do pierwszego DSa daję wartości z LUTa (toto miało generować "wzorki" na dwóch płytkach 5x5 LEDów bez środkowej diody). Robię to pisząc 6 lub 7 na port (110 by diodę zaświecić, 111 by zgasić). Cóś takiego na przykład:

SET_ALL: ldi i,49 SET_LOOP: ldi temp,0 out PORTB,temp ldi temp,6 out PORTB,temp dec i brne SET_LOOP ret

zapala wsie diody. Bit 0 to DS, 1 to SH, 2 to ST. Zmienne i i temp to rejestry. Do zgaszenia wsiech diod ładujesz 1 a potem 7. Diody połączone od Q0-Q7 do plusa.

Zrobiłem to tak, bo chciałem w wersji końcowej rozdzielić takty, by diody mi po drodze nie mrugały, ale wersji końcowej szef nie chciał, więc jest jak jest. Aha, reset olałem (do + na fest) i startuję program wywołując kasowanie wsiego.

Tu jest cały program na Tiny12:

.include "tn12def.inc"

.def temp =r16 .def delay1 =r17 .def delay2 =r18 .def delay3 =r19 .def i =r26 .def cnt =r22 .def cnt2 =r24

.equ DELAY_COUNT =0x8 .equ NO_OF_HOPS_CROSS =0x10 .equ NO_OF_HOPS_LIN =0x30 .equ NO_OF_HOPS_VOR =0x18 .equ NO_OF_HOPS_ETD =0x12 .equ SEQ_LENGTH_ETD =0x09

.CSEG .org 0

rjmp RESET rjmp RESET rjmp RESET rjmp RESET rjmp RESET rjmp RESET

RESET:

ser temp out DDRB,temp ; set port B to output

LOOP: rcall CLEAR_ALL

ldi cnt2,NO_OF_HOPS_ETD ldi ZH,high(LUT_ETD<<1) ldi ZL,low(LUT_ETD<<1)

LOOP2: lpm inc r30 mov cnt,r0 rcall SET_ONE rcall DELAY dec cnt2 brne LOOP2 rjmp LOOP

; ============== long delay routine ===================== DELAY: ldi delay3,DELAY_COUNT DELAY_X: dec delay1 brne DELAY_X dec delay2 brne DELAY_X dec delay3 brne DELAY_X ret

; ============== short delay routine =====================

DELAY_S: ldi delay3,DELAY_COUNT DELAY_SX: dec delay1 brne DELAY_SX dec delay3 brne DELAY_SX ret

; =============== clear all routine ==================

CLEAR_ALL: ldi i,49 CLEAR_LOOP: ; clear all ldi temp,1 out PORTB,temp ldi temp,7 out PORTB,temp dec i brne CLEAR_LOOP ret

; =============== set all routine =========================

SET_ALL: ldi i,49 SET_LOOP: ldi temp,0 out PORTB,temp ldi temp,6 out PORTB,temp dec i brne SET_LOOP ret

; =============== set one routine =========================

SET_ONE: mov i,cnt rcall CLEAR_LOOP

ldi temp,0 out PORTB,temp ldi temp,6 out PORTB,temp

ldi i,SEQ_LENGTH_ETD sub i,cnt rcall CLEAR_LOOP

ret

; =============== clear one routine =========================

CLEAR_ONE: mov i,cnt rcall SET_LOOP

ldi temp,1 out PORTB,temp ldi temp,7 out PORTB,temp

ldi i,SEQ_LENGTH_ETD sub i,cnt rcall SET_LOOP

ret

LUT_ETD: .DB 4, 4, 4, 3, 4, 5, 4, 7, 4, 1, 4, 3, 4, 5, 4, 7 .DB 4, 1

LUT_LIN: ;linear .DB 1,2,3,4,5,6,7,8,9,10,11,12 .DB 13,14,15,16,17,18,19,20,21,22,23,24 .DB 25,26,27,28,29,30,31,32,33,34,35,36 .DB 37,38,39,40,41,42,43,44,45,46,47,48

LUT_VOR: ; count forward .DB 15, 14, 20, 19, 17, 13, 12, 21, 24, 18, 11, 16 .DB 22, 23, 10, 6, 8, 2, 1, 9, 7, 5, 4, 3

LUT_CROSS: ; double cross .DB 16, 22, 21, 8, 22, 16, 8, 21, 23, 11, 20, 5 .DB 11, 23, 5, 20

LUT_EXP: ; forward (experimental) .DB 18,14,12,16,15,22,11,13, 2,10,20,21 .DB 1, 9,17,19, 4, 3, 6,23,24, 5, 7, 8

Waldek

Reply to
Waldemar Krzok

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.