⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 upsd3200.h

📁 适合初学者学习的UPSD的点阵LCD汉字显示
💻 H
📖 第 1 页 / 共 2 页
字号:
/* uPSD3200.h - Register and bit definitons for the uPSD3200 family. 

Created with Keil Software Inc uVision2 IDE. PK51 version 7.00.

- 7/08/02
  >> New release.

*/

#include <map3200.h>  // include the definition of your system memory map
		// and any hardware specific items

// Select which functions within uPSD3200.c below that you would like to include
// into your compile session by defining the associated compiler directive. 
// defined = include; not defined = do not include

//Module:  uPSD_ADC_Prescaler
//Calculates prescaler register value for ADC ADSL register.
//#define _U_A_P

//Module:  uPSD_ADC_Init
//Setup I/O ports and ADC prescaler value.
//#define _U_A_I

//Module:  uPSD_ADC_Read
//Reads analog signal from and returns converted value in ADAT SFR register.
//#define _U_A_R

//Module:  uPSD_PWM_Init_8bit
//Setup Prescaler value and I/O ports for the select channel of the 8-bit PWM.
//#define _U_P_I_8

//Module:  uPSD_PWM_Channel_8bit
//Output pulse train as specified in passed arguments
//#define _U_P_C_8

//Module:  uPSD_PWM_Disable
//Disable PWM IP
//#define _U_P_D

//Module:  timer0_isr
//Interrupt service routine for TIMER 0.  
//#define _T0_I

//Module:   timer0_initialize
//Enables TIMER 0 to  interrupt at 100Hz.
//#define _T0_IZ

//Module:   timer0_count
//Returns the current tick count of timer0.
//#define _T0_C

//Module:   timer0_delay
//Waits for specified number of  timer ticks to pass.
//#define _T0_D

//Module:  delay_10ms
//Inserts program execution delay of aproximately 10 msec.
//#define _D_10MS

//Module:  delay_0_1sec
//Inserts program execution delay of aproximately one tenth second.
//#define _D_01S

//Module:  delay_0_5sec
//Inserts program execution delay of aproximately one half second.
//#define _D_05S

//Module:  delay_1sec
//Inserts program execution delay of aproximately 1 second.
//#define _D_1S

//Module:  delay_2sec
//Inserts program execution delay of aproximately 2 second.
//#define _D_2S

//Module:  delay_10sec
//Inserts program execution delay of aproximately 10 second.
//#define _D_10S


typedef struct	// general structure of 8 bit register allowing bit access 
	{
	unsigned char bit0 : 1;
	unsigned char bit1 : 1;
	unsigned char bit2 : 1;
	unsigned char bit3 : 1;
	unsigned char bit4 : 1;
 	unsigned char bit5 : 1;
	unsigned char bit6 : 1;
	unsigned char bit7 : 1;
	} Register;    

typedef union	// allow bit or byte access to registers 
	{
	char byte;
	Register bits;
	} xdata Mix_Reg;

typedef union	// allow bit or byte access to registers 
	{
	char byte;
	Register bits;
	} SFR_Reg;


/* ------------------------------ */
/*      Standard PSD Registers    */
/* ------------------------------ */

typedef xdata struct REG_PSD_struct {
        unsigned char DATAIN_A;         // PSD_REG_BASE +0x00
        unsigned char DATAIN_B;         //              +0x01
        unsigned char CONTROL_A;        //              +0x02
        unsigned char CONTROL_B;        //              +0x03
        unsigned char DATAOUT_A;        //              +0x04
        unsigned char DATAOUT_B;        //              +0x05
        unsigned char DIRECTION_A;      //              +0x06
        unsigned char DIRECTION_B;      //              +0x07
        unsigned char DRIVE_A;          //              +0x08
        unsigned char DRIVE_B;          //              +0x09
        unsigned char IMC_A;            //              +0x0A
        unsigned char IMC_B;            //              +0x0B
        unsigned char OUTENABLE_A;      //              +0x0C
        unsigned char OUTENABLE_B;      //              +0x0D
        unsigned char res2[2];          //      spacer
        unsigned char DATAIN_C;         //              +0x10
        unsigned char DATAIN_D;         //              +0x11
        unsigned char DATAOUT_C;        //              +0x12 
        unsigned char DATAOUT_D;        //              +0x13
        unsigned char DIRECTION_C;      //              +0x14
        unsigned char DIRECTION_D;      //              +0x15
        unsigned char DRIVE_C;          //              +0x16
        unsigned char DRIVE_D;          //              +0x17
        unsigned char IMC_C;            //              +0x18
        unsigned char res1a;            //      spacer
        unsigned char OUTENABLE_C;      //              +0x1A
        unsigned char OUTENABLE_D;      //              +0x1B
        unsigned char res4[4];          //      spacer
        unsigned char OMC_AB;           //              +0x20
        unsigned char OMC_BC;           //              +0x21
        unsigned char OMCMASK_AB;       //              +0x22
        unsigned char OMCMASK_BC;       //              +0x23
        unsigned char res8c[0x8C];      //      spacer
        unsigned char PMMR0;            //              +0xB0
        unsigned char res1b;            //      spacer
        unsigned char PMMR1;            //              +0xB2
        unsigned char res1c;            //      spacer
        unsigned char PMMR2;            //              +0xB4
        unsigned char res0B[0x0B];      //      spacer
        unsigned char MAINPROTECT;      //              +0xC0
        unsigned char res1d;            //      spacer
        unsigned char ALTPROTECT;       //              +0xC2
        unsigned char res4a[4];         //      spacer
        unsigned char JTAG;             //              +0xC7
        unsigned char res18[0x18];      //      spacer
        unsigned char PAGE;             //              +0xE0
        unsigned char res1e;            //      spacer
        unsigned char VM;               //              +0xE2
	  unsigned char res29[0x1d];	    //    	spacer
} PSD_REGS;




//****************** PSD control register bit definitions *********

//PSD PORTA
#define PA0		bit0
#define PA1		bit1	
#define PA2		bit2	
#define PA3		bit3	
#define PA4		bit4	
#define PA5		bit5	
#define PA6		bit6	
#define PA7		bit7	

//PSD PORTB
#define PB0		bit0
#define PB1		bit1	
#define PB2		bit2	
#define PB3		bit3	
#define PB4		bit4	
#define PB5		bit5	
#define PB6		bit6	
#define PB7		bit7	

//PSD PORTC
#define PC0		bit0
#define PC1		bit1	
#define PC2		bit2	
#define PC3		bit3	
#define PC4		bit4	
#define PC5		bit5	
#define PC6		bit6	
#define PC7		bit7	

//PSD PORTD
#define PD0		bit0
#define PD1		bit1	
#define PD2		bit2	

//PSD JTAG
#define JEN		bit0   // JTAG enable

//PSD PMMR0
#define APD_ENABLE	bit1
#define PLD_TURBO		bit3
#define PLD_ARRAY_CLK	bit4
#define PLD_MCELL_CLK	bit5

//PSD PMMR2
#define PLD_CNTL0		bit2
#define PLD_CNTL1		bit3
#define PLD_CNTL2		bit4
#define PLD_ALE		bit5
#define PLD_DBE		bit6

//PSD VM
#define SRAM_CODE		bit0
#define EE_CODE		bit1
#define FL_CODE		bit2
#define EE_DATA		bit3
#define FL_DATA		bit4
#define PIO_EN		bit7


// Common Misc. Defines...
#ifndef TRUE
  #define TRUE 0x01
#endif 
#ifndef FALSE
  #define FALSE 0x00
#endif 
#ifndef ON
  #define ON 0x01
#endif 
#ifndef OFF
  #define OFF 0x00
#endif 
#ifndef NULL
  #define NULL 0x00
#endif 



/* ------------------------------ */
/* Standard 8051 MCU Registers    */
/* ------------------------------ */
// sfr P0    = 0x80;	// Port 0 - Always used for External Memory Access (no access)
sfr P1    = 0x90;		// Port 1
// sfr P2    = 0xA0;	// Port 2 - Always used for External Memory Access (no access)
sfr P3    = 0xB0;		// Port 3
sfr PSW   = 0xD0;		// Program Status Word
sfr ACC   = 0xE0;		// Accumulator
sfr B     = 0xF0;		// Register B
sfr SP    = 0x81;		// Stack Pointer
sfr DPL   = 0x82;		// Data Pointer low byte
sfr DPH   = 0x83;		// Data Pointer high byt
sfr PCON  = 0x87;		// MCU Power Control Register
sfr TCON  = 0x88;		// Timer / Counter Control
sfr TMOD  = 0x89;		// Timer / Counter Mode
sfr TL0   = 0x8A;		// Timer 0 low byte
sfr TL1   = 0x8B;		// Timer 1 low byte
sfr TH0   = 0x8C;		// Timer 0 high byte
sfr TH1   = 0x8D;		// Timer 1 high byte
sfr IE    = 0xA8;		// Interrupt Enable (main)
sfr IP    = 0xB8;		// Interrupt Priority (main) 
sfr SCON  = 0x98;		// UART0 Serial Control
sfr SBUF  = 0x99;		// UART0 Serial Buffer

/* ------------------------ */
/*  Common 8052 Extensions  */
/* ------------------------ */
sfr T2CON  = 0xC8;	// Timer 2 Control
sfr T2MOD  = 0xC9;	// Timer 2 Mode 
sfr RCAP2L = 0xCA;	// Timer 2 Reload low byte
sfr RCAP2H = 0xCB;	// Timer 2 Reload high byte
sfr TL2    = 0xCC;	// Timer 2 low byte
sfr TH2    = 0xCD;	// Timer 2 high byte

/* ------------------------ */
/*  UPSD 3200 Extensions    */
/* ------------------------ */
sfr P4 =0xC0;		// New port 4
sfr P1SFS    = 0x91;	// Port 1 I/O select
sfr P3SFS    = 0x93;	// Port 3 I/O select
sfr P4SFS    = 0x94;	// Port 4 I/O select

// --- ADC SFRs ---
sfr ASCL    = 0x95;	// ADC Clock Prescaler 8-bit
sfr ADAT   = 0x96;	// ADC Data Value
sfr ACON   = 0x97;	// ADC Control Register

// --- UART2 SFRS ----
sfr SCON2     = 0x9A;	// UART2 Serial Control
sfr SBUF2    = 0x9B;	// UART2 Serial Buffer

// --- PWM SFRs -----
sfr PWMCON   = 0xA1;	// PWM Polarity Control
sfr PWM0  = 0xA2;		// PWM0 Duty Cycle
sfr PWM1  = 0xA3;		// PWM1 Duty Cycle
sfr PWM2  = 0xA4;		// PWM2 Duty Cycle
sfr PWM3  = 0xA5;		// PWM3 Duty Cycle
sfr PSCL0L   = 0xB1;	// 8bit PWM Prescaler low
sfr PSCL0H   = 0xB2;	// 8bit PWM Prescaler high

// --- WDT SFRs ---
sfr WDRST   = 0xA6;	// Watch Dog Reset
sfr WDKEY   = 0xAE;	// Watch Dog Key Enable

// --- INTERRUPT 2 SFRs ---
sfr IEA   = 0xA7;		// Interrupt Enable (2nd)
sfr IPA    = 0xB7;	// Interrupt Priority (2nd)

// --- I2C S1/S2 & DDC SFRs ---
sfr S1SETUP  = 0xD1;	// DDC-I2C S1 Setup Control
sfr S2SETUP  = 0xD2;	// I2C S2 Setup Control
sfr RAMBUF    = 0xD4;	// DDC Ram Buffer Access
sfr DDCDAT    = 0xD5;	// DDC I2C Xmit register
sfr DDCADR    = 0xD6;	// DDC Memory Address Pointer
sfr DDCCON    = 0xD7;	// DDC Control Register
sfr S1CON    = 0xD8;	// DDC I2C S1 Control
sfr S1STA   = 0xD9;	// DDC I2C Status
sfr S1DAT   = 0xDA;	// DDC I2C Data Hold Register
sfr S1ADR     = 0xDB;   // DDC I2C Bus Address
sfr S2CON    = 0xDC;	// I2C S2 Control
sfr S2STA   = 0xDD;	// I2C S2 Status
sfr S2DAT   = 0xDE;	// I2C S2 Data Hold Register
sfr S2ADR  = 0xDF;	// I2C S2 Bus Address

// --- USB SFRs ---
sfr USCL  = 0xE1;		// USB Clock 8bit prescaler register
sfr UDT1  = 0xE6;		// USB End Point 1 Data Register
sfr UDT0   = 0xE7;	// USB End Point 0 Data register
sfr UISTA   = 0xE8;	// USB Interrupt Status
sfr UIEN   = 0xE9;	// USB Interrupt Enable
sfr UCON0   = 0xEA;	// USB End Point 0 Control
sfr UCON1    = 0xEB;	// USB End Point 1 Control
sfr UCON2    = 0xEC;	// USB End Point 2 Control
sfr USTA  = 0xED;		// USB End Point 0 Status
sfr UADR  = 0xEE;		// USB Address Register
sfr UDR0  = 0xEF;		// USB Endpoint 0 Data Receive

/* --------------------------- */
/*  Common 8051 BIT Registers  */
/* --------------------------- */
/*  PSW  */
sbit CY    = PSW^7;	// Carry
sbit AC    = PSW^6;	// 
sbit F0    = PSW^5;
sbit RS1   = PSW^4;
sbit RS0   = PSW^3;
sbit OV    = PSW^2;	// Overflow
sbit P     = PSW^0; 	// 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -