From: hackbard Date: Sun, 17 May 2009 23:19:13 +0000 (+0200) Subject: uart changes for tiny2313, hc595 set routine, touch timer.asm, mods to main in order... X-Git-Url: https://hackdaworld.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=87ef21d9eacec01abdbf3306dd2493aecf0b4afb;p=my-code%2Fatmel.git uart changes for tiny2313, hc595 set routine, touch timer.asm, mods to main in order to compile --- diff --git a/led_plex/main.asm b/led_plex/main.asm index 32f1e7d..ef66821 100644 --- a/led_plex/main.asm +++ b/led_plex/main.asm @@ -10,6 +10,8 @@ .def tmp1 = r16 .def tmp2 = r17 .def uart_rxtx = r18 +.def hc595_sink = r19 +.def hc595_source = r20 ; ; interrupts @@ -37,7 +39,7 @@ rjmp T1_OVF rjmp T0_OVF ; UART RX -rjmp UART_RX +rjmp UART_RECEIVE ; UART UDRE reti @@ -72,9 +74,9 @@ reti ; WDT OVF reti - -; include control defines -.include "ctrl.def" +; +; init and main code +; RESET: INIT: @@ -83,7 +85,7 @@ INIT: rcall PORT_INIT ; timer init - rcall TIMER_INIT + ;rcall TIMER_INIT ; uart init rcall UART_INIT @@ -99,7 +101,14 @@ INIT: ;sei ; signal ready output - ldi uart_rxtx,0x23 + ldi uart_rxtx,0x68 + rcall UART_TX + + ; testing ... DO NOT CONNECT LEDS BY NOW !!! + ldi hc595_sink,0xff + ldi hc595_source,0xff + rcall SET_HC595 + ldi uart_rxtx,0x61 rcall UART_TX MAIN: @@ -124,6 +133,6 @@ T1_OVF: T0_OVF: reti -UART_RX: +UART_RECEIVE: reti diff --git a/led_plex/port.asm b/led_plex/port.asm index 715a402..55e90e2 100644 --- a/led_plex/port.asm +++ b/led_plex/port.asm @@ -7,15 +7,172 @@ PORT_INIT: out DDRB,tmp1 ; g, rck, sck -> low / scl -> high - cbi PORTB,(1<<0)|(1<<1)|(1<<2) - sbi PORTB,(1<<3) + ldi tmp1,0x07 + out PORTB,tmp1 + sbi PORTB,3 ; port d 6 -> output - ldi tmp1,(1<<6) - out DDRD,tmp1 + sbi DDRD,6 ; ser -> low - cbi PORTD,(1<<6) + cbi PORTD,6 ret +SET_HC595: + + ; storage clock -> low + cbi PORTD,1 + + ; source driver + + ; clock -> low + cbi PORTB,2 + ; set ser line + cbi PORTD,6 + sbrc hc595_source,7 + sbi PORTD,6 + ; clock -> high + sbi PORTB,2 + + ; clock -> low + cbi PORTB,2 + ; set ser line + cbi PORTD,6 + sbrc hc595_source,6 + sbi PORTD,6 + ; clock -> high + sbi PORTB,2 + + ; clock -> low + cbi PORTB,2 + ; set ser line + cbi PORTD,6 + sbrc hc595_source,5 + sbi PORTD,6 + ; clock -> high + sbi PORTB,2 + + ; clock -> low + cbi PORTB,2 + ; set ser line + cbi PORTD,6 + sbrc hc595_source,4 + sbi PORTD,6 + ; clock -> high + sbi PORTB,2 + + ; clock -> low + cbi PORTB,2 + ; set ser line + cbi PORTD,6 + sbrc hc595_source,3 + sbi PORTD,6 + ; clock -> high + sbi PORTB,2 + + ; clock -> low + cbi PORTB,2 + ; set ser line + cbi PORTD,6 + sbrc hc595_source,2 + sbi PORTD,6 + ; clock -> high + sbi PORTB,2 + + ; clock -> low + cbi PORTB,2 + ; set ser line + cbi PORTD,6 + sbrc hc595_source,1 + sbi PORTD,6 + ; clock -> high + sbi PORTB,2 + + ; clock -> low + cbi PORTB,2 + ; set ser line + cbi PORTD,6 + sbrc hc595_source,0 + sbi PORTD,6 + ; clock -> high + sbi PORTB,2 + + ; sink driver + + ; clock -> low + cbi PORTB,2 + ; set ser line + cbi PORTD,6 + sbrc hc595_sink,7 + sbi PORTD,6 + ; clock -> high + sbi PORTB,2 + + ; clock -> low + cbi PORTB,2 + ; set ser line + cbi PORTD,6 + sbrc hc595_sink,6 + sbi PORTD,6 + ; clock -> high + sbi PORTB,2 + + ; clock -> low + cbi PORTB,2 + ; set ser line + cbi PORTD,6 + sbrc hc595_sink,5 + sbi PORTD,6 + ; clock -> high + sbi PORTB,2 + + ; clock -> low + cbi PORTB,2 + ; set ser line + cbi PORTD,6 + sbrc hc595_sink,4 + sbi PORTD,6 + ; clock -> high + sbi PORTB,2 + + ; clock -> low + cbi PORTB,2 + ; set ser line + cbi PORTD,6 + sbrc hc595_sink,3 + sbi PORTD,6 + ; clock -> high + sbi PORTB,2 + + ; clock -> low + cbi PORTB,2 + ; set ser line + cbi PORTD,6 + sbrc hc595_sink,2 + sbi PORTD,6 + ; clock -> high + sbi PORTB,2 + + ; clock -> low + cbi PORTB,2 + ; set ser line + cbi PORTD,6 + sbrc hc595_sink,1 + sbi PORTD,6 + ; clock -> high + sbi PORTB,2 + + ; clock -> low + cbi PORTB,2 + ; set ser line + cbi PORTD,6 + sbrc hc595_sink,0 + sbi PORTD,6 + ; clock -> high + sbi PORTB,2 + + ; store to storage register + sbi PORTB,1 + + ret diff --git a/led_plex/timer.asm b/led_plex/timer.asm new file mode 100644 index 0000000..e371f65 --- /dev/null +++ b/led_plex/timer.asm @@ -0,0 +1,2 @@ +; timer functions + diff --git a/led_plex/uart.asm b/led_plex/uart.asm index e7a5830..fbfbf3d 100644 --- a/led_plex/uart.asm +++ b/led_plex/uart.asm @@ -10,51 +10,51 @@ UART_INIT: ; baudrate ldi tmp1,UART_BR_H - sts UBRR0H,tmp1 + out UBRRH,tmp1 ldi tmp1,UART_BR_L - out UBRR0L,tmp1 + out UBRRL,tmp1 ; enable ldi tmp1,(1< 8n1 - ldi tmp1,(1<