📄 download.c
字号:
#include <Reg52.h>
#include <absacc.h>
#include <stdio.h>
#include <intrins.h>
#include <dspcode.h>
/*定义宏*/
#define uint unsigned int
#define uchar unsigned char
/*定义寄存器端口地址*/
//#define HPICL XBYTE[0xe000]
//#define HPICH XBYTE[0xe100]
//#define WR_HPIL0_D XBYTE[0xe200]
//#define WR_HPIH0_D XBYTE[0xe300]
//#define WR_HPIL_A XBYTE[0xe400]
//#define WR_HPIH_A XBYTE[0xe500]
//#define WR_HPIL1_D XBYTE[0xe600]
//#define WR_HPIH1_D XBYTE[0xe700]
//my definition
sbit DSPRST =P1^6;
sbit HCS =P1^0;
sbit HBIL =P1^1;
sbit HCN0 =P1^2;
sbit HCN1 =P1^3;
sbit HRW =P1^4;
sbit HDS =P1^5;
void wr_dspcode();
void delay(uint wu);
download()
{
DSPRST=1;
HDS=1;
HCS=1;
delay(10000);
DSPRST=0;
delay(1000);
DSPRST=1; // dsp reset
delay(10000);
HRW=0;
wr_dspcode();
while(1);
}
void delay(uint wu)
{
for(wu;wu>0;wu--);
}
void wr_dspcode()
{
uchar code *dspptr/*,*temp*/;
uchar len;
char i;
uint addr;
// HPICL=0x08; //clear HPIint,least is first
// HPICH=0x08;
HCS=0;
P2=0x0;
HBIL=0;
HCN0=0;
HCN1=0;
HDS=0;
HDS=1;
HBIL=1;
HDS=0;
HDS=1;
dspptr=dspcode;
while(1)
{
len=*dspptr++;
if(len==0) break;
else
{
addr=((*dspptr++)*256)+(*dspptr++);
addr--;
P2=addr/256;
HBIL=0;
HCN0=0;
HCN1=1;
HDS=0;
HDS=1;
// WR_HPIH_A=addr%256;
P2=addr%256;
HBIL=1;
HDS=0;
HDS=1;
for(i=0;i<len/2;i++)
{
//WR_HPIL0_D=*dspptr++;
P2=*dspptr++;
HBIL=0;
HCN0=1;
HCN1=0;
HDS=0;
HDS=1;
// WR_HPIH0_D=*dspptr++;
P2=*dspptr++;
HBIL=1;
HDS=0;
HDS=1;
}
}
}
// WR_HPIL_A=0x00;
P2=0x0;
HBIL=0;
HCN0=0;
HCN1=1;
HDS=0;
HDS=1;
// WR_HPIH_A=0x7f;
P2=0x7f;
HBIL=1;
HDS=0;
HDS=1;
// WR_HPIL1_D=0x00; //THE START ADDRESS OF RUN
P2=0x0;
HBIL=0;
HCN0=1;
HCN1=1;
HDS=0;
HDS=1;
// WR_HPIH1_D=0x80;
P2=0x80;
HBIL=1;
HDS=0;
HDS=1;
HCS=1;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -