📄 is62lv1024new.c
字号:
//-----------------------------------------------------------------------------
// IS62LV1024.c
//-----------------------------------------------------------------------------
// Copyright 2003 NCD co.ltd
//
// AUTH: Jhonsun
// DATE: 3 Mar 03
//
// This program shows an example of access data from external Sram .
//
// Assumes an 22.1184MHz crystal is attached between XTAL1 and XTAL2.
//
// Target: C8051F02x
// Tool chain: KEIL EVAL C51
//
//-----------------------------------------------------------------------------
// Includes
//-----------------------------------------------------------------------------
#include <c8051f020.h> // SFR declarations
#include <intrins.h>
//-----------------------------------------------------------------------------
// 16-bit SFR Definitions for 'F02x
//-----------------------------------------------------------------------------
sfr16 DP = 0x82; // data pointer
sfr16 TMR3RL = 0x92; // Timer3 reload value
sfr16 TMR3 = 0x94; // Timer3 counter
sfr16 ADC0 = 0xbe; // ADC0 data
sfr16 ADC0GT = 0xc4; // ADC0 greater than window
sfr16 ADC0LT = 0xc6; // ADC0 less than window
sfr16 RCAP2 = 0xca; // Timer2 capture/reload
sfr16 T2 = 0xcc; // Timer2
sfr16 RCAP4 = 0xe4; // Timer4 capture/reload
sfr16 T4 = 0xf4; // Timer4
sfr16 DAC0 = 0xd2; // DAC0 data
sfr16 DAC1 = 0xd5; // DAC1 data
//-----------------------------------------------------------------------------
// Global CONSTANTS
//-----------------------------------------------------------------------------
#define SYSCLK 11059200 // SYSCLK frequency in Hz
//-----------------------------------------------------------------------------
// Function PROTOTYPES
//-----------------------------------------------------------------------------
void SYSCLK_Init (void);
void PORT_Init(void);
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// MAIN Routine
//-----------------------------------------------------------------------------
void main (void) {
unsigned char idata InBuf[35];
unsigned long idata i;
unsigned char idata j;
unsigned char xdata *idata Point1;
WDTCN = 0xde; // disable watchdog timer
WDTCN = 0xad;
PORT_Init();
SYSCLK_Init (); // initialize oscillator
P4=0x04; //P4.3接1024的CE1,P4.4接1024的CE2,P4.0接A16
//A16作为分页数据线,A16=0 选择BANK0:0-64K,A16=1 选择BANK1:64-128K
j=0;
Point1=0x0000;
for(i=0;i<0xFFFE;i++)
{
j=i/0x1000;
*Point1=0xaa;
Point1++;
}
_nop_();
P4=0x05; //向BANK1送数据
_nop_();
_nop_();
Point1=0x0000;
for(i=0;i<0xFFFE;i++)
{ j=i/0x1000+0x10;
*Point1=j;
Point1++;
}
_nop_();
P4=0x04; //读取BANK0的数据
_nop_();
_nop_();
Point1=0x0000;
for(i=0;i<16;i++)
{
InBuf[i]=*Point1;
Point1+=0x1000;
}
_nop_();
P4=0x05; //读取BANK1的数据
Point1=0x0000;
for(i=16;i<32;i++)
{
InBuf[i]=*Point1;
Point1+=0x1000;
}
while (1);
}
//-----------------------------------------------------------------------------
// Initialization Subroutines
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// SYSCLK_Init
//-----------------------------------------------------------------------------
//
// This routine initializes the system clock to use an 22.1184MHz crystal
// as its clock source.
//
void SYSCLK_Init (void)
{
int i; // delay counter
OSCXCN = 0x67; // start external oscillator with
// 22.1184MHz crystal
for (i=0; i < 256; i++) ; // XTLVLD blanking interval (>1ms)
while (!(OSCXCN & 0x80)) ; // Wait for crystal osc. to settle
OSCICN = 0x88; // select external oscillator as SYSCLK
// source and enable missing clock
// detector
}
void PORT_Init()
{
XBR2 = 0x40; // Enable crossbar and weak pull-ups
EMI0TC = 0x21; //
EMI0CF =0x2f; //EMIF端口接到P4-P7,选择复用方式,工作模式为不带块选择。
P74OUT = 0x3F;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -