PDA

View Full Version : HDD IDE ATA 2 interface problems. code wrong?



rastan
- 26th March 2005, 23:08
hi ive been trying to interface my 16f877a with a samsung shd-30560A hard disk drive. its ATA-2 spec at 560MB.
the attatched code does not read properly from the drive, a previous test (also attatched) where it requests the drives information does work.

For the program that doesnt work, i got the following output


Ready to Initialize
head register = 0
Writing: 11100000
head register = 11100000
LBA Mode Activated
System Initialized and ready
Writing to number of sectors register
Writing to LBA
Writing to command register
Information:

error register = 0
Spin down


as you can see, there is no information being passed back, but the error register is still empty. as if the wrong command is being passed.

unfortunatly i couldnt upload the ata2 standard paper for reference because the filesize was too big. it can be found easily on the net. cant remember where i got it from though :)

thanks everyone for the help

phil

Luciano
- 27th March 2005, 08:50
http://hem.passagen.se/communication/ide.html

From the WEB page:

This project will explain how an IDE disk drive works.
You will also learn how to control it and how to read and save data to your disk.
Build your own interface and get advantage of the mass storage of data in a hard disk.

* * *

See also the links at the bottom of the web page.

Luciano

rastan
- 27th March 2005, 16:01
thanks Luciano,

unfortunatly the web page that you provided never provided any more information but through that web page i found that i had missed something. there is a line on the ide connector called ALE.

it is some sort of old ATX information strobe line and I did not connect this since it has not been used for years, but by doing this it was sending the drive crazy. once i had pulled it up to 5v through a resistor it was fine.

for further information, i found this by a man called wesley (http://www.pjrc.com/tech/8051/ide/wesley.html) a lot more helpful. plus also the ata2 specfication paper which i found at the t13 website (ftp://ftp.t13.org/project/d0948r4c-ATA-2.pdf)along with all the other specifications.

just for everyones reference before writing the read command, ALL of the logical block addresses MUST be written to, for example if you were wanting to read lba 0 (master boot record) then you would write 0 to ALL the appropriate registers, not just the lba 0-7 register like i did :P

thanks again Luciano, i know that not many people will be willing to touch this subject with a 50 foot barge pole but im sure ill be back in a bit asking more questions.

Also, if anyone else is having a go at this, then i would like to know how you are getting on.

cheers, phil