| Author | Topic: Problem with MMC2IEC - EDIT3: SOLVED! IT WORKS! (Read 1,935 times) |
antabaka Junior Member
  member is offline
Joined: Oct 2006 Posts: 52
|  | Problem with MMC2IEC - EDIT3: SOLVED! IT WORKS! « Thread Started on Jun 16, 2007, 8:50pm » | |
Hi,
I built a MMC2IEC using a ATMega32 DIL. I flashed it with the v08 firmware.
Upon booting the two LEDs flash. LOAD"<<",8 results in 0 FAT16 OK.
LOAD"$",8 results in FILE NOT FOUND ERROR. Error Channel delivers 74 DRIVE NOT READY.
The used cards (one MMC, one SD) work fine in my other three MMC2IECs.
Any ideas what the problem could be?
EDIT: I think it has to do with either the SDCARD_DETECT or the SDCARD_WP. I think I have not connected these at all... would mean that SDCARD_DETECT is never put to GND, thus never realizing that there is a Card present.
But why does the LOAD"<<",8 result in OK then?
EDIT2: Yep, it was the SDCARD_DETECT... now everything works fine so far.
*phew*
Learned a lot today 
- Don't trust your electronics dealer (received a 5V version of the ATMega instead of the ordered 3,3V version) - How to reset Lockbits - How to cope with rising levels of frustration. It is now almost 5am here. I spend the last 5 hours troubleshooting on this thing...)
| |
|
antabaka Junior Member
  member is offline
Joined: Oct 2006 Posts: 52
|  | Re: Problem with MMC2IEC - EDIT2: New Problem! « Reply #1 on Jun 17, 2007, 2:44pm » | |
Shadowolf reminded me that while switching the voltage for the Mega32 from 3,3v to 5v may have solved that particular problem it also probably resulted in new ones.
Namely the output levels from the Mega32 towards the SD-Card. CARD_SELECT, DATA_IN and SCLOCK would get 5V HIGH signals instead of 3,3v ones and since the Cards are only verified to up to 3,6v this could mean problems.
So I looked at possible fixes for this.
Seems like you either use a 5v Mega32 and use potential dividers for the SD-Card connections (like Shadowolf) or you use a 3,3v Mega32 but then you need level shifters towards the C64 (like Lars' C64 version).
I opted to use the potential dividers. I went with a 1,8k to 3k split, resulting in 3,125v. (the picture shows 3,3k, but I didnt have any at hand)
However, now the MMC2IEC is no longer functioning at all.
Without a card everything looks ok. The LEDs flash and LOAD"<<",8 results in either 0 ERROR: SD/MMC or 0 ERROR: FILE SYSTEM.
Booting with a card inserted looks bad. The LED01 (access) begins to shine after a few seconds and sometimes flickers alot. LOAD "<<",8 results in ?DEVICE NOT PRESENT ERROR.
Booting without a card and then inserting it looks bad as well. Sometimes the green LED just stays lit. LOAD"<<",8 locks the system. LOAD"$",8 results in FILE NOT FOUND.
What did I do wrong here?
![[image] [image]](http://www.pitsch.de/stuff/mmc2iec/MMC2IEC_antabaka.gif)
Shadowolf also mentioned that the internal oscillator of the Mega32 would be running differently then the software expects due to the higher voltage. Could that be the problem? But if so - why did it work without the potential dividers?
| |
|
spiff Senior Member
    member is offline
![[avatar] [avatar]](http://symlink.dk/spiff/spiff.png)
![[homepage] [homepage]](http://s2.images.proboards.com/buttons/www_sm.gif) Joined: Sept 2006 Gender: Male  Posts: 353 Location: Virum, Denmark
|  | Re: Problem with MMC2IEC - EDIT2: New Problem! « Reply #2 on Jun 17, 2007, 3:39pm » | |
Quote:Namely the output levels from the Mega32 towards the SD-Card. CARD_SELECT, DATA_IN and SCLOCK would get 5V HIGH signals instead of 3,3v ones and since the Cards are only verified to up to 3,6v this could mean problems.
So I looked at possible fixes for this.
Seems like you either use a 5v Mega32 and use potential dividers for the SD-Card connections (like Shadowolf) or you use a 3,3v Mega32 but then you need level shifters towards the C64 (like Lars' C64 version). |
|
True. I have discussed this issue with Lars, and the primary reason for putting the level conversion on the C64 side is that the communication on the IEC-bus is running at a much lower frequency than the SPI for the SD-card. Also, the IEC uses open drain I/O-lines, and so is very easy to do the level conversion on with just a single FET per line.
Quote:I opted to use the potential dividers. I went with a 1,8k to 3k split, resulting in 3,125v. (the picture shows 3,3k, but I didnt have any at hand)
However, now the MMC2IEC is no longer functioning at all.
What did I do wrong here? |
|
As far as I can see, this seems right.
Quote:Shadowolf also mentioned that the internal oscillator of the Mega32 would be running differently then the software expects due to the higher voltage. Could that be the problem? But if so - why did it work without the potential dividers? |
|
While it is true that the internal oscillator does run at slightly different speeds when the supply voltage is changed, this should only affect the overall speed by about 0.2MHz, and AFAIK Lars has tested the timing of the MMC2IEC to work anywhere in the range 7-9MHz at least, so I really don't think this is the problem here.
|
Mikkel Holm Olsen AKA Spaceman Spiff |
|
antabaka Junior Member
  member is offline
Joined: Oct 2006 Posts: 52
|  | Re: Problem with MMC2IEC - EDIT2: New Problem! « Reply #3 on Jun 17, 2007, 4:37pm » | |
Hm, now the funny thing is . without the potential dividers it worked fine. I must have used a 5v-tolerant Card I guess?
I am hesitant to desolder the dividers again and recheck...
Shadowolf gave me a recompiled binary for a 5V Mega32, but that didn't help wither so, yes, we can rule out the timing problems, I think.
| |
|
antabaka Junior Member
  member is offline
Joined: Oct 2006 Posts: 52
|  | Re: Problem with MMC2IEC - EDIT2: New Problem! « Reply #4 on Jun 17, 2007, 4:48pm » | |
Quote:| I am hesitant to desolder the dividers again and recheck... |
|
I desoldered and am back at square one.
Now the LOAD"<<",8 gives me a satisfactory 0 FAT 16 OK. LOAD"$",8 loads the directory. Everything fine.
However, I need to do the LOAD"<<",8 before the directory or it doesnt work. So the card does not get automatically selected, but v0.8 is supposed to do that. Hm. If the card is inserted upon boot up everything woks fine right away.
I do have CARD_DETECT and WRITE_PROTECT switched here, but in the end (with an MMC card) both end up on GND, so it shouldn't matter?
And the potential dividers are not there anymore so it seems to an unconnected problem.
| |
|
tixiv Newbie
 member is offline
Joined: May 2006 Posts: 10
|  | Re: Problem with MMC2IEC - EDIT2: New Problem! « Reply #5 on Jun 19, 2007, 6:28am » | |
I opted to use the potential dividers. I went with a 1,8k to 3k split, resulting in 3,125v. (the picture shows 3,3k, but I didnt have any at hand)
These Resistor values are much to high, to work with fast signals as on the MMC-card lines. Tha parasitic capacitances on the lines are going to ruin everything.
Better use something more low ohmisch, like 120 Ohms and 220 Ohms!
| |
|
antabaka Junior Member
  member is offline
Joined: Oct 2006 Posts: 52
|  | Re: Problem with MMC2IEC - EDIT2: New Problem! « Reply #6 on Jun 19, 2007, 7:41am » | |
Quote:These Resistor values are much to high, to work with fast signals as on the MMC-card lines. Tha parasitic capacitances on the lines are going to ruin everything. Better use something more low ohmisch, like 120 Ohms and 220 Ohms!
|
|
OK, now I am confused 
Shadowolf told me the exact opposite - that I should use higher ohm values (he uses a divider with 4,7k to 6,8k). I don't really know much about parasitic capacitances, I must admit 
1,8k to 3,3k seemed to work for this guy though (picture) - it's where I got my idea from.
But ok, I can solder a divider with lower resitances and try again... just need to find suitable resistors...
| |
|
gmoon Wizard's Apprentice
     member is offline
![[avatar] [avatar]](http://home.earthlink.net/~dgdtv/images/jaw.jpg)
![[homepage] [homepage]](http://s2.images.proboards.com/buttons/www_sm.gif) Joined: Mar 2006 Gender: Male  Posts: 876 Location: Ohio, USA
|  | Re: Problem with MMC2IEC - EDIT2: New Problem! « Reply #7 on Jun 19, 2007, 7:55am » | |
Quote:[blockquote]These Resistor values are much to high, to work with fast signals as on the MMC-card lines. Tha parasitic capacitances on the lines are going to ruin everything.
Better use something more low ohmisch, like 120 Ohms and 220 Ohms! |
|
*stumbles into conversation*
The voltage divider approach seems a bit of a kludge.
(removed comment--thought it was the idc bus...)
On an spi bus, the current's coming from pullups in the AVR, right? You might need the lower resistance divider. Excessive current shouldn't be a problem, due to the source (pullups.)
Have to tried the Mega32 @ 3.3v, since many seem to work at the lower voltage (despite the specs)?
| |
|
tixiv Newbie
 member is offline
Joined: May 2006 Posts: 10
|  | Re: Problem with MMC2IEC - EDIT2: New Problem! « Reply #8 on Jun 19, 2007, 8:13am » | |
On an spi bus, the current's coming from pullups in the AVR, right? You might need the lower resistance divider. Excessive current shouldn't be a problem, due to the source (pullups.)
That's not right. The SPI bus is not like an I2C bus. The current comes from push/pull outputs in the AVR (and from the card on the line data out). Excessive Current might be a problem with to low resistors, but the values I have given should be o.k..
| |
|
gmoon Wizard's Apprentice
     member is offline
![[avatar] [avatar]](http://home.earthlink.net/~dgdtv/images/jaw.jpg)
![[homepage] [homepage]](http://s2.images.proboards.com/buttons/www_sm.gif) Joined: Mar 2006 Gender: Male  Posts: 876 Location: Ohio, USA
|  | Re: Problem with MMC2IEC - EDIT2: New Problem! « Reply #9 on Jun 19, 2007, 8:22am » | |
Quote:That's not right. The SPI bus is not like an I2C bus. The current comes from push/pull outputs in the AVR (and from the card on the line data out). Excessive Current might be a problem with to low resistors, but the values I have given should be o.k.. |
|
Interesting, just looked at diagram that showed three SD/MMC cards connected in parallel, hence my assumption...
If that's the case, each divider would draw ~ 15 mA (5/340 ohms, 45 total), which is rather excessive. Intermittent, though.
| |
|
tixiv Newbie
 member is offline
Joined: May 2006 Posts: 10
|  | Re: Problem with MMC2IEC - EDIT2: New Problem! « Reply #10 on Jun 19, 2007, 12:13pm » | |
Quote: Interesting, just looked at diagram that showed three SD/MMC cards connected in parallel, hence my assumption...
|
|
Well, thats perfectly o.k. if every card has its own CS line, because every spi-device tristates its data-out while the CS is not asserted. The other lines are all from master->slave.
Quote: If that's the case, each divider would draw ~ 15 mA (5/340 ohms, 45 total), which is rather excessive. Intermittent, though.
|
|
But 15 per pin/45mA in total is perfectly o.k. with the AVR - it can do about 40mA on each pin, 100mA per port, and 200mA per package. At least that is, what Atmel says.
I have drawn an entire Ampere through an AVR once by mistake, and it survived(although it got quite hot...).
| |
|
antabaka Junior Member
  member is offline
Joined: Oct 2006 Posts: 52
|  | Re: Problem with MMC2IEC - EDIT2: New Problem! « Reply #11 on Jun 19, 2007, 12:41pm » | |
Quote:| Have to tried the Mega32 @ 3.3v, since many seem to work at the lower voltage (despite the specs)? |
|
At 3.3v I couldn't program the ATMega, which is why I have it on 5V now. I could try programming at 5V and running at 3,3V though, but it seems rather excessive to switch the powerline everytime I want to reflash.
I think I'll try the lower resistor values next. Just need to find them in my spare junk or go and buy some.
120 and 220 Ohm, hm? How high could I go, you think? 220/390 Ohm (~3.2V? Or rather 150/330 (~3.43V)? I have those, I think.
| |
|
gmoon Wizard's Apprentice
     member is offline
![[avatar] [avatar]](http://home.earthlink.net/~dgdtv/images/jaw.jpg)
![[homepage] [homepage]](http://s2.images.proboards.com/buttons/www_sm.gif) Joined: Mar 2006 Gender: Male  Posts: 876 Location: Ohio, USA
|  | Re: Problem with MMC2IEC - EDIT2: New Problem! « Reply #12 on Jun 19, 2007, 1:22pm » | |
It's interesting info about the spi bus, but I've never worked with one before (other than nojoopa's PSX driver...)
I've been sitting on an ATmega32L for two months, waiting for time to mod again...hence my busting into the thread.
Quote:But 15 per pin/45mA in total is perfectly o.k. with the AVR - it can do about 40mA on each pin, 100mA per port, and 200mA per package. At least that is, what Atmel says.
I have drawn an entire Ampere through an AVR once by mistake, and it survived(although it got quite hot...).
|
|
I'm not questioning if the hardware can take it, just that it's excessive to devour 45 mA for a level conversion when the other MMC2IEC components probably only use 3 to 5 mA.
Clearly not the approach for battery op mods...
| |
|
shadowolf Junior Member
  member is offline
Joined: Aug 2006 Gender: Male  Posts: 97 Location: near Braunschweig/Germany
|  | Re: Problem with MMC2IEC - EDIT2: New Problem! « Reply #13 on Jun 19, 2007, 1:39pm » | |
Well, I have the third working MMC2IEC here myself now with voltage dividers of 4k7/6k8 on the SCLK and MOSI lines.
And at least three other of my boards are using this values, at least yours, Antabaka.
So it works and I really advise against lowering the values that excessively.
Regarding parastic inductance and capacitance. OK, my boards have 0805 and 0603 resistors. And wired 0207 resistors behave a little different.
Next point are the FET's used as level-shifter in the SPI. The types I used are BSN20 and these switch in around 50ns which is just fine with a 2 MHz / 500 ns SPI.
| |
|
antabaka Junior Member
  member is offline
Joined: Oct 2006 Posts: 52
|  | Re: Problem with MMC2IEC - EDIT2: New Problem! « Reply #14 on Jun 19, 2007, 2:19pm » | |
Yes, I have three working boards with 4k7/6k8 here. All with SMD (0603 and 0805).
Now that you mention the build-type of the resistor (0805, 0603...) can that have an impact? I used what I had - which were really small, tubular, color coded thingies (sorry, I don't know what the name for that type/size is).
They look like the one soldered in the card slot space between VCC and GND on this picture.
| |
| |
|