ATTINY COMPILER


hi everyone!
here request help, know may seem bit strange need someones' ;)

i'm programming attiny2313 using arduino. have written assembly program, unfortunately @ moment cannot have access compiler...

could please kind compile me .asm file , send me .hex??

here specifics :

attiny2313

external clock 10mhz internally divided 8

fuses:
low 0x4f
high 0xdb

please ignore comments in program referred clock speed.

hoping can me,
thanks!

i cannot attach .asm file i'll write code instead ;)

code: [select]



.include "../include/tn2313def.inc"

.def temp = r16
.def temp2 = r17
.def count = r18
.def curchar = r19
.def char = r20

;===============================================================================

.dseg
ram_string: .byte 20

;===============================================================================

.cseg
.org 0x000
rjmp reset

;===============================================================================

.equ charsperline = 18 ;maximum number of chars per line
.equ numchars = 14 ;number of possible chars
firstchar:
.db "e+x:#*stmc= -%"
regularchar:
.db "#0123456789-,."

;===============================================================================

reset:
;set stackpointer end of ram
ldi temp, ramend
out spl, temp

;initialize ports
ldi temp, 0x46
out ddrd, temp
ldi temp, 0x3b
out portd, temp

;enable uart
ldi temp, 1<<txen | 1<<rxen
out ucsrb, temp
ldi temp, 7 ;9600 baud @ 0.9216 mhz
out ubrrl, temp

;initialize registers
ldi yl, ram_string
ldi count, 0

loop:
;get char uart
rcall getc
cpi temp, 0x08 ;<backspace> => delete last char buffer
breq uart_bs
cpi temp, 0x0a ;<lf> => print line
breq print
cpi temp, 0x0d ;<cr> => print line
breq print
cpi temp, 0x20 ;other control char => ignore
brlo loop
cpi count, 18
brsh loop ;overflow => discard char
;regular ascii char: save buffer
st y+, temp
inc count
rjmp loop

uart_bs:
;backspace
cpi count, 0
breq loop
dec count
sbiw yh:yl, 1
rjmp loop

print:
;print string
ldi temp, 0 ;add end marker
st y, temp
ldi yl, ram_string
rcall print_string
;send confirmation uart
ldi temp, 'p'
rcall putc
;reset registers
ldi count, 0
ldi yl, ram_string
rjmp loop

;===============================================================================

getc:
;receive char uart
sbis ucsra, rxc
rjmp getc
in temp, udr
ret

;--------------------

putc:
sbis ucsra, udre
rjmp putc
out udr, temp
ret

;===============================================================================

print_string:
;print string @ yh:yl
sbi portd, 2 ;enable motor
clr count
print_string_length:
;find length of string , move ram pointer end of string
ld temp, y+
cpi temp, 0
breq print_string_start
inc count
cpi count, charsperline+1 ;print first charsperline chars
brlo print_string_length
print_string_start:
;initialize first char (rightmost, using 'firstchar' charset)
cpi count, 0
breq print_string_empty
ldi zl, low(firstchar*2)
ldi zh, high(firstchar*2)
sbiw yh:yl, 1
rcall wait_round
print_string_char:
;find char in printer charset table
ld temp, -y
ldi char, -1
print_string_char_loop:
inc char
cpi char, numchars ;char not found => non-printable char
brsh print_string_char_invalid
lpm temp2, z+
cp temp2, temp
brne print_string_char_loop
print_string_char_print:
;wait until print wheel @ correct position
cp char, curchar
breq print_string_char_now
brsh pc+3
rcall wait_round
rjmp print_string_char_print
rcall wait_start
rcall wait_end
rjmp print_string_char_print
print_string_char_now:
;print char
rcall wait_start
sbi portd, 6 ;enable magnet
rcall wait_end
cpi count, 1 ;last char => line feed
brne pc+2
rcall wait_start
cbi portd, 6 ;disable magnet
rcall wait_end
;initialize next char (using 'regularchar' charset)
ldi zl, low(regularchar*2)
ldi zh, high(regularchar*2)
dec count
brne print_string_char
ldi temp, 128 ;keep motor running ~100ms finish line feed
ldi temp2, 0
print_string_motorwait:
dec temp2
brne print_string_motorwait
dec temp
brne print_string_motorwait
cbi portd, 2 ;disable motor
ret

print_string_empty:
;empty string: print space char line feed
ldi count, 1
sbiw yh:yl, 1
ldi temp, ' '
st y+, temp
ldi temp, 0
st y+, temp
rjmp print_string_start

print_string_char_invalid:
;char not in charset current column: print first charset entry
ldi char, 0
rjmp print_string_char_print

;-------------------

wait_start:
;wait printer "char start" singal
sbis pind, 3
rjmp pc-1
rcall shortdelay
sbic pind, 3
rjmp pc-1
rcall shortdelay
inc curchar
ret

wait_end:
;wait printer "char end" signal
sbic pind, 4
rjmp pc-1
rcall shortdelay
sbis pind, 4
rjmp pc-1
rcall shortdelay
ret

wait_round:
;wait printer "round start" signal
sbis pind, 5
rjmp pc-1
rcall shortdelay
sbic pind, 5
rjmp pc-1
rcall shortdelay
ldi curchar, 0
ret

shortdelay:
;short delay debouncing
ldi temp, 50
shortdelay_loop:
dec temp
brne shortdelay_loop
ret



Arduino Forum > Using Arduino > Programming Questions > ATTINY COMPILER


arduino

Comments

Popular posts from this blog

invalid use of void expresion in FlexiTimer2 library

error: a function-definition is not allowed here before '{' token

LED Strip Code