📄 c8051f300_defs.h
字号:
//-----------------------------------------------------------------------------
// C8051F300_defs.h
//-----------------------------------------------------------------------------
// Copyright 2007, Silicon Laboratories, Inc.
// http://www.silabs.com
//
// Program Description:
//
// Register/bit definitions for the C8051F30x family.
// **Important Note**: The compiler_defs.h header file should be included
// before including this header file.
//
// Target: C8051F300, 'F301, 'F302, 'F303, 'F304, 'F305
// Tool chain: Generic
// Command Line: None
//
// Release 1.3 - 07 AUG 2007 (PKC)
// -Removed #include <compiler_defs.h>. The C source file should include it.
// -Removed FID and fixed formatting.
// Release 1.2 - 15 NOV 2006 (PKC/BW)
// -Reformatted header file to enable portable SFR definitions
// Release 1.1 - 11 JAN 2006 (GP)
// -Converted file to new coding guidelines
// -Added #defines for interrupt priorities
// -Added #ifndef/#define to allow multiple includes of file
// Release 1.0
// -Latest release before new firmware coding standard
//-----------------------------------------------------------------------------
// Header File Preprocessor Directive
//-----------------------------------------------------------------------------
#ifndef C8051F300_DEFS_H
#define C8051F300_DEFS_H
//-----------------------------------------------------------------------------
// Byte Registers
//-----------------------------------------------------------------------------
SFR (P0, 0x80); // Port 0 Latch
SFR (SP, 0x81); // Stack Pointer
SFR (DPL, 0x82); // Data Pointer Low
SFR (DPH, 0x83); // Data Pointer High
SFR (PCON, 0x87); // Power Control
SFR (TCON, 0x88); // Timer/Counter Control
SFR (TMOD, 0x89); // Timer/Counter Mode
SFR (TL0, 0x8A); // Timer/Counter 0 Low
SFR (TL1, 0x8B); // Timer/Counter 1 Low
SFR (TH0, 0x8C); // Timer/Counter 0 High
SFR (TH1, 0x8D); // Timer/Counter 1 High
SFR (CKCON, 0x8E); // Clock Control
SFR (PSCTL, 0x8F); // Program Store R/W Control
SFR (SCON0, 0x98); // UART0 Control
SFR (SBUF0, 0x99); // UART0 Data Buffer
SFR (CPT0MD, 0x9D); // Comparator0 Mode Selection
SFR (CPT0MX, 0x9F); // Comparator0 Mux Selection
SFR (P0MDOUT, 0xA4); // Port 0 Output Mode Configuration
SFR (IE, 0xA8); // Interrupt Enable
SFR (OSCXCN, 0xB1); // External Oscillator Control
SFR (OSCICN, 0xB2); // Internal Oscillator Control
SFR (OSCICL, 0xB3); // Internal Oscillator Calibration
SFR (FLSCL, 0xB6); // Flash Scale
SFR (FLKEY, 0xB7); // Flash Lock And Key
SFR (IP, 0xB8); // Interrupt Priority
SFR (AMX0SL, 0xBB); // AMUX0 Channel Select
SFR (ADC0CF, 0xBC); // ADC0 Configuration
SFR (ADC0, 0xBE); // ADC0 Data
SFR (SMB0CN, 0xC0); // SMBus0 Control
SFR (SMB0CF, 0xC1); // SMBus0 Configuration
SFR (SMB0DAT, 0xC2); // SMBus0 Data
SFR (ADC0GT, 0xC4); // ADC0 Greater-Than Compare
SFR (ADC0LT, 0xC6); // ADC0 Less-Than Compare
SFR (TMR2CN, 0xC8); // Timer/Counter 2 Control
SFR (TMR2RLL, 0xCA); // Timer/Counter 2 Reload Low
SFR (TMR2RLH, 0xCB); // Timer/Counter 2 Reload High
SFR (TMR2L, 0xCC); // Timer/Counter 2 Low
SFR (TMR2H, 0xCD); // Timer/Counter 2 High
SFR (PSW, 0xD0); // Program Status Word
SFR (REF0CN, 0xD1); // Voltage Reference Control
SFR (PCA0CN, 0xD8); // PCA0 Control
SFR (PCA0MD, 0xD9); // PCA0 Mode
SFR (PCA0CPM0, 0xDA); // PCA0 Module 0 Mode Register
SFR (PCA0CPM1, 0xDB); // PCA0 Module 1 Mode Register
SFR (PCA0CPM2, 0xDC); // PCA0 Module 2 Mode Register
SFR (ACC, 0xE0); // Accumulator
SFR (XBR0, 0xE1); // Port I/O Crossbar Control 0
SFR (XBR1, 0xE2); // Port I/O Crossbar Control 1
SFR (XBR2, 0xE3); // Port I/O Crossbar Control 2
SFR (IT01CF, 0xE4); // INT0/INT1 Configuration
SFR (EIE1, 0xE6); // Extended Interrupt Enable 1
SFR (ADC0CN, 0xE8); // ADC0 Control
SFR (PCA0CPL1, 0xE9); // PCA0 Capture 1 Low
SFR (PCA0CPH1, 0xEA); // PCA0 Capture 1 High
SFR (PCA0CPL2, 0xEB); // PCA0 Capture 2 Low
SFR (PCA0CPH2, 0xEC); // PCA0 Capture 2 High
SFR (RSTSRC, 0xEF); // Reset Source Configuration/Status
SFR (B, 0xF0); // B Register
SFR (P0MDIN, 0xF1); // Port 0 Input Mode Configuration
SFR (EIP1, 0xF6); // Extended Interrupt Priority 1
SFR (CPT0CN, 0xF8); // Comparator0 Control
SFR (PCA0L, 0xF9); // PCA0 Counter Low
SFR (PCA0H, 0xFA); // PCA0 Counter High
SFR (PCA0CPL0, 0xFB); // PCA0 Capture 0 Low
SFR (PCA0CPH0, 0xFC); // PCA0 Capture 0 High
//-----------------------------------------------------------------------------
// 16-bit Register Definitions (might not be supported by all compilers)
//-----------------------------------------------------------------------------
SFR16 (DP, 0x82); // Data Pointer
SFR16 (TMR2RL, 0xCA); // Timer 2 Reload
SFR16 (TMR2, 0xCC); // Timer 2 Counter
SFR16 (PCA0CP1, 0xE9); // PCA0 Module 1 Capture/Compare
SFR16 (PCA0CP2, 0xEB); // PCA0 Module 2 Capture/Compare
SFR16 (PCA0, 0xF9); // PCA0 Counter
SFR16 (PCA0CP0, 0xFB); // PCA0 Module 0 Capture/Compare
//-----------------------------------------------------------------------------
// Address Definitions for Bit-addressable Registers
//-----------------------------------------------------------------------------
#define SFR_P0 0x80
#define SFR_TCON 0x88
// Address 0x90 UNUSED
#define SFR_SCON0 0x98
// Address 0xA0 UNUSED
#define SFR_IE 0xA8
// Address 0xB0 UNUSED
#define SFR_IP 0xB8
#define SFR_SMB0CN 0xC0
#define SFR_TMR2CN 0xC8
#define SFR_PSW 0xD0
#define SFR_PCA0CN 0xD8
#define SFR_ACC 0xE0
#define SFR_ADC0CN 0xE8
#define SFR_B 0xF0
#define SFR_CPT0CN 0xF8
//-----------------------------------------------------------------------------
// Bit Definitions
//-----------------------------------------------------------------------------
// TCON 0x88
SBIT (TF1, SFR_TCON, 7); // Timer 1 Overflow Flag
SBIT (TR1, SFR_TCON, 6); // Timer 1 On/Off Control
SBIT (TF0, SFR_TCON, 5); // Timer 0 Overflow Flag
SBIT (TR0, SFR_TCON, 4); // Timer 0 On/Off Control
SBIT (IE1, SFR_TCON, 3); // Ext. Interrupt 1 Edge Flag
SBIT (IT1, SFR_TCON, 2); // Ext. Interrupt 1 Type
SBIT (IE0, SFR_TCON, 1); // Ext. Interrupt 0 Edge Flag
SBIT (IT0, SFR_TCON, 0); // Ext. Interrupt 0 Type
// SCON0 0x98
SBIT (S0MODE, SFR_SCON0, 7); // UART0 Mode
// Bit6 UNUSED
SBIT (MCE0, SFR_SCON0, 5); // UART0 MCE
SBIT (REN0, SFR_SCON0, 4); // UART0 RX Enable
SBIT (TB80, SFR_SCON0, 3); // UART0 TX Bit 8
SBIT (RB80, SFR_SCON0, 2); // UART0 RX Bit 8
SBIT (TI0, SFR_SCON0, 1); // UART0 TX Interrupt Flag
SBIT (RI0, SFR_SCON0, 0); // UART0 RX Interrupt Flag
// IE 0xA8
SBIT (EA, SFR_IE, 7); // Global Interrupt Enable
SBIT (ESPI0, SFR_IE, 6); // SPI0 Interrupt Enable
SBIT (ET2, SFR_IE, 5); // Timer 2 Interrupt Enable
SBIT (ES0, SFR_IE, 4); // UART0 Interrupt Enable
SBIT (ET1, SFR_IE, 3); // Timer 1 Interrupt Enable
SBIT (EX1, SFR_IE, 2); // External Interrupt 1 Enable
SBIT (ET0, SFR_IE, 1); // Timer 0 Interrupt Enable
SBIT (EX0, SFR_IE, 0); // External Interrupt 0 Enable
// IP 0xB8
// Bit7 UNUSED
SBIT (PSPI0, SFR_IP, 6); // SPI0 Priority
SBIT (PT2, SFR_IP, 5); // Timer 2 Priority
SBIT (PS0, SFR_IP, 4); // UART0 Priority
SBIT (PT1, SFR_IP, 3); // Timer 1 Priority
SBIT (PX1, SFR_IP, 2); // External Interrupt 1 Priority
SBIT (PT0, SFR_IP, 1); // Timer 0 Priority
SBIT (PX0, SFR_IP, 0); // External Interrupt 0 Priority
// SMB0CN 0xC0
SBIT (MASTER, SFR_SMB0CN, 7); // SMBus0 Master/Slave
SBIT (TXMODE, SFR_SMB0CN, 6); // SMBus0 Transmit Mode
SBIT (STA, SFR_SMB0CN, 5); // SMBus0 Start Flag
SBIT (STO, SFR_SMB0CN, 4); // SMBus0 Stop Flag
SBIT (ACKRQ, SFR_SMB0CN, 3); // SMBus0 Acknowledge Request
SBIT (ARBLOST, SFR_SMB0CN, 2); // SMBus0 Arbitration Lost
SBIT (ACK, SFR_SMB0CN, 1); // SMBus0 Acknowledge Flag
SBIT (SI, SFR_SMB0CN, 0); // SMBus0 Interrupt Pending Flag
// TMR2CN 0xC8
SBIT (TF2H, SFR_TMR2CN, 7); // Timer 2 High Byte Overflow Flag
SBIT (TF2L, SFR_TMR2CN, 6); // Timer 2 Low Byte Overflow Flag
SBIT (TF2LEN, SFR_TMR2CN, 5); // Timer 2 Low Byte Interrupt Enable
SBIT (TF2CEN, SFR_TMR2CN, 4); // Timer 2 Lfo Capture Enable
SBIT (T2SPLIT, SFR_TMR2CN, 3); // Timer 2 Split Mode Enable
SBIT (TR2, SFR_TMR2CN, 2); // Timer 2 On/Off Control
// Bit6 UNUSED
SBIT (T2XCLK, SFR_TMR2CN, 0); // Timer 2 External Clock Select
// PSW 0xD0
SBIT (CY, SFR_PSW, 7); // Carry Flag
SBIT (AC, SFR_PSW, 6); // Auxiliary Carry Flag
SBIT (F0, SFR_PSW, 5); // User Flag 0
SBIT (RS1, SFR_PSW, 4); // Register Bank Select 1
SBIT (RS0, SFR_PSW, 3); // Register Bank Select 0
SBIT (OV, SFR_PSW, 2); // Overflow Flag
SBIT (F1, SFR_PSW, 1); // User Flag 1
SBIT (P, SFR_PSW, 0); // Accumulator Parity Flag
// PCA0CN 0xD8
SBIT (CF, SFR_PCA0CN, 7); // PCA0 Counter Overflow Flag
SBIT (CR, SFR_PCA0CN, 6); // PCA0 Counter Run Control Bit
// Bit5 UNUSED
// Bit4 UNUSED
// Bit3 UNUSED
SBIT (CCF2, SFR_PCA0CN, 2); // PCA0 Module 2 Interrupt Flag
SBIT (CCF1, SFR_PCA0CN, 1); // PCA0 Module 1 Interrupt Flag
SBIT (CCF0, SFR_PCA0CN, 0); // PCA0 Module 0 Interrupt Flag
// ADC0CN 0xE8
SBIT (AD0EN, SFR_ADC0CN, 7); // ADC0 Enable
SBIT (AD0TM, SFR_ADC0CN, 6); // ADC0 Track Mode
SBIT (AD0INT, SFR_ADC0CN, 5); // ADC0 EOC Interrupt Flag
SBIT (AD0BUSY, SFR_ADC0CN, 4); // ADC0 Busy Flag
SBIT (AD0WINT, SFR_ADC0CN, 3); // ADC0 Window Interrupt Flag
SBIT (AD0CM2, SFR_ADC0CN, 2); // ADC0 Convert Start Mode Bit 2
SBIT (AD0CM1, SFR_ADC0CN, 1); // ADC0 Convert Start Mode Bit 1
SBIT (AD0CM0, SFR_ADC0CN, 0); // ADC0 Convert Start Mode Bit 0
// CPT0CN 0xF8
SBIT (CP0EN, SFR_CPT0CN, 7); // CPT0 Enable
SBIT (CP0OUT, SFR_CPT0CN, 6); // CPT0 Output
SBIT (CP0RIF, SFR_CPT0CN, 5); // CPT0 Rising-edge detected Flag
SBIT (CP0FIF, SFR_CPT0CN, 4); // CPT0 Falling-edge detected Flag
SBIT (CP0HYP1, SFR_CPT0CN, 3); // CPT0 Hysteresis Positive 1
SBIT (CP0HYP0, SFR_CPT0CN, 2); // CPT0 Hysteresis Positive 0
SBIT (CP0HYN1, SFR_CPT0CN, 1); // CPT0 Hysteresis Negative 1
SBIT (CP0HYN0, SFR_CPT0CN, 0); // CPT0 Hysteresis Negative 0
//-----------------------------------------------------------------------------
// Interrupt Priorities
//-----------------------------------------------------------------------------
#define INTERRUPT_INT0 0 // External Interrupt 0
#define INTERRUPT_TIMER0 1 // Timer0 Overflow
#define INTERRUPT_INT1 2 // External Interrupt 1
#define INTERRUPT_TIMER1 3 // Timer1 Overflow
#define INTERRUPT_UART0 4 // Serial Port 0
#define INTERRUPT_TIMER2 5 // Timer2 Overflow
#define INTERRUPT_SMBUS0 6 // SMBus0 Interface
#define INTERRUPT_ADC0_WINDOW 7 // ADC0 Window Comparison
#define INTERRUPT_ADC0_EOC 8 // ADC0 End Of Conversion
#define INTERRUPT_PCA0 9 // PCA0 Peripheral
#define INTERRUPT_COMPARATOR0F 10 // Comparator0 Falling
#define INTERRUPT_COMPARATOR0R 11 // Comparator0 Rising
//-----------------------------------------------------------------------------
// Header File PreProcessor Directive
//-----------------------------------------------------------------------------
#endif // #define C8051F300_DEFS_H
//-----------------------------------------------------------------------------
// End Of File
//-----------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -