您的位置 首页 IC

根据stc单片机的AT89S52离线烧录器程序

下面是部分源码预览,完整的代码请到http:www51heicombbsdpj-20605-1html下载includeuarthincludes51prohincludemy


下面是部分源码预览,完好的代码请到http://www.51hei.com/bbs/dpj-20605-1.html下载
#include “uart.h”
#include “s51pro.h”
#include “myfun.h”

#include “znfat/znFAT.h”

extern unsigned char OutBuf[4];
extern unsigned char InBuf[4];

unsigned char idata psignbuf[3];

unsigned char code_buf[32];

sfr P1M0 = 0x92;
sfr P1M1 = 0x91; //界说STC12单片机IO形式特别功用寄存器

struct znFAT_Init_Args idata Init_Args; //初始化参数调集
struct FileInfo idata fileinfo; //文件信息调集

void main()
{
unsigned int idata addr=0,i=0;
unsigned int idata res=0,n_file=0,len=0;

P1M1=0x40;//P16高阻输入
P1M0=0xa0; //假如运用51单片机来调试SD卡模块,翻开推挽,增强IO驱动才能

UART_Init();
UART_Send_Str(“串口设置结束”);

znFAT_Device_Init(); //存储设备初始化
UART_Send_Str(“SD卡初始化结束”);

znFAT_Select_Device(0,&Init_Args); //挑选设备

res=znFAT_Init(); //文件体系初始化

if(!res) //文件体系初始化成功
{
UART_Send_Str(“Suc. to init FS”);

UART_Put_Inf(“BPB_Sector_No:”,Init_Args.BPB_Sector_No);
UART_Put_Inf(“Total_SizeKB:”,Init_Args.Total_SizeKB);
UART_Put_Inf(“BytesPerSector:”,Init_Args.BytesPerSector);
UART_Put_Inf(“FATsectors:”,Init_Args.FATsectors);
UART_Put_Inf(“SectorsPerClust:”,Init_Args.SectorsPerClust);
UART_Put_Inf(“FirstFATSector:”,Init_Args.FirstFATSector);
UART_Put_Inf(“FirstDirSector:”,Init_Args.FirstDirSector);
UART_Put_Inf(“FSsec:”,Init_Args.FSINFO_Sec);
UART_Put_Inf(“Next_Free_Cluster:”,Init_Args.Next_Free_Cluster);
UART_Put_Inf(“FreenCluster:”,Init_Args.Free_nCluster);
}
else //文件体系初始化失利
{
UART_Put_Inf(“Fail to init FS , Err Code:”,res);
}
//==================================================================

res=znFAT_Open_File(&fileinfo,”/*.bin”,n_file,1); //翻开文件

while(!res)
{
UART_Put_Inf(“Suc. toopenfile “,n_file);
UART_Send_Str(“================================”);
UART_Send_Str(“File_Name(Short 8.3):”);
UART_Send_Str(fileinfo.File_Name);UART_Send_Enter();
if(fileinfo.have_lfn) //假如有长名,则输出长名
{
UART_Send_Str(“File_Name(Long Name):”);
//中文输出其UN%&&&&&%ODE编码码值
i=0;
while(fileinfo.longname[i])
{
if(fileinfo.longname[i]<0x80)
UART_Send_Byte((unsigned char)fileinfo.longname[i++]);
else
{
UART_Put_Hex(fileinfo.longname[i++]);
UART_Send_Byte( );
}
}
UART_Send_Enter();
}
else
{
UART_Send_Str(“This file have not Long Name.”);;
}
UART_Put_Inf(“File_Size:”,fileinfo.File_Size);

声明:本文内容来自网络转载或用户投稿,文章版权归原作者和原出处所有。文中观点,不代表本站立场。若有侵权请联系本站删除(kf@86ic.com)https://www.86ic.net/bandaoti/318246.html

为您推荐

联系我们

联系我们

在线咨询: QQ交谈

邮箱: kf@86ic.com

关注微信
微信扫一扫关注我们

微信扫一扫关注我们

返回顶部