From: hackbard Date: Sun, 4 Mar 2007 23:29:12 +0000 (+0000) Subject: should work now, of course it does not! X-Git-Url: https://hackdaworld.org/gitweb/?a=commitdiff_plain;h=ebc6337dea06a5abd94de3794352accb573e22ec;p=my-code%2Fatmel.git should work now, of course it does not! --- diff --git a/hdw-tank/main.asm b/hdw-tank/main.asm index e1ee14d..59787ea 100644 --- a/hdw-tank/main.asm +++ b/hdw-tank/main.asm @@ -3,8 +3,13 @@ ; author: hackbard@hackdaworld.org ; +; device specific definition file +.include "../include/m128def.inc" + ; defines -.define tmp = r16 +.def tmp = r16 +.def uart_rxtx = r17 +.def tmp_motor = r18 ; interrupts jmp RESET @@ -43,27 +48,43 @@ jmp USART1_TXC jmp TWI jmp SPM_RDY -; include subroutines -.include "motor.asm" -.include "uart.asm" +; include control defines +.include "ctrl.def" RESET: INIT: - ; motor init - call ; uart init + rcall UART_INIT + + ; motor init + rcall MOTOR_INIT + + ; uart interrupt enable + rcall UART_INT_RX_INIT ; set stackpointer - ldi r16, high(RAMEND) + ldi tmp,high(RAMEND) out SPH,r16 - ldi r16, low(RAMEND) + ldi tmp,low(RAMEND) out SPL,r16 ; global interrupt enable sei + ; debug output + ldi uart_rxtx,0x23 + rcall UART_TX + +MAIN: + + ; loop forever + rjmp MAIN + +; include subroutines +.include "motor.asm" +.include "uart.asm" ; @@ -71,71 +92,54 @@ INIT: ; EXT_INT0: - nop reti EXT_INT1: - nop reti EXT_INT2: - nop reti EXT_INT3: - nop reti EXT_INT4: - nop reti EXT_INT5: - nop reti EXT_INT6: - nop reti EXT_INT7: - nop reti TIM2_COMP: - nop reti TIM2_OVF: - nop reti TIM1_CAPT: - nop reti TIM1_COMPA: - nop reti TIM1_COMPB: - nop reti TIM1_OVF: - nop reti TIM0_COMP: - nop reti TIM0_OVF: - nop reti SPI_STC: - nop reti USART0_RXC: @@ -143,71 +147,81 @@ USART0_RXC: ; read received byte and drive the motor ; in addition, loop it back to the host - in UDR + ; receive routine (byte stored in uart_rxtx) + rcall UART_RX + + ; loop back the received byte + rcall UART_TX + + ; drive the motor + rcall MOTOR_STOP + cpi uart_rxtx,CTRL_FWD + brne CTRL1 + rcall MOTOR_FWD + rjmp CTRL4 + CTRL1: + cpi uart_rxtx,CTRL_BWD + brne CTRL2 + rcall MOTOR_BWD + rjmp CTRL4 + CTRL2: + cpi uart_rxtx,CTRL_RIGHT + brne CTRL3 + rcall MOTOR_RIGHT + rjmp CTRL4 + CTRL3: + cpi uart_rxtx,CTRL_LEFT + brne CTRL4 + rcall MOTOR_LEFT + CTRL4: reti USART0_DRE: - nop reti USART0_TXC: - nop reti ADC: - nop reti EE_RDY: - nop reti ANA_COMP: - nop reti TIM1_COMPC: - nop reti TIM3_CAPT: - nop reti TIM3_COMPA: - nop reti TIM3_COMPB: - nop reti TIM3_COMPC: - nop reti TIM3_OVF: - nop reti USART1_RXC: - nop reti USART1_DRE: - nop reti USART1_TXC: - nop reti TWI: - nop reti SPM_RDY: - nop reti diff --git a/hdw-tank/motor.asm b/hdw-tank/motor.asm index 9386180..5b630ed 100644 --- a/hdw-tank/motor.asm +++ b/hdw-tank/motor.asm @@ -1,67 +1,63 @@ ; motor functions -;include "../include/m128def.inc" - .equ MOT_DIR_L = 0x02 .equ MOT_DIR_R = 0x03 .equ MOT_PWR_L = 0x04 .equ MOT_PWR_R = 0x07 -;.def tmp = r17 - MOTOR_INIT: ; ports -> output - in tmp,DDRB - sbr tmp,(1< 8n1 + ldi uart_rxtx,(1<