;; atmel_rs232 - Copyright 2007 by Michael Kohn ;; Email: mike ta mikekohn.net ;; Web: http://www.mikekohn.net/ ;; ;; Simple example of how to use the UART of an Atmel ATmega168 ;; Tx/Rx on the ATmega168 are connected to a DS275 to convert ;; TTL serial values to rs232 .include "m168def.inc" ; note: CLKSEL 0010 .dseg .cseg ;; Set up stack ptr ldi r16, RAMEND>>8 out SPH, r16 ldi r16, RAMEND&255 out SPL, r16 ;; Set up LED default ldi r18, 2 out PORTB, r18 ; turn on bit 1 ser r17 out DDRB, r17 ; entire port B is output ;; Set up rs232 baud rate ldi r16, 25 ; 25 @ 4MHz = 9600 baud sts UBRR0L, r16 ; 25 @ 8MHz = 19200 baud eor r16, r16 sts UBRR0H, r16 ;; Set up rs232 options ldi r16, (1<>8 call send_string ldi r19, (1<