#include<stdio.h>
#include<string.h>
#define INBUF_LEN 4 //数据长度
unsigned char inbuf1[INBUF_LEN]
unsigned char checksum,count3 , flag,temp,ch
bit read_flag=0
sbit cp=P1^1
sbit DIR=P1^2
int i
unsigned int xdata *RAMDATA/*定义RAM地址指针*/
unsigned char a[6] ={0x11,0x22,0x33,0x44,0x55,0x66}
void init_serialcomm(void)
{
SCON=0x50//在11.0592MHz下,设置串行口波特率为9600,方式1,并允许接收
PCON=0x00
ES=1
TMOD=0x21//定时器工作于方式2,自动装载方式
TH0=(65536-1000)%256
TL0=(65536-1000)/256
TL1=0xfd
TH1=0xfd
ET0=1
TR0=1
TR1=1
// TI=0
EA=1
// TI=1
RAMDATA=0x1F45
}
void serial () interrupt 4 using 3
{
if(RI)
{ RI=0
ch=SBUF
TI=1//置SBUF空
switch(ch)
{
case 0x01 :printf("A")TI=0break
case 0x02 :printf("B")TI=0break
case 0x03 :printf("C")TI=0break
case 0x04 :printf("D")TI=0break
default :printf("fg")TI=0break
}
}
}
//向串口发送一个字符
void timer0() interrupt 1 using 3{
// char i
flag++
TH0=0x00
TL0=0x00
if(flag==10)
{// cp=!cp
// for(i=0i<6i++)
P2=0x25
TI=1
temp=*RAMDATA
printf("%c",temp)
TI=0
// RAMDATA--
flag=0
}
}
//主程序
main()
{
init_serialcomm()//初始化串口
//向6264中送数据
{
*RAMDATA=0x33
}
while(1)
{
*RAMDATA=0x33
}
}
AREA StrCopy, CODE, READONLYENTRY mark the first instruction to call
start
LDR r1, =srcstr pointer to first string
LDR r0, =dststr pointer to second string
BL strcopy
call subroutine to do copy
stop
MOV r0,
#0x18
LDR r1,
=0x20026
SWI
0x123456
strcopy
LDRB r2, [r1],#1
STRB r2, [r0],#1
CMP r2, #0
BNE strcopy
MOV pc,lr
Return
AREA Strings, DATA, READWRITE
srcstr DCB First string - source,0
dststr DCB Second string - destination,0
END
试试,
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)