有没有人用过C8051F021这款芯片的?我现在再用这款芯片访问外部RAM,但是现在读出来的数不对。有没有人用过给我看下历程,或者怎么配置这款芯片访问外部RAM(非复用方式)……实在是弄不明白了……
#include "C8051F020.H"
#include"absacc.h"
#define c654_a_cs XBYTE[0x2000]
#define c654_a_dll XBYTE[0x2000]
#define c654_a_dlm XBYTE[0x2001]
#define c654_a_ier XBYTE[0x2001]
#define c654_a_rhr XBYTE[0x2000]
#define c654_a_thr XBYTE[0x2000]
#define c654_a_isr XBYTE[0x2002]
#define c654_a_fcr XBYTE[0x2002]
#define c654_a_lcr XBYTE[0x2003]
#define c654_a_mcr XBYTE[0x2004]
#define c654_a_efr XBYTE[0x2002]
#define c654_a_lsr XBYTE[0x2005]
#define c654_b_cs XBYTE[0x2010]
#define c654_b_dll XBYTE[0x2010]
#define c654_b_dlm XBYTE[0x2011]
#define c654_b_ier XBYTE[0x2011]
#define c654_b_rhr XBYTE[0x2010]
#define c654_b_thr XBYTE[0x2010]
#define c654_b_isr XBYTE[0x2012]
#define c654_b_fcr XBYTE[0x2012]
#define c654_b_lcr XBYTE[0x2013]
#define c654_b_mcr XBYTE[0x2014]
#define c654_b_efr XBYTE[0x2012]
#define c654_b_lsr XBYTE[0x2015]
#define c654_c_cs XBYTE[0x2020]
#define c654_c_dll XBYTE[0x2020]
#define c654_c_dlm XBYTE[0x2021]
#define c654_c_ier XBYTE[0x2021]
#define c654_c_rhr XBYTE[0x2020]
#define c654_c_thr XBYTE[0x2020]
#define c654_c_isr XBYTE[0x2022]
#define c654_c_fcr XBYTE[0x2022]
#define c654_c_lcr XBYTE[0x2023]
#define c654_c_mcr XBYTE[0x2024]
#define c654_c_efr XBYTE[0x2022]
#define c654_c_lsr XBYTE[0x2025]
#define c654_d_cs XBYTE[0x2030]
#define c654_d_dll XBYTE[0x2030]
#define c654_d_dlm XBYTE[0x2031]
#define c654_d_ier XBYTE[0x2031]
#define c654_d_rhr XBYTE[0x2030]
#define c654_d_thr XBYTE[0x2030]
#define c654_d_isr XBYTE[0x2032]
#define c654_d_fcr XBYTE[0x2032]
#define c654_d_lcr XBYTE[0x2033]
#define c654_d_mcr XBYTE[0x2034]
#define c654_d_efr XBYTE[0x2032]
#define c654_d_lsr XBYTE[0x2035]
sbit A4 =P2^4;
sbit A5 =P2^5;
sbit A6 =P2^6;
sbit CS =P1^5;
EMI0CF = 0X18; //EMIF低端口 选择地址/数据非复用方式
EMI0TC = 0xff; //地址建立时间3*SYSCLK周期 WR 、RD控制位脉冲宽度2*SYSCLK周期 地址保持1*SYSCLK周期
EMI0CN = 0X20;
void main( void )
{
C8051f020_Init();
initialize16c654a();//外部访问的16C654
while(1)
{
CS=1;
c654_a_thr&=0x1f;
}
}
void initialize16c654a(void)
{
////////通道A/////////////////////////
c654_a_lcr=0xbf; //LCR为线路控制寄存器
c654_a_efr=0x10; // enhanced feature register
c654_a_lcr=0x80; //线路控制寄存器
c654_a_dlm=0x00; //波特率因子寄存器高位
c654_a_dll=0x02; // 波特率因子寄存器地位 115.2K波特率
c654_a_lcr=0x00; //
c654_a_lcr=0x03; //8bit,1stop,no parity,diable divisor access latch
c654_a_mcr=0x08;
c654_a_fcr=0x67; // FIFO 控制寄存器 收16个FIFO,发32个FIFO,复位所有FIFO ;
c654_a_ier=0x01;
////////通道B/////////////////////////
c654_b_lcr=0xbf;
c654_b_efr=0x10;
c654_b_lcr=0x80;
c654_b_dlm=0x00;
c654_b_dll=0x02; //115.2k波特率
c654_b_lcr=0x00;
c654_b_lcr=0x03;
c654_b_mcr=0x08;
c654_b_fcr=0x67; //收8个FIFO,发32个FIFO,复位所有FIFO;27
c654_b_ier=0x01;
////////通道C////////////////////////
c654_c_lcr=0xbf;
c654_c_efr=0x10;
c654_c_lcr=0x80;
c654_c_dlm=0x00;
c654_c_dll=0x02; //115.2k波特率
c654_c_lcr=0x00;
c654_c_lcr=0x03;
c654_c_mcr=0x08;
c654_c_fcr=0x67; //收16个FIFO,发32个FIFO,复位所有FIFO;
c654_c_ier=0x01;
////////通道D////////////////////////
c654_d_lcr=0xbf;
c654_d_efr=0x10;
c654_d_lcr=0x80;
c654_d_dlm=0x00;
c654_d_dll=0x02; //115.2K波特率
c654_d_lcr=0x00;
c654_d_lcr=0x03;
c654_d_mcr=0x08;
c654_d_fcr=0x67; //收8个FIFO,发32个FIFO,复位所有FIFO;
c654_d_ier=0x01;
}