Tag Archives: AVR

Atmel retiring ATmega48/88/168 microcontrollers

Atmel AVR Microcontrollers - Mature Devices

Has anyone else noticed that the ATmega48/88/168 family of 8-bit AVR microcontrollers recently joined Atmel’s “mature devices” list, shown above?

Truthfully, I was not surprised to see this, having been tipped off by an Atmel sales rep earlier this year at ESC in San Jose.

The good news is that while these much-loved ATmega devices are slowly being obsoleted, they are being replaced by the largely-identical ‘PA’ series, which includes the ATmega48PA, ATmega88PA, ATmega168PA, and the ATmega328P.  The ‘PA’ devices are enhanced versions of the former ‘P’ series, which added energy-saving picoPower functionality to the original devices.

Porting code to the new family should be fairly straightforward given that the PA family is designed to be a drop-in replacement.  To help with the switchover, Atmel has released some migration notes, including AVR512, “Migration from ATmega48/88/168 to ATmega48P/88P/168P” and AVR528, “Migrating from ATmega48/88/168 and ATmega48P/88P/168P to ATmega48PA/88PA/168PA“.  Regardless, check your header files and fuse bits for any changes.

If you are anxious about switching devices, don’t panic, the ATmega48/88/168 devices are still in stock at all major distributors, while the PA devices aren’t even on the radar yet.  While professionals might want switch AVRs for new designs, hobbyists will likely still be using the older devices for years to come.  (Long live the PIC16F84!)

Building a Wifi Radio – Part 9, A Few Odds and Ends

This is the ninth part of an ongoing series about building a low cost, open source streaming internet radio based on the ASUS WL-520gU Wireless Router.  If you haven’t already, check out the previous parts (see the links at the end of this article) for some background about the project.

In part eight, we added a tuning control for the radio.  Now we can change to any of ten preset stations on the radio by adjusting the position of a potentiometer connected to our AVR microcontroller.   The LCD display we built in part seven lets us know what stream we’re listening to and the artist and title of the current song.  This project is coming together very nicely!

Before we put the final touches on this project in part ten, there are a few miscellaneous chores to take care of:

Fixing /etc/config/wireless:

Last time, we tweaked /etc/config/network to assign a static IP address to the LAN (ethernet) ports of the router.  This allowed us to directly connect a computer to the router via an ethernet cable and get a shell prompt, regardless of the state of the serial console or the wireless connection of the router.  Unfortunately, I made an omission in the setup instructions which may prevent this from working correctly.

To fix this, modify /etc/config/wireless as follows (changes are in bold, use your wireless network information in place of my example):

config wifi-device  wl0
    option type     broadcom
    option channel  3

    # REMOVE THIS LINE TO ENABLE WIFI:
    # option disabled 1

config wifi-iface
    option device   wl0
    option network  wan
    option mode     sta  # configures the router to connect to your network
    option ssid     MyNetwork # the SSID of your network
    option encryption wep  # the encryption mode of your network
    option key	XXXXXXXXXX  # add this line with your WEP key in place of X...X

The only change is to set “option network” to “wan” instead of “lan”.  This minor change tells the router to separate the wireless interface of the router from the LAN/ethernet interface and allows the router to acquire two separate IP addresses, one for each interface.

Launching mpd automatically at startup:

Manually launching mpd every time the router boots is a drag.  You can automate this by creating a symbolic link to /etc/init.d/mpd from the /etc/rc.d directory, as follows:

root@OpenWrt:~# ln -s /etc/init.d/mpd /etc/rc.d/S93mpd

Now every time the router boots, mpd will be started automatically as part of the boot process.  (That was easy!)

Boot script for the user interface:

Assuming we want a dedicated internet radio that doesn’t require user intervention to operate, the scripts for the LCD display and tuning control should also be launched at startup.  This will ensure that upon applying power, the radio will boot into a state where a stream is playing and the user interface is active.

First, we need to create a simple boot script.  Create the file /etc/init.d/AVR with the following contents:

#!/bin/sh /etc/rc.common
# Copyright (C) 2008 OpenWrt.org
START=99
start() {
sleep 5    # make sure boot process is done, no more console messages
/root/interface.sh
}

To launch the script at boot, create a symbolic link as follows:

root@OpenWrt:~# ln -s /etc/init.d/AVR /etc/rc.d/S99AVR

Every time the router boots, the user interface will automatically start, mpd will start playing the selected stream based on the tuner position, and the AVR microcontroller (assuming it is still connected to the serial port) will update the LCD display and watch the potentiometer for any changes in position.

Tweaking the firewall configuration:

This is actually optional, but it can be pretty useful while hacking on the router.  As presently configured, the router blocks incoming requests on the WAN, which now includes the wireless interface.  This prevents us from using ssh or telnet to log into the router over our wireless network.  While we can still get a shell by connecting an ethernet cable to one of the LAN ports on the router, it is often more convenient to access the router across your wireless network.

The file /etc/config/firewall controls the firewall settings.  We’ll be modifying this file.

Open the file in vi and scroll down to this section:

config zone
    option name        wan
    option input    REJECT
    option output    ACCEPT
    option forward    REJECT
    option masq        1

Edit the “option input” line so that it looks like this:

config zone
    option name        wan
    option input    ACCEPT
    option output    ACCEPT
    option forward    REJECT
    option masq        1

Now restart the firewall (or just reboot the router):

root@OpenWrt:~# /etc/init.d/firewall restart

You should now be able to ssh or telnet into the router over your wireless network.

Enable SSH:

By the way, if you want to access the router with ssh instead of telnet, just set a root password.  The telnet daemon will be disabled (for security reasons) and replaced with an SSH daemon instead.  You can do this with the “passwd” command.

root@OpenWrt:~# passwd
Changing password for root
New password: *****
Retype password: *****
Password for root changed by root
root@OpenWrt:~#

Log out of your telnet session and use ssh to log back in with your favorite ssh client (don’t forget to tell the client to use the username “root”).

Stay tuned!

Wifi Radio Enclosure - Google Sketchup Model

That’s it for now.  Stay tuned for the final part in this series, part ten, in which I’ll talk about what it took to turn this Sketchup model into a real wooden case for the radio!

Update: Part ten (the final part in the series) is now online.

AVR, Eclipse and the Mac

Pete Harrison at Micromouse Online wrote a short tutorial about using Eclipse to program AVRs.   Eclipse is  an open source IDE that is supported on many platforms, including OS X on the Mac.

I have never used Eclipse myself, so I can’t vouch for how well this works, but I would like to upgrade from the command line tools I am using (part of AVRMacPack, which is now called CrossPack).  I could use Apple’s Xcode but last time I checked, the AVR integration in Xcode wasn’t that great.

Is anyone using Eclipse for AVR development? What do you like/dislike about it?

AVR, Eclipse and the Mac | Micromouse Online

Space Invaders Button


Marcus at Interactive Matter made this awesome space invaders button, inspired by Alex Weber’s 64pixels project.  It uses almost entirely SMT components and an ATmega164P microcontroller.

The PCB layout is gorgeous!

Marcus provides schematics, source code, and some helpful notes about surface mount soldering. I really like to see SMT projects like these popping up, proving that with the right tools, through hole packaging is no longer a necessity for DIY!

Space Invaders Button | Interactive Matter.