6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sat Apr 20, 2024 3:29 am

All times are UTC




Post new topic Reply to topic  [ 1 post ] 
Author Message
PostPosted: Sun Feb 23, 2014 7:28 pm 
Offline
User avatar

Joined: Sun Oct 13, 2013 2:58 pm
Posts: 485
Location: Switzerland
Hi,

regarding Compact Flash cards, most of the reading I have done so far is that the CF cards have an option to be compatible with IDE interfaces. That's what I also always used when building adapters for my 6502 Computers to compact flash. In fact it was the other way around. I first built a IDE interface to interface my 6502 CPU to an old IDE harddrive, later I found out that CF Cards have a IDE compatible mode. So I bought some CF Card to IDE Adapters and was very happy with the result and used this for quiet a few projects I built. But, and that's the reason for this posting, I read in the CF Card specs, that CF Cards also have a Common Memory Mode which provides a 8-bit Interface. But for this to work you most not connect pin 9 of the CF Card to Ground (as all CF Card to IDE Adapters do) when you power-up the CF Card, as this PIN is then used as the "READ" signal. It seems that you need to first send a command to the CF Card and after that you can read and write sectors with a 8-bit interface. I will definitively investigate more on that, especially as a 8-bit interface would be a perfect match for 8-bit CPUs, requires a lot less connections and last but not least requires a very simple interface. But before doing so I ask. Has anyone already done that, or has even a example of code or a usable link? One document I found was the following http://www.walrus.com/~raphael/pdf/compactflashOnPicArticle.pdf, I even have the source code of the program mentioned, but as I'm not familiar with PICs I'm not sure I got it 100% right.

Regards

Peter

Update 6th of March 2014

As it seems CF cards not only support the TrueIDE mode but also in this mode are able to switch to a 8-bit wide databus. So to transfers from/to the 512-byte data buffer any of the three modes of a CF Card are supported. I have found an application note http://read.pudn.com/downloads52/ebook/178846/S72032.pdf from SST that shows how to interface to a CF-Card in TrueIDE mode with a 8-bit microcontroller using only a the lower half of the data bus and still use the full 512-bytes sectors. I have now verified the principal concept of this application note (I used a AVR 8-bit MCU not a MC-51 and the CF Card is sitting in a standard IDE to CF-Card Adapter, note that IDE HDD do _not_ support this feature). And indeed you just need to set the appropriate feature with the "SetFeature" IDE Command. After a reset or power-on you must set the feature of the CF Card to use 8-bit data-bus, the feature number 0x01 (or 0x81 to set the CF-Card back to use 16-bit data-bus). So just set the feature register to 0x01, the Drive Head register to 0xE0 (Master in LBA mode) or 0xF0 (Slave in LBA mode) and then send the command 0xEF. From then on the databuffer can be read and written using 512 consecutive read or writes to the data-register to retrieve the full 512byte sector. In other words, a simple IDE to CF-Card Adapter and a simple 8-bit interface to the 65xxx databus will do it. Signals you need to feed to the CF-Card, apart from the data bus, are A0, A1, A2, /CS0, /CS1, /IORD, /IOWR and /RESET (the last one can also be sent as a command to the command register). My setup is using a ATMega162 running at full 16MHz and uses the external memory interface as does the MC-51 in the above mentioned application note. I use no wait states, that is the /RD and /WR pulses are just about 65ns. So that suggests you can interface a CF-Card directly to the 65C816 running at 8MHz.

Attachment:
File comment: Test setup for 8-bit IDE interface to CF Card
IMG_0002.JPG
IMG_0002.JPG [ 599.19 KiB | Viewed 3249 times ]


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: