Porting mjoy to ATmega88 (working!)

Go To Last Post
13 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi All,

I'm trying to port MJOY:
http://web.archive.org/web/20070...
from mega8 to mega88.

Firstly, has anyone done this already?

I've attached my source code and unix-diff file (so you can see the changes I made). I think it's all correct, it assembles and flashes, but doesn't communicate with USB correctly. i.e. Windows gives a USB communication error.

I'd really appreciate any help or tips, because it looks like I'm stuck.

Last Edited: Mon. Nov 5, 2007 - 04:15 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Bear in mind that the mega88 ships with the clock set to internal as default. If you want to use an external "crystal" then the correct fuses must be set.
Not setting the fuses correctly will usually result in selecting an external "clock" which won't work with a crystal.Failing to understand how to set fuses properly before doing so is a major reason people post here with tales of 'dead' chips.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Did you check out application note AVR094: Replacing ATmega8 by ATmega88:

http://www.atmel.com/dyn/resourc...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks for the tips.

Obviously I've read AVR094, I couldn't compile the source for a ATmega88 target without changing lots of registers. I went through each bolded item in AVR094 (the registers that changed functionality), and hopefully ported them all correctly.

I think my fuse bits are appropriate:
F7 DF F8 (low, high, ext)
I am measuring 11.99MHz with my el-cheapo multimeter on the XTAL, so that's a good sign.

I was thinking of trying out something like USBtiny, to test if my electronics/wiring is correct. I wonder if someone's ported that to 88.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You don't have to port usbtiny to the mega88, it works with everything I've tried so far without modification.

The only restriction you have is that D+ and D- have to be on the same PORT.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I don't think so MegaTorr, avr-gcc doesn't even support the mega88, so I can't compile it.

This is a whole lot of trouble, time to find a mega8 chip (though they're more expensive)...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

check the sticky tags in the avr-gcc forum, especially the first one. Works rather well, and as of today it has a brand new version too ;).

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You're right MegaTorr, the avr-gcc page didn't list atmega88, it must just be outdated. Editing the Makefiles with -mmcu=atmega88 got USBtiny's SPI program compiled and it works!

Ok, so my bug is purely software (porting mjoy.asm to mega88), time to go over it with a fine-tooth comb.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ok it's solved, I got MJOY working on ATmega88. It was no simple task :) All the problems stem from the fact that the original code uses SRAM 0x60-0xff and never used the HIGH byte in pointers. ATmega88 starts its SRAM from 0x0100, so you really need to worry about ZH/YH/XH/SPH etc.

Will post working source code tomorrow.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

MJOY 88.0
~~~~~~~~~

This is a port of MJOY v1.2 to the ATmega88, a newer, cheaper version of the ATmega8. You can buy it from some online stores for less than $3.

The MJOY website has disappeared from the web, but you can find a archived version here:

http://web.archive.org/web/20070...

The FUSE bits you should use for a ATmega88 are:

Low : F7
High: DF
Ext : FF

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Wow forum bug! That was not Rukus, it was my post!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I was working on the same thing. Mjoy, ATmega8 to Atmega88. You beat me to it. Thank you. It works great. I am using the old 1.1 version of the Schematic just to make sure it worked before I build it into a little home made car for the kids. LOL or maybe me and NASCAR game. LOL thanks again

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

What compiler are you guys using to get this working? I'm getting quite a few errors when compiling with AVR Studio 4.