很久以前搞过,忘得差不多了,幸好当时记了笔记: ========= 发现必须从MCU清HINT DSP上电时HPIC是0088,HINT是低电平 从DSP写0到HPIC无效 主板写08到HPIC,从CCS查HPIC是0080。HINT变为高电平。 =========
MCU的代码供参考: ;从串口接收地址(16bit)和长度(8bit),读相应内存的内容发送到串口 ;p0.0-p0.7 ===== HD0-HD7 ;P2.0 ===== HCNTL0 ;P2.1 ===== HCNTL1 ;P2.2 ===== HBIL ;P2.4 ===== HPIR/W ;P2.7 ===== HCS ;write ===== HDS2 ;read ===== HDS1 ;ALE ===== HAS ;HINT ===== INT0 ORG 0000H AJMP MAIN ORG 0003H ;INT0中断子程序 RETI ORG 0030H MAIN: ;设置串口 MOV SCON,#50H ;SCON: mode 1, 8-bit UART, enable rcvr MOV TMOD,#20H ;TMOD: timer 1, mode 2, 8-bit reload MOV TH1,#0FDH ;TH1: reload value for 9600 baud @ 11.0592MHz MOV TL1,#0FDH SETB TR1 ;timer 1 run
;初始化BOB、清HINT MOV A,#08h MOV DPTR,#0000h MOVX @DPTR,A MOV DPTR,#0400h MOVX @DPTR,A
SetAddress: ;从串口读高地址位 CLR TI JNB RI,$ MOV A,SBUF CLR RI ;写HPIA高地址 MOV DPTR,#0200h MOVX @DPTR,A ;从串口读低地址位 JNB RI,$ MOV A,SBUF CLR RI ;写HPIA低地址 MOV DPTR,#0600h MOVX @DPTR,A ;从串口读数据长度 JNB RI,$ MOV A,SBUF CLR RI MOV R1,A
;读DSP内部存贮区并发送到串口 ReadHPI: ;读高字节并发送 MOV DPTR,#1100h MOVX A,@DPTR MOV SBUF,A JNB TI,$ CLR TI ;读低字节并发送 MOV DPTR,#1500h MOVX A,@DPTR MOV SBUF,A JNB TI,$ CLR TI DJNZ R1,ReadHPI ;再次取地址 AJMP SetAddress
End |