From 12dfe92063a52e73ca7522afbf19e7baf0990e41 Mon Sep 17 00:00:00 2001 From: hackbard Date: Thu, 8 Mar 2007 22:27:18 +0000 Subject: [PATCH] clean up + uart tx fix --- hdw-tank/main.asm | 37 ++++++++++++++++++++++----------- hdw-tank/motor.asm | 52 +++++++++++++++++++++++----------------------- hdw-tank/uart.asm | 30 +++++++++++++------------- 3 files changed, 66 insertions(+), 53 deletions(-) diff --git a/hdw-tank/main.asm b/hdw-tank/main.asm index 59787ea..b47c1f8 100644 --- a/hdw-tank/main.asm +++ b/hdw-tank/main.asm @@ -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: diff --git a/hdw-tank/motor.asm b/hdw-tank/motor.asm index 5b630ed..3339c99 100644 --- a/hdw-tank/motor.asm +++ b/hdw-tank/motor.asm @@ -8,56 +8,56 @@ MOTOR_INIT: ; ports -> output - in tmp_motor,DDRB - sbr tmp_motor,(1< 8n1 - ldi uart_rxtx,(1<