1 /*-------------------------------------------------------------------------
2 Register Declarations for the mcs51 compatible microcontrollers
4 Written By - Bela Torok / bela.torok@kssg.ch (November 2000)
6 This program is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 In other words, you are welcome to use, share and improve this program.
21 You are forbidden to forbid anyone else to use, share and improve
22 what you give them. Help stamp out software-hoarding!
27 Version 1.0 Nov 2, 2000 - B. Torok / bela.torok@kssg.ch
28 Initial release, supported microcontrollers:
29 8051, 8052, Atmel AT89C1051, AT89C2051, AT89C4051,
30 Siemens SAB80515, SAB80535, SAB80515A
33 SAB80515A definitions revised by Michael Schmitt / michael.schmitt@t-online.de
35 Adding support for additional microcontrollers:
36 -----------------------------------------------
38 1. Make an entry with the inventory of the register set of
39 the microcontroller in the "Describe microcontrollers" section.
41 2. If necessary add/modify entry(s) in the "Register definitions" section
43 3. If necessary add/modify entry(s) in the "Interrupt vectors" section
45 4. Make a step-by-step protocol of your modifications
47 5. Send the protocol and the modified file to me ( bela.torok@kssg.ch ).
48 I'm going to compile/verify changes made by different authors.
51 Microcontroller support:
53 Use one of the following options:
55 1. use #include <mcs51reg.h> in your program & define REG_XXXXXX in your makefile.
57 2. use following definitions prior the
58 #include <mcs51reg.h> line in your program:
60 #define REG_8052_H -> 8052 type microcontroller
62 #define REG_AT89CX051_H -> Atmel AT89C1051, AT89C2051 and AT89C4051 microcontrollers
65 Use only one of the following definitions!!!
67 Supported Microcontrollers:
72 REG_AT89CX051_H Atmel AT89C1051, AT89C2051 and AT89C4051
73 REG_SAB80515_H Siemens SAB80515 & SAB80535
74 REG_SAB80515A_H Siemens SAB80515A
76 -----------------------------------------------------------------------*/
79 #ifndef HEADER_MCS51REG
80 #define HEADER_MCS51REG
82 //////////////////////////////////
83 /// Describe microcontrollers ///
84 /// (inventory of registers) ///
85 //////////////////////////////////
87 // definitions for the 8051
89 #ifdef MICROCONTROLLER_DEFINED
90 #define MCS51REG_ERROR
92 #ifndef MICROCONTROLLER_DEFINED
93 #define MICROCONTROLLER_DEFINED
95 #warning Selected HW: 8051
120 // end of definitions for the 8051
123 // definitions for the 8052 microcontroller
125 #ifdef MICROCONTROLLER_DEFINED
126 #define MCS51REG_ERROR
128 #ifndef MICROCONTROLLER_DEFINED
129 #define MICROCONTROLLER_DEFINED
131 #warning Selected HW: 8052
156 // 8052 specific registers
164 // end of definitions for the 8052 microcontroller
166 // definitionsons for the Atmel
167 // AT89C1051, AT89C2051 and AT89C4051 microcontrollers
168 #ifdef REG_AT89CX051_H
169 #ifdef MICROCONTROLLER_DEFINED
170 #define MCS51REG_ERROR
172 #ifndef MICROCONTROLLER_DEFINED
173 #define MICROCONTROLLER_DEFINED
175 #warning Selected HW: Atmel AT89Cx051
177 // 8051 register set without P0 & P2
199 // end of definitionsons for the Atmel
200 // AT89C1051, AT89C2051 and AT89C4051 microcontrollers
202 // definitions for the Siemens SAB80515 & SAB80535
203 #ifdef REG_SAB80515_H
204 #ifdef MICROCONTROLLER_DEFINED
205 #define MCS51REG_ERROR
207 #ifndef MICROCONTROLLER_DEFINED
208 #define MICROCONTROLLER_DEFINED
210 #warning Selected HW: Siemens SAB80515 & SAB80535
212 // 8051 register set without IE, IP & PCON
233 // SAB80515 specific registers
234 #define IE_SAB80515_FAMILY
235 #define IP0 ; // interrupt priority register - SAB80515 specific
236 #define IEN1 ; // interrupt enable register - SAB80515 specific
237 #define IRCON ; // interrupt control register - SAB80515 specific
238 #define CCEN ; // compare/capture enable register
239 #define CCL1 ; // compare/capture register 1, low byte
240 #define CCH1 ; // compare/capture register 1, high byte
241 #define CCL2 ; // compare/capture register 2, low byte
242 #define CCH2 ; // compare/capture register 2, high byte
243 #define CCL3 ; // compare/capture register 3, low byte
244 #define CCH3 ; // compare/capture register 3, high byte
246 #define CRCL ; // compare/reload/capture register, low byte
247 #define CRCH ; // compare/reload/capture register, high byte
250 #define ADCON ; // A/D-converter control register
251 #define ADDAT ; // A/D-converter data register
252 #define DAPR ; // D/A-converter program register
253 #define P4 ; // Port 4 - SAB80515 specific
254 #define P5 ; // Port 5 - SAB80515 specific
255 #define PCON_SAB80515 ; // PCON of the SAB80515
258 // end of definitions for the Siemens SAB80515
260 // definitions for the Siemens SAB80515A
261 #ifdef REG_SAB80515A_H
262 #ifdef MICROCONTROLLER_DEFINED
263 #define MCS51REG_ERROR
265 #ifndef MICROCONTROLLER_DEFINED
266 #define MICROCONTROLLER_DEFINED
268 #warning Selected HW: Siemens SAB80515A
270 // 8051 register set without IE, IP & PCON
290 // SAB80515A specific registers
291 #define IE_SAB80515_FAMILY
292 #define IP0 ; // interrupt priority register - SAB80515 specific
293 #define IP1 ; // interrupt priority register - SAB80515 specific
294 #define IEN1 ; // interrupt enable register - SAB80515 specific
295 #define IRCON ; // interrupt control register - SAB80515 specific
296 #define CCEN ; // compare/capture enable register
297 #define CCL1 ; // compare/capture register 1, low byte
298 #define CCH1 ; // compare/capture register 1, high byte
299 #define CCL2 ; // compare/capture register 2, low byte
300 #define CCH2 ; // compare/capture register 2, high byte
301 #define CCL3 ; // compare/capture register 3, low byte
302 #define CCH3 ; // compare/capture register 3, high byte
304 #define CRCL ; // compare/reload/capture register, low byte
305 #define CRCH ; // compare/reload/capture register, high byte
308 #define ADCON0 ; // A/D-converter control register 0
309 #define ADDATH ; // A/D data high byte
310 #define ADDATL ; // A/D data low byte
311 #define ADCON1 ; // A/D-converter control register 1
312 #define SRELL ; // Baudrate generator reload low
313 #define SYSCON ; // XRAM Controller Access Control
314 #define SRELH ; // Baudrate generator reload high
315 #define P4 ; // Port 4 - SAB80515 specific
316 #define P5 ; // Port 5 - SAB80515 specific
317 #define P6 ; // Port 6 - SAB80515 specific
318 #define PCON_SAB80515A ; // PCON of the SAB80515A
319 #define XPAGE ; // Page Address Register for Extended On-Chip RAM
322 // end of definitions for the Siemens SAB80515A
324 /////////////////////////////////////////////////////////
325 /// don't specify microcontrollers below this line! ///
326 /////////////////////////////////////////////////////////
328 // default microcontroller -> 8051
329 // use default if no microcontroller specified
330 #ifndef MICROCONTROLLER_DEFINED
331 #define MICROCONTROLLER_DEFINED
332 #warning //////////////////////////////////
333 #warning // No microcontroller defined! //
334 #warning //////////////////////////////////
335 #warning Code will be generated for the
336 #warning 8051 (default) microcontroller.
337 #warning If you have another microcontroller
338 #warning define it in the makefile, or in the
339 #warning "C" source prior
340 #warning the #include <mcs51reg.h> statement.
341 #warning If you use a non supported
342 #warning microcontroller, mcs51reg.h can be
343 #warning easily extended to support your HW.
369 // end of definitions for the default microcontroller
372 #ifdef MCS51REG_ERROR
373 #error Two or more microcontrollers defined!
376 ////////////////////////////////
377 /// Register definitions ///
378 /// (In alphabetical order) ///
379 ////////////////////////////////
388 sfr at 0xD8 ADCON ; // A/D-converter control register SAB80515 specific
399 /* ADCON0 ... Siemens also called this register ADCON in the User Manual */
402 sfr at 0xD8 ADCON0 ; // A/D-converter control register 0 SAB80515A specific
412 // Not directly accessible ADCON0
413 #define ADCON0_MX0 0x01
414 #define ADCON0_MX1 0x02
415 #define ADCON0_MX2 0x04
416 #define ADCON0_ADM 0x08
417 #define ADCON0_BSY 0x10
418 #define ADCON0_ADEX 0x20
419 #define ADCON0_CLK 0x40
420 #define ADCON0_BD 0x80
425 sfr at 0xD9 ADDAT ; // A/D-converter data register SAB80515 specific
430 sfr at 0xD9 ADDATH ; // A/D data high byte SAB80515A specific
435 sfr at 0xDA ADDATL ; // A/D data low byte SAB80515A specific
440 sfr at 0xDC ADCON1 ; // A/D-converter control register 1 SAB80515A specific
441 // Not directly accessible ADCON1
442 #define ADCON1_MX0 0x01
443 #define ADCON1_MX1 0x02
444 #define ADCON1_MX2 0x04
445 #define ADCON1_ADCL 0x80
452 sbit at 0xF0 BREG_F0 ;
453 sbit at 0xF1 BREG_F1 ;
454 sbit at 0xF2 BREG_F2 ;
455 sbit at 0xF3 BREG_F3 ;
456 sbit at 0xF4 BREG_F4 ;
457 sbit at 0xF5 BREG_F5 ;
458 sbit at 0xF6 BREG_F6 ;
459 sbit at 0xF7 BREG_F7 ;
464 sfr at 0xC1 CCEN ; // compare/capture enable register SAB80515 specific
469 sfr at 0xC3 CCH1 ; // compare/capture register 1, high byte SAB80515 specific
474 sfr at 0xC5 CCH2 ; // compare/capture register 2, high byte SAB80515 specific
479 sfr at 0xC7 CCH3 ; // compare/capture register 3, high byte SAB80515 specific
484 sfr at 0xC2 CCL1 ; // compare/capture register 1, low byte SAB80515 specific
489 sfr at 0xC4 CCL2 ; // compare/capture register 2, low byte SAB80515 specific
494 sfr at 0xC6 CCL3 ; // compare/capture register 3, low byte SAB80515 specific
499 sfr at 0xCB CRCH ; // compare/reload/capture register, high byte SAB80515 specific
504 sfr at 0xCA CRCL ; // compare/reload/capture register, low byte SAB80515 specific
509 sfr at 0xD8 DAPR ; // D/A-converter program register SAB80515 specific
533 sbit at 0xAD ET2 ; // Enable timer2 interrupt
537 #ifdef IE_SAB80515_FAMILY
538 #undef IE_SAB80515_FAMILY
540 sfr at 0xA8 IEN0 ; // IE as called by Siemens
547 sbit at 0xAD ET2 ; // Enable timer 2 overflow SAB80515 specific
548 sbit at 0xAE WDT ; // watchdog timer reset - SAB80515 specific
550 sbit at 0xAF EAL ; // EA as called by Siemens
551 #endif // IE_SAB80515_FAMILY
555 sfr at 0xB8 IEN1 ; // interrupt enable register - SAB80515 specific
557 sbit at 0xB8 EADC ; // A/D converter interrupt enable
563 sbit at 0xBE SWDT ; // watchdog timer start/reset
564 sbit at 0xBF EXEN2 ; // timer2 external reload interrupt enable
580 sfr at 0xA9 IP0 ; // interrupt priority register SAB80515 specific
581 // Not directly accessible IP1 bits
593 sfr at 0xB9 IP1 ; // interrupt priority register SAB80515 specific
594 // Not directly accessible IP1 bits
605 sfr at 0xC0 IRCON ; // interrupt control register - SAB80515 specific
607 sbit at 0xC0 IADC ; // A/D converter irq flag
608 sbit at 0xC1 IEX2 ; // external interrupt edge detect flag
613 sbit at 0xC6 TF2 ; // timer 2 owerflow flag
614 sbit at 0xC7 EXF2 ; // timer2 reload flag
643 #ifdef REG_SAB80515_H
644 sbit at 0x90 INT3_CC0 ; // P1 alternate functions - SAB80515 specific
645 sbit at 0x91 INT4_CC1 ;
646 sbit at 0x92 INT5_CC2 ;
647 sbit at 0x93 INT6_CC3 ;
650 sbit at 0x96 CLKOUT ;
653 #ifdef REG_SAB80515A_H
654 sbit at 0x90 INT3_CC0 ; // P1 alternate functions - SAB80515 specific
655 sbit at 0x91 INT4_CC1 ;
656 sbit at 0x92 INT5_CC2 ;
657 sbit at 0x93 INT6_CC3 ;
660 sbit at 0x96 CLKOUT ;
704 sfr at 0xE8 P4 ; // Port 4 - SAB80515 specific
718 sfr at 0xF8 P5 ; // Port 5 - SAB80515 specific
732 sfr at 0xDB P6 ; // Port 6 - SAB80515 specific
738 // Not directly accessible PCON bits
749 // Not directly accessible PCON bits
753 #ifdef PCON_SAB80515A
754 #undef PCON_SAB80515A
756 // Not directly accessible PCON bits
758 #define IDLE 0x01 ; same as IDL
760 #define PDE 0x02 ; same as PD
767 #define PCON_IDLE 0x01
768 #define PCON_PDE 0x02
769 #define PCON_GF0 0x04
770 #define PCON_GF1 0x08
771 #define PCON_IDLS 0x20
772 #define PCON_PDS 0x40
773 #define PCON_SMOD 0x80
826 sfr at 0xBA SRELH ; // Baudrate generator reload high
831 sfr at 0xAA SRELL ; // Baudrate generator reload low
836 sfr at 0xB1 SYSCON ; // XRAM Controller Access Control
838 #define SYSCON_XMAP0 0x01
839 #define SYSCON_XMAP1 0x02
840 #define SYSCON_RMAP 0x10
841 #define SYSCON_EALE 0x20
848 sbit at 0xC8 T2CON_0 ;
849 sbit at 0xC9 T2CON_1 ;
850 sbit at 0xCA T2CON_2 ;
851 sbit at 0xCB T2CON_3 ;
852 sbit at 0xCC T2CON_4 ;
853 sbit at 0xCD T2CON_5 ;
854 sbit at 0xCE T2CON_6 ;
855 sbit at 0xCF T2CON_7 ;
914 // Not directly accessible TMOD bits
930 sfr at 0x91 XPAGE ; // Page Address Register for Extended On-Chip Ram - Siemens SAB80515A specific
934 /////////////////////////
935 /// Interrupt vectors ///
936 /////////////////////////
938 // Interrupt numbers: address = (number * 8) + 3
939 #define IE0_VECTOR 0 // 0x03 external interrupt 0
940 #define TF0_VECTOR 1 // 0x0b timer 0
941 #define IE1_VECTOR 2 // 0x13 external interrupt 1
942 #define TF1_VECTOR 3 // 0x1b timer 1
943 #define SI0_VECTOR 4 // 0x23 serial port 0
946 #ifdef REG_SAB80515_H
947 // Interrupt numbers: address = (number * 8) + 3
948 #define TF2_VECTOR 5 // 0x2B timer 2
949 #define EX2_VECTOR 5 // 0x2B external interrupt 2
951 #define IADC_VECTOR 8 // 0x43 A/D converter interrupt
952 #define IEX2_VECTOR 9 // 0x4B external interrupt 2
953 #define IEX3_VECTOR 10 // 0x53 external interrupt 3
954 #define IEX4_VECTOR 11 // 0x5B external interrupt 4
955 #define IEX5_VECTOR 12 // 0x63 external interrupt 5
956 #define IEX6_VECTOR 13 // 0x6B external interrupt 6
959 #ifdef REG_SAB80515A_H
960 // Interrupt numbers: address = (number * 8) + 3
961 #define TF2_VECTOR 5 // 0x2B timer 2
962 #define EX2_VECTOR 5 // 0x2B external interrupt 2
964 #define IADC_VECTOR 8 // 0x43 A/D converter interrupt
965 #define IEX2_VECTOR 9 // 0x4B external interrupt 2
966 #define IEX3_VECTOR 10 // 0x53 external interrupt 3
967 #define IEX4_VECTOR 11 // 0x5B external interrupt 4
968 #define IEX5_VECTOR 12 // 0x63 external interrupt 5
969 #define IEX6_VECTOR 13 // 0x6B external interrupt 6
972 #endif // End of the header -> #ifndef MCS51REG_H