Hi everyone. First I'd like to introduce myself. I'm a 4th year computer/electrical engineer, doing my thesis project using at Atmel microcontroller.
Ok, now onto the problem.
I'm using the Atmel AT90S2313 microcontroller, and I'm attempting to create a serial connection between it and my PC. I have it hooked up (properly) to a MAX233A chip, which is what provides the bridge between the Atmel and the serial port.
I'm using the STK500 project board for the time being, with PD0 as the receive pin and PD1 as the transmit pin. Everything is hooked up and working as it should, except for the actual serial communication.
I've written a simple program, whose sole purpose is to wait for a character to be received, then echo the same character directly back to the user. Unfortunately, this doesn't work. One of two things happens:
1) The Atmel just transmits garbage continuously, or
2) The Atmel echoes back a COMPLETELY DIFFERENT character than what was sent
I've tried using Hyperterminal, as well as making a Visual Basic project to communicate serially, and neither work.
Here is my program listing:
.nolist .include "2313def.inc" .list .def temp = r16 ; Temporary register ; Set Port B (LEDs) to be output and turn them off ser temp out DDRB,temp out PORTB,temp ; Set up the baud rate to 9600 (based on a 3.69 MHz clock) ldi temp,23 out UBRR,temp ; Enable UART transmit and receive sbi UCR,RXEN sbi UCR,TXEN ; ===== MAIN PROGRAM STARTS HERE ===== loop: sbis USR,RXC ; Wait for character rjmp loop ldi temp,UDR ; Load received char into temp wait: sbis USR,UDRE ; Wait for transmit buffer rjmp wait ; to be free out UDR,temp ; Send that char out rjmp loop
I'm open to any suggestions anyone has. Thanks.