Help: CompactFlash card interface

(Please view in fixed font :)

Hi All

I have built an IDE compact flash card interface for a particulat embedded system and all boards work except for one, which i am having consistant truoble with. I want to know why it doesn't work, to make sure that the other working boards won't develop the same problem (i.e. they aren't on the edge of failing)

The board uses a DS80C320 and PSD813 with a 20MHx XTAL. Peripherals are connected to the PSD813 using separate 8 bit address and data buses, and the PSD chip select outputs.

The circuit at the bottom of the page is the interface to the compactflash card in IDE mode. Why IDE mode? :) Well because we are using CF-IDE adapter boards cause we didn't want to do any surface mount soldering. However the card must be able to be taken out and put back in with out turning off the unit. I have a switch to turn it off, however it also draws power from the data and address pins, hence the two buffers with output enable set to the card enable. This way when I switch the card off, the software stops writing to the card registers, thus /CS0 remains high and the buffers have a high impedence output, stopping the card from drawing power. On the bad board it sometimes works fine, sometimes hangs waiting for the DRQ bit (bit

3) to be set in the status register during sector reads and writes, and sometimes the identify drive command returns crap. The bad board always works with a normal sandisk compactflash, but not an industrial one. Streching MOVX makes no difference.

Ok I hope that made sense. Question 1: Is there anything wrong with the interface circuit? Question 2: I do a check every 100ms to see if the RDY (bit 5) bit is set in the status register and CF D5 and /IORD look like this:

. +--l. +--l. . | '-_ | '-_ . | '-| -. . | '-__ .---+ '----- CF D5 . .---+ +-----+ +---------------- /IORD . | | | | . | | | | . | | | | . +--+ +--+

This is OK isnt it? Or should i put some pull downs in? Question 3: Does any one have a similar circuit they can describe to me

Thanks Ross

Interface Circuit: All D? pulled high All other signals straight from PSD813

. 74HC245 . +---------+ All D? pulled high CF D7 -------------| B7 A7 |--------------- D7 CF D6 -------------| B6 A6 |--------------- D6 CF D5 -------------| B5 A5 |--------------- D5 CF D4 -------------| B4 A4 |--------------- D4 CF D3 -------------| B3 A3 |--------------- D3 CF D2 -------------| B2 A2 |--------------- D2 CF D1 -------------| B1 A1 |--------------- D1 CF D0 -------------| B0 A0 |--------------- D0 . | DIR |--------------- /IORD . | /OE |--------------- /CS0 (ATA reg select) . +---------+ . . 74HC541 . +---------+ CF /IOWR ----------| Y7 A7 |--------------- /IOWR CF /IORD ----------| Y6 A6 |--------------- /IORD CF A1 -------------| Y5 A5 |--------------- A1 . ----| Y4 A4 |--------------- GND CF A0 -------------| Y3 A3 |--------------- A0 CF A2 -------------| Y2 A2 |--------------- A2 CF /CS0 -----------| Y1 A1 |--------------- /CS0 CF /CS1 -----------| Y0 A0 |--------------- /CS1 (Always high) . | /OE1 |--------------- /CS0 (ATA reg select) . | /OE2 |--------------- /CS0 (ATA reg select) . +---------+

Reply to
geo
Loading thread data ...

[snip]

Could it be that the line lenght from the from the 74hcx chips to the CF is too long? I had similar problems with a prototype where I used an IDE cable of ~20cm in lenght (~8"). The phenomeon was really similar. Sandisk worked, Memorex did not. Error was that when reading data, some bytes were "forgotten". IMHO you should use a different aproach and place a CF header on your PCB. This is really no Rocket Sience. Advantage would be that you can use memory mapped mode (which is not harder to wire/implement and you would have "real" support from the CF with replacing it on the fly.

Just my 2¢ though

Markus

Reply to
Markus Zingg

One problem we had is that the CF connector is sequenced; grounds contact first, then power, then signals. So if you plug the card into a hot socket, it will not necessarily see ATASEL on "powerup". Ow. I don't think this is the problem you're having, but it's a data point.

Reply to
Lewin A.R.W. Edwards

adapter

the

the

Yea, it's not a hot socket. When the card is inserted the user has to press a button, then power will be applied and 3 seconds later the CPU will attempt to communicate. Start-up is usually fine.

Reply to
geo

embedded

Line length does make a difference on this board. But not on any of the working ones. Length ~20 cm is worse than length ~5cm, but still both give errors. Hmmm could it be that the signals are going throught one 74HC chip faster than the other perhaps? I might try replacing the 541 with a 245 (with DIR = high, and /OE = /IORD).

I wish I could place a header on the PCB, but the boss wants these IDE adapter boards (we use them for the single board computers) and finding a suitable header (eject button and through hole pins) has not been successful.

Thanks Ross

Reply to
geo
[snip]

That might very well be.

Maybe you have to replace the boss then :) sorry, could not resist...

Seriousely, there is no through hole CF header known to me. SMD CF headers including an eject bottom are no problem (IBM, MOLEX and others have them) . Note that a "true" IDE bus is having bus drivers which your design does not seem to have (and also don't really need) and hence line lenght IS crititcal.

Markus

Reply to
Markus Zingg

:D

Thanks for the info. I will experiment tomorrow and post the results (its

12:15 am now in Australia, way past my bedtime!!).

ross

Reply to
geo

I don't think there is a TH CF slot, but maybe it is easier for you to put a PCMCIA slot on the board (there are DEFINITELY many options for through-hole PCMCIA sockets!) and use a CF->PCMCIA adapter?

Reply to
Lewin A.R.W. Edwards

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.