Atmel ATmega168 RS232
I've decided to try out the Atmel microcontrollers to replace the PICMicro I used in a previous project I've been working on and off on.
The purpose of this page is to serve as a journal for what I have working with the ATmega168 already and maybe as a guide for other people wanting to use Atmel microcontrollers for RS232 communication.
Atmel Probe is an extension of this project that allows a user to connect to the Ateml chip with rs232 which provides the user with a command prompt allowing reading and writing of SRAM, I/O ports, EEProm, and flash.
Also, I did a bitbanging of this here if anyone's interested in seeing how this would be done without the hardware UART.
Disclaimer: If you get cut, bruised, burn your house down, get diarrhea, contract herpres, die, or any other undesirable thing while imitating or extending this project, I am not at fault.
To use this circuit/software, it should be hooked up to the com port of a PC. When flashing the ATmega168 chip, the CLKSEL fuses should be fused 0010 so that the ATmega's internal clock is used. It should be wired for 8MHz with no clock divide. The computer's serial port should be set to 8N1 @ 19200 baud.
When the circuit is turned on, it will transmit a copyright message over the serial port. After that every character the Atmel receives over the serial port will cause the LED to toggle and the character will be echo'd back to the source.
My circuit on the breadboard will look a little different than the one in the schematic, mostly in that I have an extra LED that lets me know if there is power on the board and there are two resistors adding up to around 350 instead of just 1. There is also a 4MHz crystal resonator I was originally using, but removed so I could use the 8MHz internal clock instead.
The DS275 chip is used to change TTL voltages (0v = 0, 5v = 1) to RS232 voltages (-5v = 1, +5v = 0). This part of the circuit can be replaced with an ugly and more complex MAX232 chip (along with 5 capacitors).
If you are using a NULL modem cable instead of a straight through cable to the computer, connect pin 3 of the 9pin connector to TXout and pin 2 to RXin instead of the way my schematic wires it.
Warning: This code is written for the ATmega168. This processor memory maps the UART registers into SRAM. Other Atmel chips might need in/out instructions instead. Using this as a guide it should be pretty simple.
Well, I must say the ATmega168 is a really freakin' cool chip. I like this so much better than the PICMicro so far. The assembly language is so much more friendly. This is definitely my new microcontroller of choice.
Copyright 1997-2021 - Michael Kohn