Home > Microcontroller >Microcontroller Production > Hard disk control circuit and original program

Hard disk control circuit and original program

Source: InternetPublisher:桂花蒸 Updated: 2012/10/05

Knowledge belongs to all mankind. Being able to share your achievements with others unconditionally is great and respected, and it is also a blessing. Since I want to be happy and respected, I also open up the results of my work. (Actually, it’s not much of a work achievement. I wrote it in a hurry in one night. It’s ridiculous. I would like to thank Comrade Shao Chunwei. I referred to the program he wrote when I was studying the ata protocol.) I believe many people want to use microcontroller control. Hard drives are used to realize mass storage of data and develop some things (such as hard drive MP3), but there is not much information about this on the Internet, and those who actually provide the original code and circuit are even rarer, and even if the original program is given, I don’t know what it is. Because of mistakes or failure to understand the ata protocol, or due to issues of intellectual property protection, there are major or minor errors in the program. This program is just a demonstration and is not perfect yet. It is just a reference for you to develop ata programs, but I guarantee that it can definitely be used. Of course, you can modify and expand it to become a complete ata driver. Features and Usage All parameters related to the hardware of the microcontroller itself in the program are defined at the beginning of the program. When transplanting to other types of microcontrollers, you only need to modify the pin definitions. When using it, be sure to modify the corresponding parameters according to your hard disk (there are comments in the program). Usage steps and running effects: Connect the circuit (very simple), and then burn the program into the chip. First turn on the power of the hard disk, then open any serial port debugging program, set the baud rate to 57600bps, and then run the microcontroller. The effect is the same as below: Source program: #include /****************************************************** * * HardDisk Control Demo * Power BY DDDLZHU * Compilation environment: KEIL C51 V7.07 Supported device: AT89C51 * COPYRIGHT (C) 2004 ********************** *****************************/ #define byte unsigned char #define uint unsigned int /********** ****************************************** //Line connection definition. If the circuit changes, just modify it directly********************************************** ********/ #define DataH P1 #define DataL P0 #define RegAddr P2 #define Read P3_4 #define Write P3_3 #define Rst P3_2 /**************** ********************************* //Line connection definition. If the circuit changes, just modify it directly********************************************** ********/ //Register address definition #define _Status_Control 0x16 #define _Data 0x8 #define _Err_Features 0x9 #define _SecCount 0xa #define _SecNum 0xb #define _CylinderL 0xc #define _CylinderH 0xd #define _DeviceAndHead 0xe #define _Status_Com mand 0xf //************************************************ ******************************************/ /*Here are the important parameters for initializing the hard disk, each The parameters of each hard disk are different. If it is incorrect, the data on the disk cannot be read. The calculation method is as follows: First, look clearly at the data in the surface label of your hard disk. There are three important parameters in it: 1. Number of cylinders (Cylinder) 2. Number of heads (Head) 3. Number of tracks (Sector) Among them _MaxHead=0xA+Head _MaxSector=Sector For example, my 130M hard drive (very old, haha), the number of heads is 15, and the hexadecimal value is 0xf, so _MaxHead=0xAF, the number of tracks is 17 ,so _MaxSector=0x11 */ #define _MaxHead 0xAF #define _MaxSector 0x11 //******************************

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号