📄 18f6720pindef.h
字号:
//**************************************I/O PORT INCLUDE*******************************************
//MCU:PIC18F6520
//PORT MAP:
//
// RAn:7BIT
// RA0/AN0 bit 0 TTL Input/output or analog input.
// RA1/AN1 bit 1 TTL Input/output or analog input.
// RA2/AN2/VREF- bit 2 TTL Input/output or analog input or VREF-.
// RA3/AN3/VREF+ bit 3 TTL Input/output or analog input or VREF+.
// RA4/T0CKI bit 4 ST Input/output or external clock input for Timer0.Output is open-drain type.
// RA5/AN4/LVDIN bit 5 TTL Input/output or slave select input for synchronous serial port or analog input, or Low-Voltage Detect input.
// OSC2/CLKO/RA6 bit 6 TTL OSC2 or clock output, or I/O pin.
//
// RBn:8BIT
// RB0/INT0 bit 0 TTL/ST(1) Input/output pin or external interrupt input 0.Internal software programmable weak pull-up.
// RB1/INT1 bit 1 TTL/ST(1) Input/output pin or external interrupt input 1. Internal software programmable weak pull-up.RB2/INT2 bit 2 TTL/ST(1) Input/output pin or external interrupt input 2.Internal software programmable weak pull-up.
// RB3/INT3/CCP2 bit 3 TTL/ST(4) Input/output pin or external interrupt input 3. Capture2 input/Compare2 output/PWM output (when CCP2MX configuration bit is enabled, all PIC18F8X20 operating modes except Microcontroller mode).Internal software programmable weak pull-up.
// RB4/KBI0 bit 4 TTL Input/output pin (with interrupt-on-change).Internal software programmable weak pull-up.
// RB5/KBI1/PGM bit 5 TTL/ST(2) Input/output pin (with interrupt-on-change).Internal software programmable weak pull-up.Low-voltage ICSP enable pin.
// RB6/KBI2/PGC bit 6 TTL/ST(2) Input/output pin (with interrupt-on-change).Internal software programmable weak pull-up.Serial programming clock.
// RB7/KBI3/PGD bit 7 TTL/ST(2) Input/output pin (with interrupt-on-change).Internal software programmable weak pull-up.Serial programming data.
//
// RCn:8BIT
// RC0/T1OSO/T13CKI bit 0 ST Input/output port pin, Timer1 oscillator output or Timer1/Timer3clock input.
// RC1/T1OSI/CCP2 bit 1 ST Input/output port pin, Timer1 oscillator input or Capture2 input/Compare2 output/PWM output (when CCP2MX configuration bit isdisabled).
// RC2/CCP1 bit 2 ST Input/output port pin or Capture1 input/Compare1 output/PWM1 output.
// RC3/SCK/SCL bit 3 ST RC3 can also be the synchronous serial clock for both SPI and I2C modes.
// RC4/SDI/SDA bit 4 ST RC4 can also be the SPI data in (SPI mode) or data I/O (I2C mode).
// RC5/SDO bit 5 ST Input/output port pin or synchronous serial port data output.
// RC6/TX1/CK1 bit 6 ST Input/output port pin, addressable USART1 asynchronous transmit or addressable USART1 synchronous clock.
// RC7/RX1/DT1 bit 7 ST Input/output port pin, addressable USART1 asynchronous receive or addressable USART1 synchronous data.
//
// RDn:8BIT
// RD0/PSP0/AD0 bit 0 ST/TTL(1) Input/output port pin, Parallel Slave Port bit 0 or address/data bus bit 0.
// RD1/PSP1/AD1 bit 1 ST/TTL(1) Input/output port pin, Parallel Slave Port bit 1 or address/data bus bit 1.
// RD2/PSP2/AD2 bit 2 ST/TTL(1) Input/output port pin, Parallel Slave Port bit 2 or address/data bus bit 2.
// RD3/PSP3/AD3 bit 3 ST/TTL(1) Input/output port pin, Parallel Slave Port bit 3 or address/data bus bit 3.
// RD4/PSP4/AD4 bit 4 ST/TTL(1) Input/output port pin, Parallel Slave Port bit 4 or address/data bus bit 4.
// RD5/PSP5/AD5 bit 5 ST/TTL(1) Input/output port pin, Parallel Slave Port bit 5 or address/data bus bit 5.
// RD6/PSP6/AD6 bit 6 ST/TTL(1) Input/output port pin, Parallel Slave Port bit 6 or address/data bus bit 6.
// RD7/PSP7/AD7 bit 7 ST/TTL(1) Input/output port pin, Parallel Slave Port bit 7 or address/data bus bit 7.
//
// REn:8BIT
// RE0/RD/AD8 bit 0 ST/TTL(1) Input/output port pin, read control for Parallel Slave Port or address/data bit 8
// RE1/WR/AD9 bit 1 ST/TTL(1) Input/output port pin, write control for Parallel Slave Port or address/data bit 9
// RE2/CS/AD10 bit 2 ST/TTL(1) Input/output port pin, chip select control for Parallel Slave Port oraddress/data bit 10
// RE3/AD11 bit 3 ST/TTL(1) Input/output port pin or address/data bit 11.
// RE4/AD12 bit 4 ST/TTL(1) Input/output port pin or address/data bit 12.
// RE5/AD13 bit 5 ST/TTL(1) Input/output port pin or address/data bit 13.
// RE6/AD14 bit 6 ST/TTL(1) Input/output port pin or address/data bit 14.
// RE7/CCP2/AD15 bit 7 ST/TTL(1) Input/output port pin, Capture2 input/Compare2 output/PWM output
//
//
// RFn:6BIT
// RF0/AN5 bit 0 ST Input/output port pin or analog input.
// RF1/AN6/C2OUT bit 1 ST Input/output port pin, analog input or comparator 2 output.
// RF2/AN7/C1OUT bit 2 ST Input/output port pin, analog input or comparator 1 output.
// RF3/AN8 bit 3 ST Input/output port pin or analog input/comparator input.
// RF4/AN9 bit 4 ST Input/output port pin or analog input/comparator input.
// RF5/AN10/CVREF bit 5 ST Input/output port pin, analog input/comparator input or comparator reference output.
// RF6/AN11 bit 6 ST Input/output port pin or analog input/comparator input.
// RF7/SS bit 7 ST/TTL Input/output port pin or slave select pin for synchronous serial port.
//
// RGn:
// RG0/CCP3 bit 0 ST Input/output port pin or Capture3 input/Compare3 output/PWM3 output.
// RG1/TX2/CK2 bit 1 ST Input/output port pin, addressable USART2 asynchronous transmit or addressable USART2 synchronous clock.
// RG2/RX2/DT2 bit 2 ST Input/output port pin, addressable USART2 asynchronous receive or addressable USART2 synchronous data.
// RG3/CCP4 bit 3 ST Input/output port pin or Capture4 input/Compare4 output/PWM4 output.
// RG4/CCP5 bit 4 ST Input/output port pin or Capture5 input/Compare5 output/PWM5 output.
//
//
// REGISTER:
//? TRIS register (data direction register)
//? PORT register (reads the levels on the pins of the(device)
//? LAT register (output latch)
//
//*************************************************************************************************
#include "p18f6720.h"
//******************************* I/O define **********************************//
//
//
//*****************************************************************************//
//******************************* LCD DRIVER **********************************//
#define LEDCTRL LATDbits.LATD3 //PIN 53 OUTPUT
#define DDRLEDCTRL DDRDbits.RD3
#define LCDCS LATDbits.LATD2 //PIN 54 OUTPUT
#define DDRLCDCS DDRDbits.RD2
#define LCDRD LATDbits.LATD1 //PIN 55 OUTPUT
#define DDRLCDRD DDRDbits.RD1
#define LCDRW LATDbits.LATD0 //PIN 58 OUTPUT
#define DDRLCDRW DDRDbits.RD0
#define LCDDA_IN PORTEbits.RE7 //PIN 59 OUTPUT/INPUT
#define LCDDA_OUT LATEbits.LATE7
#define DDRLCDDA DDREbits.RE7
//*******************************FM1702***************************************
#define HQCCLK LATEbits.LATE6 //PIN 60 OUTPUT
#define DDRHQCCLK DDREbits.RE6
#define HQCMN LATEbits.LATE5 //PIN 61 OUTPUT
#define DDRHQCMN DDREbits.RE5
#define HQCDI PORTEbits.RE4 //PIN 62 INPUT
#define DDRHQCDI DDREbits.RE4
#define HQCDO LATEbits.LATE3 //PIN 63 OUTPUT
#define DDRHQCDO DDREbits.RE3
#define HQCRST LATEbits.LATE2 //PIN 64 OUTPUT
#define DDRHQCRST DDREbits.RE2
//*******************************DS1302***************************************
#define DSCLK LATDbits.LATD6 //PIN 50 OUTPUT
#define DDRDSCLK DDRDbits.RD6
#define DSDA_IN PORTDbits.RD5 //PIN 51 INPUT/OUTPUT
#define DSDA_OUT LATDbits.LATD5
#define DDRDSDA DDRDbits.RD5
#define DSRST LATDbits.LATD4 //PIN 52 OUTPUT
#define DDRDSRST DDRDbits.RD4
//*******************************AT24C1024************************************
#define E2_WP LATCbits.LATC2 //PIN 33 OUTPUT
#define DDRE2_WP DDRCbits.RC2
#define E2_CLK LATCbits.LATC3 //PIN 34 OUTPUT
#define DDRE2_CLK DDRCbits.RC3
#define E2_SDA_IN PORTCbits.RC4 //PIN 35 INPUT/OUTPUT
#define E2_SDA_OUT LATCbits.LATC4
#define DDRE2_SDA DDRCbits.RC4
//*******************************motor contrl*********************************
#define CLOSE LATAbits.LATA1 //PIN 23 output
#define DDRCLOSE DDRAbits.RA1
#define OPEN LATAbits.LATA5 //PIN 27 OUTPUT
#define DDROPEN DDRAbits.RA5
//*******************************SYSTEEM VOLT CHCEK***************************
#define MOTORDET
#define DDRMOTORDET
#define PWRDET
#define DDRPWRDET
//******************************* Count Key **********************************
#define SIN1 PORTBbits.RB2
#define DDRSIN1 DDRBbits.RB2
#define SIN2 PORTBbits.RB1
#define DDRSIN2 DDRBbits.RB1
#define SOUT LATCbits.LATC5
#define DDRSOUT DDRCbits.RC5
//*******************************KEY******************************************
#define SETKEY PORTBbits.RB3 //PIN 42 INPUT
#define DDRSETKEY DDRBbits.RB3
#define KEYDEC PORTBbits.RB4 //PIN 44 INPUT
#define DDRKRYDEC DDEBbits.RB4
#define KEYADD PORTBbits.RB5 //PIN 45 INPUT
#define DDEKEYADD DDRBbits.RB5
#define KEY_OK PORTBbits.RB0 //PIN 48 INPUT
#define DDRKEY_OK DDRBbits.RB0
//*******************************U2270B***************************************
#define OP LATCbits.LATC1 //PIN 29 OUTPUT
#define DDROP DDRCbits.RC1
#define CFE PORTAbits.RA4 //PIN 28 INPUT
#define DDRCFE DDRAbits.RA4
#define LQCPC LATCbits.LATC0 //PIN 30 OUTPUT CONTRL POWER FOR U2270B
#define DDRLQCPC DDRCbits.RC0
//*******************************TC35I***************************************
#define _SYNC PORTFbits.RF4 //PIN 14 INPUT
#define SYNCDDR DDRFbits.RF4
#define PD LATFbits.LATF5 //PIN 13 OUTPUT
#define DDRPD DDRFbits.RF5
#define DCD PORTFbits.RF6 //PIN 12 INPUT
#define DDRDCD DDRFbits.RF6
#define DTR LATFbits.LATF7 //PIN 11 OUTPUT MCU-PORT IS READY
#define DDRDTR DDRFbits.RF7
#define RTS LATGbits.LATG4 //PIN 8 OUTPUT MCU ASK FOR DCE SENT DATA
#define DDRRTS DDRGbits.RG4
#define CTS PORTGbits.RG3 //PIN 6 INPUT DCE ASK FOR MCU SENT DATA
#define DDRCTS DDRGbits.RG3
#define DSR PORTGbits.RG0 //PIN 3 INPUT DCE-PORT IS READY
#define DDRDSR DDRGbits.RG0
#define IGT LATEbits.LATE0 //PIN 2 OUTPUT TC35 STARTUP SIGNAL
#define DDRIGT DDREbits.RE0
#define PWRCTRL LATEbits.LATE1 //PIN 1 OUTPUT
#define DDRPWRCTRL DDREbits.RE1
//hardware serial 2
#define DDRTX2 DDRGbits.RG1 //PIN 4
#define DDRRX2 DDRGbits.RG2 //PIN 5
#define OPENCOM2 RCSTA2bits.SPEN = 1
#define CLOSECOM2 RCSTA2bits.SPEN = 0
#define EN_COM2_T TXSTA2bits.TXEN = 1
#define DIS_COM2_T TXSTA2bits.TXEN = 0
#define EN_COM2_CR RCSTA2bits.CREN = 1
#define DIS_COM2_CR RCSTA2bits.CREN = 0
//*******************************RS485***************************************
//hardware serial 1
#define DDRTX1 DDRCbits.RC6 //PIN 31
#define DDRRX1 DDRCbits.RC7 //PIN 32
#define OPENCOM1 RCSTA1bits.SPEN = 1
#define CLOSECOM1 RCSTA1bits.SPEN = 0
#define EN_COM1_T TXSTA1bits.TXEN = 1
#define DIS_COM1_T TXSTA1bits.TXEN = 0
#define EN_COM1_CR RCSTA1bits.CREN = 1
#define DIS_COM1_CR RCSTA1bits.CREN = 0
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -