最近翻譯一段匯編程式,使用的c8051f505單片機,與FPGA之間是地址資料總線通訊,通過中斷在地址中讀取資料,匯編程式能順利跑起來,我翻譯成匯編后發現進入中斷怎么也讀取不到地址的資料,求大神指點,匯編代碼
LJMP MAIN
ORG 000BH
LJMP A1CDF
ORG 001BH
LJMP A1CC8
MAIN:
ANL PCA0MD, #0BFh
MOV SFRPAGE, #CONFIG_PAGE
MOV OSCICN, #0C5H
MOV P0SKIP, #03H
MOV P1SKIP , #0E0H
MOV 0, #00H ;交叉開關使能
MOV XBR1, #0C0H
MOV XBR2, #040H
MOV P2MDIN, #0FH ;埠配置,P0開漏,p1,P4口為推挽輸出
MOV P1MDOUT, #0E7H
MOV P2MDOUT, #0FH
MOV P3MDOUT, #0FFH ;P0-p4埠為數字輸入,p2四位模擬輸入埠
MOV P4MDOUT, #0FFH
MOV EMI0CF, #09H
MOV EMI0TC, #045H
MOV SFRPAGE, #ACTIVE_PAGE ;外部儲存器設定
CLR P1.1
LCALL A1D30
CLR P1.0 ;15530主復位
CLR P1.4 ;開接收
SETB EA ;清中斷屏蔽位,開CPU中斷
A1CC8: PUSH DPL ;接收中斷服務子程(T1中斷)
PUSH DPH
PUSH ACC
MOV DPTR,#02001H
MOVX A,@DPTR
JB B.0,A1D19
MOV RMSB,A
MOV COM_DATA,#00H
;SETB P2.1
JNB P1.3,A1D1D
MOV COM_DATA,#0FFH
A1D1D: SETB B.0
SJMP LP5
A1D19: MOV RLSB,A
SETB B.3
SJMP LP5
翻譯成c后
void Oscillator_Init(void)在c中RMSB=XBYTE[0X2001]這句有沒有啥問題?沒讀取到數
{
SFRPAGE = CONFIG_PAGE;
OSCICN = 0xC5;
SFRPAGE = ACTIVE_PAGE;
}
//定時器初始化//A1D30
void Timer_Init(void)
{
ET0=1;
ET1=1;
TR0=1;
TR1=1;
TMOD=0x66;
TL0=0xF8;
TH0=0xF8;
TL1=0xF8;
TH1=0xF8;
}
void EMI_IN(void)
{
SFRPAG=CONFIG_PAGE;
EMI0CF = 0x09; //配置EMIF埠復用方式,帶塊選擇的分片方式,<4k用記憶體,>4k用外存
EMI0TC = 0x45; //最小地址建立時間、最大保持時間。原值55H
SFRPAGE=ACTIVE_PAGE ;
}
void Port_IO_Init(void)
{
SFRPAGE = CONFIG_PAGE;
P0SKIP = 0x03; // Skip P0.0 and P0.1
P1SKIP = 0xE0;
XBR0 = 0x00;
XBR1 = 0xC0; //T2、T1、T0連接到埠引腳
XBR2 = 0x40; //使能交叉開關
P2MDIN = 0x0F; //設定P2口沒有模擬輸入
P1MDOUT = 0xE7; //推挽輸出帶負載能力強
P2MDOUT = 0x0F;
P3MDOUT = 0xFF;
P4MDOUT = 0xFF;
SFRPAGE=ACTIVE_PAGE ;
}
INTERRUPT(TIMER1_ISR, INTERRUPT_TIMER1)
{
if(BB0)
{
RLSB=XBYTE[0X2001];
BB3=1;
}
else
{
RMSB=XBYTE[0X2001];
COM_DATA=https://bbs.csdn.net/topics/0x00;
if(P13==0)BB0=1;
else
{
COM_DATA=https://bbs.csdn.net/topics/0xff;
BB0=1;
}
}
}
uj5u.com熱心網友回復:
就是匯編正確,C不正確?確保XBYTE[]定義在了xdata區,并且起始地址正確,如果起始地址位于0x100處則你的XBYTE[0X2001]實際指向了xdata 0x2101
例如 xdata XBYTE[] __attribute__((section(".ARM.__at_0x00")))
uj5u.com熱心網友回復:
更正下,C51下應該這樣寫xdata XBYTE[] _at_ 0x00;
uj5u.com熱心網友回復:
沒有看到XBYTE[]的定義,但是 RMSB=XBYTE[0X2001]看,你確認c8051f505單片機有多于0X2001 的記憶體?uj5u.com熱心網友回復:
我是直接加的#include <absacc.h>頭檔案,起始地址怎么看?通過EMI0CF[3:2]設定的是10,說明書如下,When EMI0CF[3:2] are set to 10, the XRAM memory map is split into two areas, on-chip space and off-chip space.? Effective addresses below the internal XRAM size boundary will access on-chip XRAM space.
? Effective addresses above the internal XRAM size boundary will access off-chip space.
? 8-bit MOVX operations use the contents of EMI0CN to determine whether the memory access is on-chip or off-chip. The upper 8-bits of the Address Bus A[15:8] are determined by EMI0CN, and the lower
8- bits of the Address Bus A[7:0] are determined by R0 or R1. All 16-bits of the Address Bus A[15:0] are driven in “Bank Select” mode.
? 16-bit MOVX operations use the contents of DPTR to determine whether the memory access is on-chip or off-chip, and the full 16-bits of the Address Bus A[15:0] are driven during the off-chip transaction.
超過1000的為片外,不超過1000的為片內,XRAM圖上顯示的是0000到ffff~~~
uj5u.com熱心網友回復:
我直接參考的#include <absacc.h>頭檔案,另外人家匯編確實有2001H,不知道為啥我c語言就讀不出來,通過EMI0CF[3:2]設定的是10,說明書如下,When EMI0CF[3:2] are set to 10, the XRAM memory map is split into two areas, on-chip space and off-chip space.
? Effective addresses below the internal XRAM size boundary will access on-chip XRAM space.
? Effective addresses above the internal XRAM size boundary will access off-chip space.
? 8-bit MOVX operations use the contents of EMI0CN to determine whether the memory access is on-chip or off-chip. The upper 8-bits of the Address Bus A[15:8] are determined by EMI0CN, and the lower
8- bits of the Address Bus A[7:0] are determined by R0 or R1. All 16-bits of the Address Bus A[15:0] are driven in “Bank Select” mode.
? 16-bit MOVX operations use the contents of DPTR to determine whether the memory access is on-chip or off-chip, and the full 16-bits of the Address Bus A[15:0] are driven during the off-chip transaction.
超過1000的為片外XRAM~~
uj5u.com熱心網友回復:
這個選的是第三個,起始地址是多少?1000?
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/202919.html
標籤:單片機/工控
