]> hackdaworld.org Git - my-code/atmel.git/commitdiff
clean up + uart tx fix
authorhackbard <hackbard>
Thu, 8 Mar 2007 22:27:18 +0000 (22:27 +0000)
committerhackbard <hackbard>
Thu, 8 Mar 2007 22:27:18 +0000 (22:27 +0000)
hdw-tank/main.asm
hdw-tank/motor.asm
hdw-tank/uart.asm

index 59787ea3643d527088923581cab3f507f7879ace..b47c1f89f56cf5d4bf6a3e72265e3a7153565224 100644 (file)
@@ -7,9 +7,9 @@
 .include "../include/m128def.inc"
 
 ; defines
-.def   tmp             = r16
-.def   uart_rxtx       = r17
-.def   tmp_motor       = r18
+.def   tmp1            = r16
+.def   tmp2            = r17
+.def   uart_rxtx       = r18
 
 ; interrupts
 jmp RESET 
@@ -54,25 +54,25 @@ jmp SPM_RDY
 RESET:
 INIT:
 
-       ; uart init
-       rcall UART_INIT
-
        ; motor init
        rcall MOTOR_INIT
 
+       ; uart init
+       rcall UART_INIT
+
        ; uart interrupt enable
        rcall UART_INT_RX_INIT
 
        ; set stackpointer
-       ldi tmp,high(RAMEND)
-       out SPH,r16 
-       ldi tmp,low(RAMEND)
-       out SPL,r16
+       ldi tmp1,high(RAMEND)
+       out SPH,tmp1
+       ldi tmp1,low(RAMEND)
+       out SPL,tmp1
 
        ; global interrupt enable
-       sei 
+       ;sei 
 
-       ; debug output
+       ; signal ready output
        ldi uart_rxtx,0x23
        rcall UART_TX
 
@@ -153,28 +153,41 @@ USART0_RXC:
        ; loop back the received byte
        rcall UART_TX
 
+       ;
        ; drive the motor
+       ;
+
+       ; stop it first
        rcall MOTOR_STOP
+
+       ; fwd
        cpi uart_rxtx,CTRL_FWD
        brne CTRL1
        rcall MOTOR_FWD
        rjmp CTRL4
+
+       ; bwd
        CTRL1:
        cpi uart_rxtx,CTRL_BWD
        brne CTRL2
        rcall MOTOR_BWD
        rjmp CTRL4
+
+       ; right
        CTRL2:
        cpi uart_rxtx,CTRL_RIGHT
        brne CTRL3
        rcall MOTOR_RIGHT
        rjmp CTRL4
+
+       ; left
        CTRL3:
        cpi uart_rxtx,CTRL_LEFT
        brne CTRL4
        rcall MOTOR_LEFT
        CTRL4:
 
+       ; return
        reti
 
 USART0_DRE:
index 5b630ed1c429808f7db992729375499bd0117b94..3339c9972e87a1cecbd93d095b2b24b1e0d02114 100644 (file)
@@ -8,56 +8,56 @@
 MOTOR_INIT:
 
        ; ports -> output
-       in tmp_motor,DDRB
-       sbr tmp_motor,(1<<MOT_DIR_L)|(1<<MOT_DIR_R)
-       sbr tmp_motor,(1<<MOT_PWR_L)|(1<<MOT_PWR_R)
-       out DDRB,tmp_motor
+       in tmp1,DDRB
+       sbr tmp1,(1<<MOT_DIR_L)|(1<<MOT_DIR_R)
+       sbr tmp1,(1<<MOT_PWR_L)|(1<<MOT_PWR_R)
+       out DDRB,tmp1
 
 MOTOR_STOP:
 
        ; output zero
-       in tmp_motor,PORTB
-       cbr tmp_motor,(1<<MOT_DIR_L)|(1<<MOT_DIR_R)
-       cbr tmp_motor,(1<<MOT_PWR_L)|(1<<MOT_PWR_R)
-       out PORTB,tmp_motor
+       in tmp1,PORTB
+       cbr tmp1,(1<<MOT_DIR_L)|(1<<MOT_DIR_R)
+       cbr tmp1,(1<<MOT_PWR_L)|(1<<MOT_PWR_R)
+       out PORTB,tmp1
 
        ret
 
 MOTOR_FWD:
 
-       in tmp_motor,PORTB
-       sbr tmp_motor,(1<<MOT_DIR_L)|(1<<MOT_DIR_R)
-       sbr tmp_motor,(1<<MOT_PWR_L)|(1<<MOT_PWR_R)
-       out PORTB,tmp_motor
+       in tmp1,PORTB
+       sbr tmp1,(1<<MOT_DIR_L)|(1<<MOT_DIR_R)
+       sbr tmp1,(1<<MOT_PWR_L)|(1<<MOT_PWR_R)
+       out PORTB,tmp1
 
        ret
 
 MOTOR_BWD:
 
-       in tmp_motor,PORTB
-       cbr tmp_motor,(1<<MOT_DIR_L)|(1<<MOT_DIR_R)
-       sbr tmp_motor,(1<<MOT_PWR_L)|(1<<MOT_PWR_R)
-       out PORTB,tmp_motor
+       in tmp1,PORTB
+       cbr tmp1,(1<<MOT_DIR_L)|(1<<MOT_DIR_R)
+       sbr tmp1,(1<<MOT_PWR_L)|(1<<MOT_PWR_R)
+       out PORTB,tmp1
 
        ret
 
 MOTOR_RIGHT:
 
-       in tmp_motor,PORTB
-       sbr tmp_motor,(1<<MOT_DIR_L)
-       cbr tmp_motor,(1<<MOT_DIR_R)
-       sbr tmp_motor,(1<<MOT_PWR_L)|(1<<MOT_PWR_R)
-       out PORTB,tmp_motor
+       in tmp1,PORTB
+       sbr tmp1,(1<<MOT_DIR_L)
+       cbr tmp1,(1<<MOT_DIR_R)
+       sbr tmp1,(1<<MOT_PWR_L)|(1<<MOT_PWR_R)
+       out PORTB,tmp1
 
        ret
 
 MOTOR_LEFT:
 
-       in tmp_motor,PORTB
-       sbr tmp_motor,(1<<MOT_DIR_R)
-       cbr tmp_motor,(1<<MOT_DIR_L)
-       sbr tmp_motor,(1<<MOT_PWR_L)|(1<<MOT_PWR_R)
-       out PORTB,tmp_motor
+       in tmp1,PORTB
+       sbr tmp1,(1<<MOT_DIR_R)
+       cbr tmp1,(1<<MOT_DIR_L)
+       sbr tmp1,(1<<MOT_PWR_L)|(1<<MOT_PWR_R)
+       out PORTB,tmp1
 
        ret
 
index bb189daa82b482ff214037e62d72061cc604e208..aaa024967465e8a89ff1f6ae0af9c2ca09ea3bfc 100644 (file)
@@ -9,34 +9,34 @@
 UART_INIT:
 
        ; baudrate
-       ldi uart_rxtx,UART_BR_H
-       sts UBRR0H,uart_rxtx
-       ldi uart_rxtx,UART_BR_L
-       out UBRR0L,uart_rxtx
+       ldi tmp1,UART_BR_H
+       sts UBRR0H,tmp1
+       ldi tmp1,UART_BR_L
+       out UBRR0L,tmp1
 
        ; enable
-       ldi uart_rxtx,(1<<RXEN)|(1<<TXEN)
-       out UCSR0B,uart_rxtx
+       ldi tmp1,(1<<RXEN)|(1<<TXEN)
+       out UCSR0B,tmp1
 
        ; frame format -> 8n1
-       ldi uart_rxtx,(1<<UCSZ00)|(1<<UCSZ01)
-       sts UCSR0C,uart_rxtx
+       ldi tmp1,(1<<UCSZ00)|(1<<UCSZ01)
+       sts UCSR0C,tmp1
 
        ret
 
 UART_INT_RX_INIT:
 
-       in uart_rxtx,UCSR0B
-       sbr uart_rxtx,(1<<RXCIE0)
-       out UCSR0B,uart_rxtx
+       in tmp1,UCSR0B
+       sbr tmp1,(1<<RXCIE0)
+       out UCSR0B,tmp1
 
        ret
 
 UART_INT_TX_INIT:
 
-       in uart_rxtx,UCSR0B
-       sbr uart_rxtx,(1<<TXCIE0)
-       out UCSR0B,uart_rxtx
+       in tmp1,UCSR0B
+       sbr tmp1,(1<<TXCIE0)
+       out UCSR0B,tmp1
 
        ret
 
@@ -52,7 +52,7 @@ UART_RX:
 UART_TX:
 
        ; transmit content of uart_rxtx
-       sbis UCSR0A,TXC0
+       sbis UCSR0A,UDRE
                rjmp UART_TX
        out UDR0,uart_rxtx