; ; test all ports and uart ; .include "../include/m32def.inc" INIT: ; all ports outputs ldi r16,0xff out DDRA,r16 out DDRB,r16 out DDRC,r16 out DDRD,r16 ; uart baudrate (8mhz -> 38.4k) + enable ldi r16,0 out UBRRH,r16 ldi r16,12 out UBRRL,r16 sbi UCSRB,TXEN ; led counter ldi r17,0 ; loop counter ldi r18,0 MAINLOOP: ; reset loop counter ldi r18,0 ; the delay loop LOOP: ; the dely loop in the delay loop ldi r22,0 INNERLOOP: ldi r23,0 IILOOP: inc r23 cpi r23,0x40 brne IILOOP inc r22 cpi r22,0xff brne INNERLOOP ; increase loop counter inc r18 ; check loop counter cpi r18,0xff ; continue if loop counter = 0xff ; else do loop again brne LOOP ; shift the led counter lsl r17 ; set first bit if led counter is equal zero cpi r17,0 brne LEDOUT ldi r17,1 ; drive the leds LEDOUT: ldi r21,0xff sub r21,r17 out PORTA,r21 out PORTB,r21 out PORTC,r21 out PORTD,r21 ; get the number we want to transmit mov r19,r17 ldi r20,0x30 ; ascii 0 GETNUMBER: lsr r19 inc r20 cpi r19,0 brne GETNUMBER ; uart transmit UARTOUT: ; try again if uart not ready sbis UCSRA,UDRE rjmp UARTOUT ; transmit the number out UDR,r20 ; loop forever rjmp LOOP ; eof