I am struggleing to get USART communication on-line with a mega8515-16, but all I can read out is garbage, some bytes at around 220-255, I am trying to send "test!#13#10".
I am using Hyperterminal 9600 Baud, Even Parity, No hardware control 1 Stop bit to receive data. I get only part of the data (I can see how fast it should be going with the LED), and garbage :(
Below is my source code, I am currently running on internal oscillator, but as soon as I know what fuse bits to program, i'll move to an external crystal... But I have wasted one of my uC, because of bad fuse bits, and don't wanna waste the other one too :(
Below is my source code:
.include "m8515def.inc"
.def temp = r16
.equ CLOCK = 4000000
.equ BAUD = 9600
.equ UBRRVAL = CLOCK/(BAUD*16)-1
ldi temp, LOW(RAMEND)
out SPL, temp
ldi temp, HIGH(RAMEND)
out SPH, temp
ldi temp, 0xFF
out DDRC, temp
ldi temp, LOW(UBRRVAL)
out UBRRL, temp
ldi temp, HIGH(UBRRVAL)
out UBRRH, temp
; Frame-Format: 8 Bit, Even parity
ldi temp, (1<<URSEL)|(3<<UCSZ0) | (2>>UPM0)
out UCSRC, temp
sbi UCSRB,TXEN
ldi R22,0xFE
ser R23
loop:
inc R22
out PORTC, R22 ; Blink a LED on PORTC0
ldi temp, 'T'
rcall serout
ldi temp, 'e'
rcall serout
ldi temp, 's'
rcall serout
ldi temp, 't'
rcall serout
ldi temp, '!'
rcall serout
ldi temp, 10
rcall serout
ldi temp, 13
rcall serout
rjmp loop
serout:
sbis UCSRA,UDRE
rjmp serout
out UDR, temp
ret