本帖最后由 iago 于 2013-8-10 23:48 编辑
如题,用汇编写的在计算机上模拟正常,改写到leonardo上就没任何反应了,一下为代码,求达人指导.
51汇编如下ORG 100H
RS EQU P2.0
RW EQU P2.1
E EQU P2.2
CLR RS ;0 COMMAND,1 DATA
CLR RW ;0 WRITE ,1 READ
SETB E ;NEGATTIVE EDGE EXECUTE,1 READ STAT
MOV R7,#38H
CALL WRITE
MOV R7,#0FH
CALL WRITE
MOV R7,#01H
CALL WRITE
;COMMANDS FINISH,WRITE DATA BELLOW
SETB RS
SETB E
MOV R0,#0
MOV R1,#0CH
MOV DPTR,#TAB
LOOP:
MOV A,R0
MOVC A,@A+DPTR
MOV P3,A
CLR E
SETB E
CALL DELAY
INC R0
MOV A,R0
DJNZ R1,LOOP
SJMP $
;-------------------------------FUNCTIONS BELLOW----------------------
; DELAY 6ms
DELAY:
MOV R5,#30
LOOP2:
MOV R4,#64H
LOOP1:
DJNZ R4,LOOP1
DJNZ R5,LOOP2
RET
;WIRTE DATA INTO LCD1602
WRITE:
MOV P3,R7
CLR E
CALL DELAY
SETB E
RET
;TABLES BELLOW
TAB: DB "Hello,World!"
以下为arduino代码:
const unsigned char LED8Pin[]={5,6,7,8,9,10,11,12} ; //D0~D7
int RS =2;
int RW =3;
int E =4;
void setup()
{
for(int i=2;i<13;i++)
{
pinMode(i,OUTPUT);
}
digitalWrite(RS,0);
digitalWrite(RW,0);
digitalWrite(E,1);
LED8Show(0x38);
LED8Show(0x0F);
LED8Show(0x01);
digitalWrite(RS,1);
LED8Show(0x48);
}
void loop()
{
}
void LED8Show(char data)
{
for(int i=0;i<8;i++)
{
digitalWrite(LED8Pin,bitRead(data,i));
}
digitalWrite(E,0);
delay(6);
digitalWrite(E,1);
delay(6);
}
这个本应该出现一个"H"的,可是什么反应都没有,咋么回事?
|