AVR homebrew device with iPhone aspirations

Can you make an iPhone out of an AVR? No. Can you get a surprising amount of functionality out of a humble 8 bit processor and a cheap touch LCD? Yes.

The iPhone runs more than 30 times faster (417Mhz ARM vs 12Mhz AVR) and has more than 30,000 times as much ram RAM (128M vs 4k) yet this frumpy little device can ape some of the iPhones neater tricks.

Hardware
320×240 LCD with 4 wire resistive touch screen – a ELT240320ATP variant from a dead Sylvania MP3 player – uses a ILI9325 controller.
12Mhz Atmega644 CPU with 64k Flash and 4k RAM – demo fits in 32k.
USB connector for PC communication and charging.
Lithium polymer battery with software controlled power.
Software controlled backlight.
SD Micro slot.

Software
LCD driver to support blitting image decompression and smooth scrolling.
Z-sorted span 3D engine with zero overdraw.
Basic UI framework for gadgets and poorly drawn pictures.
USB mouse or keyboard HID support.
Sampling profiler.
Movie playback.
Sprite engine.

Tricky Bits
4K of RAM might sound like a lot but it isn’t. Getting a 3D renderer to fit comes down to the representation of the active triangle edges – this engine uses 16 bytes for a double sided edge so you can have lots of triangles on a horizontal scanline and still run the whole thing in 8k of Flash and 512 bytes of RAM.

Pacman just fits in 8K flash and 512 bytes of RAM. It uses the sprite engine and runs at > 60fps.

None of the images or animations ever linger in RAM, the go straight from the SD card to the screen. The SD card is a wonderful alternative to RAM. Reading a 512 byte block takes ~1ms; not snappy but plenty fast enough for human interation.

At 3.3v, the Atmega644 is limited to about 12Mhz. Pretty pokey when you consider you can buy a  50Mhz ARM Cortex-M3 with the same flash and ram for about 1/3 as much as the 644. Don’t get me wrong; I love the Atmel parts but a little more CPU would not go astray.

Source
Source code, demo files, Eagle PCB and schematics at https://sourceforge.net/projects/microtouch/

Advertisement

46 thoughts on “AVR homebrew device with iPhone aspirations

  1. Anonymous

    Realy impressive! Real nice job. Im sure a bit more CPU speed and ram would go a long way… I normaly use PIC18f series. 48mhz for dirt cheap + usb.

    Reply
  2. Anonymous

    Nice results, have you considered dropping the AVR and moving up to the big boys, say an ARM core like the AT91SAM7S, 50+ MHz, 512K FLASH, 64K RAM, only costs $10 for the chip, free C/C++ compilers. It’s real easy to get started with that, not as scary as it might sound 🙂

    Reply
  3. Anonymous

    Hi,

    Very interesting project you got there! If you’re interested in a bit more power and space, we could work something out. I dev hardware so if you’re interested, leave me a message.

    Reply
  4. rossum

    I will always have a soft spot in my heart for Atmel 8 bit cpus and their role in introducing so many people to the delights of making things with microcontrollers. The Atmega644 in the current version of the microtouch makes little sense and is not high on the AVR price performance graph (much cheaper AVRs run the same demo). There is no practical reason not to use an ARM but I do love the 8 bit beasties so.Don’t get me wrong, I have liked ARM since writing code on the 3DO in ’93. About 5B ARM cores will ship this year and there are lots of really well appointed, cheap choices for ARM starting at about $2. There are even M1 softcores that fit in $10 FPGAs. My next project is ARM based. I just feel a little guilty.I gotta admit AT91SAM7S is a really fun part; but what would I do with all that memory? Run an operating system? After all look where that got Microsoft. If they had just stuck to 64k…..

    Reply
  5. cifo

     Thank you very much, I would really appreciate it. I promise I will use it and write a post on it in my blog: http://timewitharduino.blogspot.com/ (I actually have a board developed around ATmega644 which I also use as the “motherboard” for an uzebox.)   —– Original Message —– From: Comment to Posterous To: florin@cifo.com Sent: Tuesday, November 03, 2009 10:55 PM Subject: Posterous (rossum) | AVR homebrew device with iPhone aspirations — Reply above this line to comment on this post — rossum just commented on the post “AVR homebrew device with iPhone aspirations” on rossum’s posterous No kits but I can send you a pcb if you promise to use it 😉 Sent from my iPhone Posterous is the place to post everything. Just email us. Change my email settings or unsubscribe »

    Reply
  6. Anonymous

    I think this is an amazing project. You should seriously consider making a kit out of this.

    Thanks,

    Dhananjay V. Gadre

    Reply
  7. Anonymous

    A lot of people don’t seem to get it. If he wanted to write this demo for an ARM processor, then he might as well have just written it for the iPhone in the first place. That way, he could’ve spent the next five years authoring the code and demo content, and nobody would have noticed.

    Reply
  8. Anonymous

    Wow, this project is AWESOME! Thanks very much for sharing! Any cheap source for that same LCD? I’ve always wanted to make a picture frame using simple AVR (instead of a little arm board running linux)

    Reply
  9. rossum

    The screen is ~$10 in China, CPU ~$7.50, Lipo is ~$5, 2 layer PCB is homemade ($2.50 in production), < $5 for everything else. So call it a $30 BOM in small volumes. I gutted dead Sylvania SMPK8854B mp3 players. The B is important; not all Sylvania players have the right LCD.I am working on a rev. 2 board that I will turn into a kit if there is enough interest.

    Reply
  10. elektra

    Hi rossum, This is an excellent work, I would like to implement one, but there is little information regarding components, please could publish the list of materials (BOM)

    Reply
  11. Anonymous

    Very nice demo.
    Have you considered trying to use an AVR32 device instead of ARM? Don’t know how they compare on price, but I think the AVR32 should give you more CPU power.

    Reply
  12. Anonymous

    Hi, andd WOW! very interesting use of Atmega processor, Can you please provide me with a PCB(in your post you offered pcb to another person) aswell as a parts list. thanks,

    Any chance of making a kit and selling?

    Reply
  13. jeffhardy15

    Thank you for the great web site – a true resource, and one many people clearly enjoy thanks for sharing the info, keep up the good work going….

    high school education , get high school diploma , divorce plan for men , christian school online

    Reply
  14. Sivakumar Tumma

    Really awesome work…..
    I tried to do implement this one from the repository given. But have some issues with it, Can you clarify those?

    Reply
  15. rossum

    Cheapest and easiest place to get the screen is to search ebay for SYLVANIA SMPK8854B, a touch mp3 player that commonly shows up as is. I have bought them for $1 to $10 + shipping. Just make sure the LCD isn’t cracked. You also get a LiPo cell, connectors etc. For example, right now there are 9 with zero bids at $1 + $13 shipping that will expire in the next 24 hours. I have seen them in China for as little as $8 but shipping and translation makes getting them a little tricky.

    Reply
  16. Anonymous

    wow that is much cheaper. So you title the post as “AVR homebrew device with iPhone aspirations” have you ever thought about adding a cellular module such as the GM862 from Telit to make give it cellular communications?

    I’ve been working for some time on a custom cell phone design. Until I saw the capability of your system I was planning on a system based on Android and a high end processor. Now i’m thinking about a smaller processor maybe a little more powerful then yours to do the job.

    Also, what can we expect in 2.0?

    Reply
  17. rossum

    2.0 is smaller, faster and cheaper with a few more hardware features – probably January.3.0 is the really interesting one ;-).

    Reply
  18. Anonymous

    Very nice job ! I love it !
    If you need more calculation power from Atmel CPUs, keeping your existing AVR tools, I recommend you to move to Atmel AVR32 UC3 devices. UC3B could be a perfect fit for your project.

    Reply
  19. Anonymous

    Hi.
    Very nice project indeed!
    I have send you an email with some questions, I hope you will answer them.

    Best regards
    Thomas Jespersen

    Reply
  20. Anonymous

    Hi,
    First of, nice work. Really. I have played with one of the crystalfontz LCDs with the same controller and i can’t figure out how you are getting the smoothness on the display at all.

    I was hoping i could pick your brain for some tips etc. I’m using an XMega running at 32MHz so that should outperform a 12MHz 644 (although the IO is a bit slow on the xmegas)

    When i go to update a screen it takes a VERY long time and was wondering how you get your sprites etc to run so smoothly. I’m guessing your pictures and ebook reader functions simply rely on the build in pixel shift so you can update the whole screen without it looking glitchy like mine.

    I had a quick look through your code but i can’t see any reason why your code runs faster than mine as even just changing all the pixels on the screen takes (from memory) 86 or 150ms… let along doing some math ect to draw lines and write text to the screen. My functions for sending commands and data to the LCD have less code and set multiple control lines in one operation rather than clearing CS, RS and WR in 3 lines as per your code (WriteLcdRegAddress in LCD.cpp)

    How do you get the speed, what is your secret? Care to share? I would really like my project to work better. It has done what it needs to, and that is get me an A for my final project for university, but i really want to get it working better just for personal satisfaction haha.

    If you have any hints/tips/clues, please let me know. Sorry for the massively long message too… My email is neilvangeffen at gmail . com

    Again, amazing. Blown away!

    Neil

    Reply
  21. Torby

    Yikes. You’ve been badly spammed.
    Just surfing around and I found your excellent project doing what I’ve been struggling with, and it’s an old project from years ago!
    I can write the pixels in any color, but somehow can’t find any correct mapping to the GRAM address. I can color the pixels in the top and bottom edges, but not in a square section of the middle. Any suggestions? Thanks for all the code!

    Reply
  22. Pingback: Magic with an 8-bit microcontroller « ramblings

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s