1 /*-------------------------------------------------------------------------
2 stc12.h - Register Declarations for STC10/11/12 Series
3 Based on 8051.h and compiler.h
5 Copyright (c) 2012, intron@intron.ac
7 This library is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 2, or (at your option) any
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this library; see the file COPYING. If not, write to the
19 Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
22 As a special exception, if you link this library with other files,
23 some of which are compiled with SDCC, to produce an executable,
24 this library does not by itself cause the resulting executable to
25 be covered by the GNU General Public License. This exception does
26 not however invalidate any other reasons why the executable file
27 might be covered by the GNU General Public License.
28 -------------------------------------------------------------------------*/
33 STC10/11/12 series are 8051-compatible MCU's. The "official" website
34 is http://www.stcmcu.com/ (In Chinese Han only), and datasheets in Chinese
35 Han and English can be downloaded there.
39 1. The "official" C header file (written for another C51 compiler):
40 http://www.stcmcu.com/datasheet/stc/STC-AD-PDF/STC_NEW_8051.H
41 2. Datasheets for STC12(C/LE)5Axx(S2/AD) series:
43 http://www.stcmcu.com/datasheet/stc/STC-AD-PDF/STC12C5A60S2.pdf
45 http://www.stcmcu.com/datasheet/stc/STC-AD-PDF/STC12C5A60S2-english.pdf
46 3. Datasheets for STC12(C/LE)52xxAD series:
48 http://www.stcmcu.com/datasheet/stc/STC-AD-PDF/STC12C5201AD.pdf
50 http://www.stcmcu.com/datasheet/stc/STC-AD-PDF/STC12C5201AD-english.pdf
51 4. Datasheets for STC11/10 series:
53 http://www.stcmcu.com/datasheet/stc/STC-AD-PDF/STC11F-10Fxx.pdf
55 http://www.stcmcu.com/datasheet/stc/STC-AD-PDF/STC11F-10Fxx-english.pdf
70 * Bit Mapping: T0x12 T1x12 UART_M0x6 BRTR S2SMOD BRTx12 EXTRAM S1BRS
71 * Reset Value: 0000,0000
76 * Auxiliary Register 1
77 * Bit Mapping: - PCA_P4 SPI_P4 S2_P4 GF2 ADRJ - DPS
78 * Reset Value: x000,00x0
83 * Control Register for Clock Output and Power Down Wake-up
84 * Bit Mapping: PCAWAKEUP RXD_PIN_IE T1_PIN_IE T0_PIN_IE
85 * LVD_WAKE BRTCLKO T1CLKO T0CLKO
86 * (Here "O" is the letter meaning "output", not the digit.)
87 * Reset Value: 0000,0000
92 * Clock Devider Register
93 * Bit Mapping: - - - - - CLKS2 CLKS1 CLKS0
94 * Reset Value: xxxx,x000
100 * Bit Mapping: - - ALES1 ALES0 - RWS2 RWS1 RWS0
101 * Reset Value: xx10,x011
103 SFR(BUS_SPEED
, 0xA1);
105 /* Two extended bits in IE */
106 SBIT(ELVD
, 0xA8, 6); /* Enable Low Voltage Detection Interrupt */
107 SBIT(EADC
, 0xA8, 5); /* Enable ADC Interrupt */
110 * Auxiliary Interrupt Register
111 * Bit Mapping: - - - - - - ESPI ES2
112 * Reset Value: xxxx,xx00
116 /* Three extended bits in IP */
117 SBIT(PPCA
, 0xB8, 7); /* Interrupt Priority for PCA */
118 SBIT(PLVD
, 0xB8, 6); /* Interrupt Priority for Low Voltage Detection */
119 SBIT(PADC
, 0xB8, 5); /* Interrupt Priority for ADC */
122 * Higher bits for Interrupt Priority
123 * Bit Mapping: PPCAH PLVDH PADCH PSH PT1H PX1H PT0H PX0H
124 * Reset Value: 0000,0000
129 * The 2nd Interrupt Priority Register, Lower bits
130 * Bit Mapping: - - - - - - PSPI PS2
131 * Reset Value: xxxx,xx00
136 * The 2nd Interrupt Priority Register, Higher bits
137 * Bit Mapping: - - - - - - PSPIH PS2H
138 * Reset Value: xxxx,xx00
143 * Two Extended GPIO Ports: P4 and P5
144 * - For DIP-40 and QFN-40 packages, only higher 4 bits of P4 are available.
145 * - For PLCC-44 and LQFP-44 packages, only all 8 bits of P4 are available.
146 * - For LQFP-48 package, all 8 bits of P4 and lower 4 bits of P5 are
158 SFR(P5
, 0xC8); /* Only lower 4 bits */
164 /* Working Mode Registers for P0, P1, P2, P3, P4 and P5 */
175 SFR(P4SW
, 0xBB); /* - LVD_P4.6 ALE_P4.5 NA_P4.4 - - - - Reset: x000,xxxx */
179 /* Slave Address Mask for Serial Communication */
182 /* Slave Address for Serial Communication */
186 * The Control Register for the 2nd Serial Communication Port
187 * Bit Mapping: S2SM0 S2SM1 S2SM2 S2REN S2TB8 S2RB8 S2TI S2RI
188 * Reset Value: 0000,0000
192 /* Data Buffer Register for the 2nd Serial Communication Port */
196 * Reload Value Register for the Specific Baud Rate Generator
197 * (Independent from the 8051 Timer)
202 * Watchdog Timer Control Register
203 * Bit Mapping: WDT_FLAG - EN_WDT CLR_WDT IDLE_WDT PS2 PS1 PS0
204 * Reset Value: 0x00,0000
206 SFR(WDT_CONTR
, 0xC1);
209 * PCA Control Register
210 * Bit Mapping: CF CR - - - - CCF1 CCF0
211 * Reset Value: 00xx,xx00
221 * Bit Mapping: CIDL - - - CPS2 CPS1 CPS0 ECF
222 * Reset Value: 0xxx,x000
226 /* PCA Counter Registers */
227 SFR(CL
, 0xE9); /* Lower 8 bits */
228 SFR(CH
, 0xF9); /* Higher 8 bits */
231 * PCA Module 0 PWM Register
232 * Bit Mapping: - ECOM0 CAPP0 CAPN0 MAT0 TOG0 PWM0 ECCF0
233 * Reset Value: x000,0000
238 * PCA Module 1 PWM Register
239 * Bit Mapping: - ECOM1 CAPP1 CAPN1 MAT1 TOG1 PWM1 ECCF1
240 * Reset Value: x000,0000
244 /* PCA Module 0/1 Capture/Comparison Registers */
251 * PCA Module 0 PWM Auxiliary Register
252 * Bit Mapping: - - - - - - EPC0H EPC0L
253 * Reset Value: xxxx,xx00
258 * PCA Module 1 PWM Auxiliary Register
259 * Bit Mapping: - - - - - - EPC1H EPC1L
260 * Reset Value: xxxx,xx00
264 /* Switch P1 pins between ADC inputs and GPIO Port pins */
268 * ADC Control Register
269 * Bit Mapping: ADC_POWER SPEED1 SPEED0 ADC_FLAG ADC_START CHS2 CHS1 CHS0
270 * Reset Value: 0000,0000
272 SFR(ADC_CONTR
, 0xBC);
274 /* ADC Converting Result Registers */
275 SFR(ADC_RES
, 0xBD); /* Higher Bits */
276 SFR(ADC_RESL
, 0xBE); /* Lower Bits */
279 * SPI Control Register
280 * Bit Mapping: SSIG SPEN DORD MSTR CPOL CPHA SPR1 SPR0
281 * Reset Value: 0000,0100
286 * SPI Status Register
287 * Bit Mapping: SPIF WCOL - - - - - -
288 * Reset Value: 00xx,xxxx
292 /* SPI Data Register */
295 /* In-Application-Programming Data Register */
298 /* In-Application-Programming Address Registers */
299 SFR(IAP_ADDRH
, 0xC3); /* Higher 8 bits */
300 SFR(IAP_ADDRL
, 0xC4); /* Lower 8 bits */
303 * In-Application-Programming Address Registers
304 * Bit Mapping: - - - - - - MS1 MS0
305 * Reset Value: xxxx,xx00
309 /* In-Application-Programming Trigger Registers */
313 * In-Application-Programming Control Register
314 * Bit Mapping: IAPEN SWBS SWRST CFAIL - WT2 WT1 WT0
315 * Reset Value: 0000,x000
317 SFR(IAP_CONTR
, 0xC7);
319 #endif /* _STC12_H_ */