at89c51芯片燒錄驅程
以下是C51BOX程式編寫器的AT89C51芯片燒錄驅動源程式:“AT89C51.C”中的内容用戶只需要C51實現芯片的幾個函數程式,就可以支持一種新的芯片。其他庫函數和通訊協議代碼都在OBJ中,不需要修改。#include <intrins.h>#include "Plug3LIB.H"//-----------------------------------------------------------------------------------------------#define DATA P1#define AL P0#define AH P2#define P37 P3_7#define P36 P3_6#define P27 P2_7#define P26 P2_6#define PROG P3_3#define PSEN P3_4#define GET12V P3_5//-----------------------------------------------------------------------------------------------Byte ReadFID(void)//讀工廠ID,1bit{ Byte ID=0; PSEN=0; PROG=1; DATA=0xFF; P26=0;P27=0;P36=0;P37=0; AH=0;AL=0x30; Delay5us(); ID=DATA; return ID;}//-----------------------------------------------------------------------------------------------Word ReadID(void)//讀芯片ID,2bit{ Word ID=0; PSEN=0; PROG=1; DATA=0xFF; P26=0;P27=0;P36=0;P37=0; AH=0x00;AL=0x31; Delay5us(); ID=DATA;ID<<=8; AH=0x00;AL=0x32; Delay5us(); ID|=DATA; return ID;}//-----------------------------------------------------------------------------------------------Byte ReadByte(Word address)//讀一個bit{ PSEN=0; PROG=1; DATA=0xFF; P26=0;P27=0;P36=1;P37=1; AL=address; AH=address>>8; Delay5us(); return DATA;}//-----------------------------------------------------------------------------------------------void ChipErase(void)//全片清除{ PSEN=0; PROG=0; GET12V=0; P26=1;P27=0;P36=0;P37=0; Delay1ms(10); PROG=1; GET12V=1;}//-----------------------------------------------------------------------------------------------void WriteLockBit(Byte No)//寫加密位,No是加密位的序號,1/2/3可選{ PROG=1; PSEN=0; DATA=0xFF; if (No==1) {P26=1;P27=1;P36=1;P37=1;} if (No==2) {P26=1;P27=1;P36=0;P37=0;} if (No==3) {P26=1;P27=0;P36=1;P37=0;} Delay5us();//P2.7 (ENABLE) High to VPP GET12V=0; Delay5us();Delay5us();//VPP Setup to PROG Low PROG=0; Delay5us();//PROG Width PROG=1; Delay5us();Delay5us();//VPP Hold after PROG GET12V=1; Delay1ms(2);} //-----------------------------------------------------------------------------------------------void ByteProgram(Word address,Byte ch)//向指定地址寫一個bit{ PROG=1; PSEN=0; P26=0;P27=1;P36=1;P37=1; Delay5us();//P2.7 (ENABLE) High to VPP AL=address; AH=(address>>8)|0x80;//或0x80是爲了保證P27仍為高 DATA=ch; GET12V=0; Delay5us();Delay5us();//VPP Setup to PROG Low PROG=0; Delay5us();//PROG Width PROG=1; Delay5us();Delay5us();//VPP Hold after PROG GET12V=1; DATA=0xFF; while(ReadByte(address)!=ch);}//-----------------------------------------------------------------------------------------------void main(void) { McuIni(); Protocol();}re:高兴与楼主多交流,谢谢!
高兴与楼主多交流,谢谢!好复杂!!头都大了!!
乐乐天真的好厉害!!好好佩服!!什么时候我才能看懂1%……??
页:
[1]