📄 186c.cod
字号:
_Set186Register(P2CON , 0x$$P2CON$);
/* Direction
* Output = 1
* P2.7 = ($$P2DIR.7$) $%tP2DIR.7$Input$Output$
* P2.6 = ($$P2DIR.6$) $%tP2DIR.6$Input$Output$
* P2.5 = ($$P2DIR.5$) $%tP2DIR.5$Input$Output$
* P2.4 = ($$P2DIR.4$) $%tP2DIR.4$Input$Output$
* P2.3 = ($$P2DIR.3$) $%tP2DIR.3$Input$Output$
* P2.2 = ($$P2DIR.2$) $%tP2DIR.2$Input$Output$
* P2.1 = ($$P2DIR.1$) $%tP2DIR.1$Input$Output$
* P2.0 = ($$P2DIR.0$) $%tP2DIR.0$Input$Output$
*/
_Set186Register(P2DIR , 0x$$P2DIR$);
}
##80C186EB IO2#
$$IF$ RELREG.12
#define _MEM_SPACE_
#ifndef PCB_BASE
#define PCB_BASE 0x$$RELREG.0-11$00000L
#endif
$$END$
$$IFN$ RELREG.12
#define _IO_SPACE_
#ifndef PCB_BASE
#define PCB_BASE 0x$$RELREG.0-11$00
#endif
$$END$
#include "80c186eb.h"
void Init_IO_Port2(void)
{
/*
* P2.5/BLK0 = ($$P2CON.5$) $%tP2CON.5$BCLK0 Pin$I/O Pin$
* P2.4/CTS1 = ($$P2CON.4$) $%tP2CON.4$CTS1 Pin$I/O Pin$
* P2.3/SINT1 = ($$P2CON.3$) $%tP2CON.3$SINT1 Pin$I/O Pin$
* P2.2/BLK1 = ($$P2CON.2$) $%tP2CON.2$BLK1 Pin$I/O Pin$
* P2.1/TXD1 = ($$P2CON.1$) $%tP2CON.1$TxD1 Pin$I/O Pin$
* P2.0/RXD1 = ($$P2CON.0$) $%tP2CON.0$RxD1 Pin$I/O Pin$
*/
_Set186Register(P2CON , 0x$$P2CON$);
/*
* Direction
* Output = 1
* P2.7 = ($$P2DIR.7$) $%tP2DIR.7$Input$Output$
* P2.6 = ($$P2DIR.6$) $%tP2DIR.6$Input$Output$
* P2.5 = ($$P2DIR.5$) $%tP2DIR.5$Input$Output$
* P2.4 = ($$P2DIR.4$) $%tP2DIR.4$Input$Output$
* P2.3 = ($$P2DIR.3$) $%tP2DIR.3$Input$Output$
* P2.2 = ($$P2DIR.2$) $%tP2DIR.2$Input$Output$
* P2.1 = ($$P2DIR.1$) $%tP2DIR.1$Input$Output$
* P2.0 = ($$P2DIR.0$) $%tP2DIR.0$Input$Output$
*/
_Set186Register(P2DIR , 0x$$P2DIR$);
}
##80C186EC IO3#
$$IF$ RELREG.12
#define _MEM_SPACE_
#ifndef PCB_BASE
#define PCB_BASE 0x$$RELREG.0-11$00000L
#endif
$$END$
$$IFN$ RELREG.12
#define _IO_SPACE_
#ifndef PCB_BASE
#define PCB_BASE 0x$$RELREG.0-11$00
#endif
$$END$
#include "80c186ec.h"
void Init_IO_Port3(void)
{
/*
* P3.3/DMAI1 = ($$P3CON.3$) $%tP3CON.3$DMAI1 Pin$I/O Pin$
* P3.2/DMAI0 = ($$P3CON.2$) $%tP3CON.2$DMAI0 Pin$I/O Pin$
* P3.1/TXI1 = ($$P3CON.1$) $%tP3CON.1$TXI1 Pin$I/O Pin$
* P3.0/RXI1 = ($$P3CON.0$) $%tP3CON.0$RXI1 Pin$I/O Pin$
*/
_Set186Register(P3CON , 0x$$P3CON$);
/*
/* Direction
* Output = 1
* P3.4 = ($$P3DIR.3$) $%tP3DIR.3$Input$Output$
* P3.5 = ($$P3DIR.2$) $%tP3DIR.2$Input$Output$
*/
_Set186Register(P3DIR , 0x$$P3DIR$);
}
##80C186EC RCU#
##80C186EB RCU#
##80C186XL RCU#
##80C186EA RCU#
$$IF$ RELREG.12
#define _MEM_SPACE_
#ifndef PCB_BASE
#define PCB_BASE 0x$$RELREG.0-11$00000L
#endif
$$END$
$$IFN$ RELREG.12
#define _IO_SPACE_
#ifndef PCB_BASE
#define PCB_BASE 0x$$RELREG.0-11$00
#endif
$$END$
$$IFP$ 80C186EC
#include "80c186ec.h"
$$END$
$$IFP$ 80C186EB
#include "80c186eb.h"
$$END$
$$IFP$ 80C186EA || 80C186XL
#include "80c186ea.h"
$$END$
void Init_RefreshCntrlUnit(void)
{
/* Refresh Address = @@REFADDR@ */
_Set186Register(RFBASE , 0x$$RFBASE$);
/* Refresh Time = @@RFTIME@ usec at @@FREQ@ MHz */
_Set186Register(RFTIME , 0x$$RFTIME$);
/* Refresh Control Register = $%ERFCON.15$ */
_Set186Register(RFCON , 0x$$RFCON$);
}
##80C186EC Serial0#
##80C186EB Serial0#
$$IF$ RELREG.12
#define _MEM_SPACE_
#ifndef PCB_BASE
#define PCB_BASE 0x$$RELREG.0-11$00000L
#endif
$$END$
$$IFN$ RELREG.12
#define _IO_SPACE_
#ifndef PCB_BASE
#define PCB_BASE 0x$$RELREG.0-11$00
#endif
$$END$
$$IFP$ 80C186EC
#include "80c186ec.h"
$$END$
$$IFP$ 80C186EB
#include "80c186eb.h"
$$END$
void Init_SerialPort0(void)
{
/* Baud Rate
* Clocking = $%tB0CMP.15$Internal$External$
* Baud Rate = @@BAUDRATE0@ at @@FREQ@ MHz
*/
_Set186Register(B0CMP , 0x$$B0CMP$);
/* Serial Port Control
* Serial Port Mode = @@SERMODE0@
* Clear to Send is $%eS0CON.6$
* Receive is $%eS0CON.5$
* Parity $%eS0CON.3$
$$IF$ S0CON.3
* $%tS0CON.4$Even$Odd$ Parity
$$END$
*/
_Set186Register(S0CON , 0x$$S0CON$);
}
##80C186EC Serial1#
##80C186EB Serial1#
$$IF$ RELREG.12
#define _MEM_SPACE_
#ifndef PCB_BASE
#define PCB_BASE 0x$$RELREG.0-11$00000L
#endif
$$END$
$$IFN$ RELREG.12
#define _IO_SPACE_
#ifndef PCB_BASE
#define PCB_BASE 0x$$RELREG.0-11$00
#endif
$$END$
$$IFP$ 80C186EC
#include "80c186ec.h"
$$END$
$$IFP$ 80C186EB
#include "80c186eb.h"
$$END$
void Init_SerialPort1(void)
{
/* Baud Rate
* Internal Clocking = $$B1CMP.15$
* Baud Rate = @@BAUDRATE1@ at @@FREQ@ MHz
*/
_Set186Register(B1CMP , 0x$$B1CMP$);
/* Serial Port Control
* Serial Port Mode = @@SERMODE1@
* Clear to Send is $%eS1CON.6$
* Receive is $%eS1CON.5$
* Parity $%eS1CON.3$
$$IF$ S1CON.3
* $%tS1CON.4$Even$Odd$ Parity
$$END$
*/
_Set186Register(S1CON , 0x$$S1CON$);
}
##80C186XL ICU#
##80C186EA ICU#
$$IF$ RELREG.12
#define _MEM_SPACE_
#ifndef PCB_BASE
#define PCB_BASE 0x$$RELREG.0-11$00000L
#endif
$$END$
$$IFN$ RELREG.12
#define _IO_SPACE_
#ifndef PCB_BASE
#define PCB_BASE 0x$$RELREG.0-11$00
#endif
$$END$
#include "80c186ea.h"
void Init_InterruptControlUnit(void)
{
/*Interrupt 0
* Special Fully Nested Mode is $%eI0CON.6$
* Cascade Mode is $%eI0CON.5$
* $%tI0CON.4$Level$Edge$-triggered
* Interrupts are $%tI0CON.3$Masked$Enabled$
* Priority Level = @@INT0L@
*/
_Set186Register(I0CON , 0x$$I0CON$);
/*Interrupt 1
* Special Fully Nested Mode is $%eI1CON.6$
* Cascade Mode is $%eI1CON.5$
* $%tI1CON.4$Level$Edge$-triggered
* Interrupts are $%tI1CON.3$Masked$Enabled$
* Priority Level = @@INT1L@
*/
_Set186Register(I1CON , 0x$$I1CON$);
/*Interrupt 2
* $%tI2CON.4$Level$Edge$-triggered
* Interrupts are $%tI2CON.3$Masked$Enabled$
* Priority Level = @@INT2L@
*/
_Set186Register(I2CON , 0x$$I2CON$);
/*Interrupt 3
* $%tI3CON.4$Level$Edge$-triggered
* Interrupts are $%tI3CON.3$Masked$Enabled$
* Priority Level = @@INT3L@
*/
_Set186Register(I3CON , 0x$$I3CON$);
/*DMA 0 Interrupt
* Interrupt is = $%tDMA0CON.3$Masked$Enabled$
* Priority Level = @@DMA0L@
*/
_Set186Register(DMA0CON , 0x$$DMA0CON$);
/*DMA 1 Interrupt
* Interrupt is $%tDMA1CON.3$Masked$Enabled$
* Priority Level = @@DMA1L@
*/
_Set186Register(DMA1CON , 0x$$DMA1CON$);
/*Timer Interrupts
* Interrupt Mask = $%tTCUCON.3$Masked$Enabled$
* Priority Level = @@TCUL@
*/
_Set186Register(TCUCON , 0x$$TCUCON$);
}
##80C186EB ICU#
$$IF$ RELREG.12
#define _MEM_SPACE_
#ifndef PCB_BASE
#define PCB_BASE 0x$$RELREG.0-11$00000L
#endif
$$END$
$$IFN$ RELREG.12
#define _IO_SPACE_
#ifndef PCB_BASE
#define PCB_BASE 0x$$RELREG.0-11$00
#endif
$$END$
#include "80c186eb.h"
void Init_InterruptControlUnit(void)
{
/*Interrupt 0
* Special Fully Nested Mode is $%eI0CON.6$
* Cascade Mode is $%eI0CON.5$
* $%tI0CON.4$Level$Edge$-triggered
* Interrupts are $%tI0CON.3$Masked$Enabled$
* Priority Level = @@INT0L@
*/
_Set186Register(I0CON , 0x$$I0CON$);
/*Interrupt 1
* Special Fully Nested Mode = $$I1CON.6$
* Cascade Mode = $$I1CON.5$
* $%tI1CON.4$Level$Edge$-triggered
* Interrupts are $%tI1CON.3$Masked$Enabled$
* Priority Level = @@INT1L@
*/
_Set186Register(I1CON , 0x$$I1CON$);
/*Interrupt 2
* $%tI2CON.4$Level$Edge$-triggered
* Interrupts are $%tI2CON.3$Masked$Enabled$
* Priority Level = @@INT2L@
*/
_Set186Register(I2CON , 0x$$I2CON$);
/*Interrupt 3
* $%tI3CON.4$Level$Edge$-triggered
* Interrupts are $%tI3CON.3$Masked$Enabled$
* Priority Level = @@INT3L@
*/
_Set186Register(I3CON , 0x$$I3CON$);
/*Interrupt 4
* $%tI4CON.4$Level$Edge$-triggered
* Interrupts are $%tI4CON.3$Masked$Enabled$
* Priority Level = @@INT4L@
*/
_Set186Register(I4CON , 0x$$I4CON$);
/*Serial Port Interrupt
* Interrupts are $%tSCUCON.3$Masked$Enabled$
* Priority Level = @@SCUL@
*/
_Set186Register(SCUCON , 0x$$SCUCON$);
/*Timer Interrupts
* Interrupts are $%tTCUCON.3$Masked$Enabled$
* Priority Level = @@TCUL@
*/
_Set186Register(TCUCON , 0x$$TCUCON$);
}
##80C186EC ICU#
$$IF$ RELREG.12
#define _MEM_SPACE_
#ifndef PCB_BASE
#define PCB_BASE 0x$$RELREG.0-11$00000L
#endif
$$END$
$$IFN$ RELREG.12
#define _IO_SPACE_
#ifndef PCB_BASE
#define PCB_BASE 0x$$RELREG.0-11$00
#endif
$$END$
#include "80c186ec.h"
void Init_InterruptControlUnit(void)
{
/*Slave 8259A, ICW1S through SPICP0
* Level Trigger Mode = $$ICW1S.3$
* Single 8259A = $$ICW1S.1$
* ICW4 = $$ICW1S.0$
*/
_Set186Register(SPICP0 , 0x$$ICW1S$);
/*ICW2S through SPICP1, Base Interrupt Type*/
_Set186Register(SPICP1 , 0x$$ICW2S$);
*ICW3S through SPICP1, Set Slave ID */
_Set186Register(SPICP1 , 07);
/*ICW4S through SPICP1
* Slave ID must be seven
* Initialize ICW4
* Initialize Slave 8259A
* Special Fully Nested Mode = $$ICW4S.4$
* Automatic EOI Mode = $$ICW4S.1$
*/
_Set186Register(SPICP1 , 0x$$ICW4S$);
/*ICW1M through MPICP0
* Initialize Master 8259A
* Level Trigger Mode = $$ICW1M.3$
* Single 8259A = $$ICW1M.1$
* ICW4 = $$ICW1M.0$
*/
_Set186Register(MPICP0 , 0x$$ICW1M$);
/*ICW2M through MPICP1, Base Interrupt Type*/
_Set186Register(MPICP1 , 0x$$ICW2M$);
/*ICW3M through MPICP1, Initialize Slave ID*/
_Set186Register(MPICP1 , 0x$$ICW3M$);
/*ICW4M through MPICP1
* Initialize Slave 8259A
* Special Fully Nested Mode = $$ICW4M.4$
* Automatic EOI Mode = $$ICW4M.1$
*/
_Set186Register(MPICP1 , 0x$$ICW4M$);
}
##80C186EB PM#
##80C186EB Clock#
##80C186EB CPU#
$$IF$ RELREG.12
#define _MEM_SPACE_
#ifndef PCB_BASE
#define PCB_BASE 0x$$RELREG.0-11$00000L
#endif
$$END$
$$IFN$ RELREG.12
#define _IO_SPACE_
#ifndef PCB_BASE
#define PCB_BASE 0x$$RELREG.0-11$00
#endif
$$END$
#include "80c186eb.h"
void Init_PowerManagement(void)
{
/*
* Idle Mode = $%ePWRCON.1$
* PowerDown Mode = $%ePWRCON.0$
*/
_Set186Register(PWRCON , 0x$$PWRCON$);
}
##80C186XL CPU#
##80C186XL Clock#
$$IF$ RELREG.12
#define _MEM_SPACE_
#ifndef PCB_BASE
#define PCB_BASE 0x$$RELREG.0-11$00000L
#endif
$$END$
$$IFN$ RELREG.12
#define _IO_SPACE_
#ifndef PCB_BASE
#define PCB_BASE 0x$$RELREG.0-11$00
#endif
$$END$
#include "80c186ea.h"
void Init_PowerSave(void)
{
/* Power Save Enable = $%ePWRSAV.15$ */
_Set186Register(PWRSAV , 0x$$PWRSAV$);
}
##80C186EA PM#
##80C186EC PM#
##80C186EC Clock#
##80C186EA Clock#
##80C186EA CPU#
##80C186EC CPU#
$$IF$ RELREG.12
#define _MEM_SPACE_
#ifndef PCB_BASE
#define PCB_BASE 0x$$RELREG.0-11$00000L
#endif
$$END$
$$IFN$ RELREG.12
#define _IO_SPACE_
#ifndef PCB_BASE
#define PCB_BASE 0x$$RELREG.0-11$00
#endif
$$END$
$$IFP$ 80C186EC
#include "80c186ec.h"
$$END$
$$IFP$ 80C186EA
#include "80c186ea.h"
$$END$
void Init_PowerManagement(void)
{
/* Idle Mode is $%ePWRCON.1$
* PowerDown Mode is $%ePWRCON.0$
*/
_Set186Register(PWRCON , 0x$$PWRCON$);
/* Power Save Feature is $%ePWRSAV.15$ */
_Set186Register(PWRSAV , 0x$$PWRSAV$);
}
##80C186EC WDT#
Due to the LOCKed instructions required to program
the Watchdog Timer, it cannot be programmed in 'C'.
This peripheral must be programmed using assembly language.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -