1 /*-------------------------------------------------------------------------
2 p89lpc9331.h - Register Declarations for NXP the P89LPC9331/P89LPC9341
3 (Based on user manual (UM10308_3) Rev. 03 - 17 June 2009)
5 Copyright (C) 2009, Jesus Calvino-Fraga / jesusc at ece.ubc.ca
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 -------------------------------------------------------------------------*/
30 #ifndef REG_P89LPC9331_H
31 #define REG_P89LPC9331_H
35 SFR(ACC
, 0xe0); // Accumulator
44 SFR(ADCON0
, 0x8e); // A/D control register 0
53 SFR(ADCON1
, 0x97); // A/D control register 1
62 SFR(ADINS
, 0xa3); // A/D input select
71 SFR(ADMODA
, 0xc0); // A/D mode register A
72 SBIT(ADMODA_7
, 0xc0, 7);
73 SBIT(ADMODA_6
, 0xc0, 6);
74 SBIT(ADMODA_5
, 0xc0, 5);
75 SBIT(ADMODA_4
, 0xc0, 4);
76 SBIT(ADMODA_3
, 0xc0, 3);
77 SBIT(ADMODA_2
, 0xc0, 2);
78 SBIT(ADMODA_1
, 0xc0, 1);
79 SBIT(ADMODA_0
, 0xc0, 0);
81 SBIT(BURST1
, 0xc0, 6);
85 SBIT(BURST0
, 0xc0, 2);
88 SFR(ADMODB
, 0xa1); // A/D mode register B
97 SFR(AD0BH
, 0xbb); // A/D_0 boundary high register
98 SFR(AD0BL
, 0xa6); // A/D_0 boundary low register
99 SFR(AD0DAT0
, 0xc5); // A/D_0 data register 0
100 SFR(AD0DAT1
, 0xc6); // A/D_0 data register 1
101 SFR(AD0DAT2
, 0xc7); // A/D_0 data register 2
102 SFR(AD0DAT3
, 0xf4); // A/D_0 data register 3
103 SFR(AD1BH
, 0xc4); // A/D_1 boundary high register
104 SFR(AD1BL
, 0xbc); // A/D_1 boundary low register
105 SFR(AD1DAT0
, 0xd5); // A/D_1 data register 0
106 SFR(AD1DAT1
, 0xd6); // A/D_1 data register 1
107 SFR(AD1DAT2
, 0xd7); // A/D_1 data register 2
108 SFR(AD1DAT3
, 0xf5); // A/D_1 data register 3
109 SFR(AUXR1
, 0xa2); // Auxiliary function register
116 SFR(B
, 0xf0); // B register
125 SFR(BRGR0
, 0xbe); // Baud rate generator 0 rate low
126 SFR(BRGR1
, 0xbf); // Baud rate generator 0 rate high
127 SFR(BRGCON
, 0xbd); // Baud rate generator 0 control
130 SFR(CMP1
, 0xac); // Comparator 1 control register
137 SFR(CMP2
, 0xad); // Comparator 2 control register
144 SFR(DIVM
, 0x95); // CPU clock divide-by-M control
145 SFR(DPH
, 0x83); // Data pointer high
146 SFR(DPL
, 0x82); // Data pointer low
147 SFR(FMADRH
, 0xe7); // Program flash address high
148 SFR(FMADRL
, 0xe6); // Program flash address low
149 SFR(FMCON
, 0xe4); // Program flash control Read
163 SFR(FMDATA
, 0xe5); // Program flash data
164 SFR(I2ADR
, 0xdb); // I2C-bus slave address register
173 SFR(I2CON
, 0xd8); // I2C-bus control register
174 SBIT(I2CON_7
, 0xd8, 7);
175 SBIT(I2CON_6
, 0xd8, 6);
176 SBIT(I2CON_5
, 0xd8, 5);
177 SBIT(I2CON_4
, 0xd8, 4);
178 SBIT(I2CON_3
, 0xd8, 3);
179 SBIT(I2CON_2
, 0xd8, 2);
180 SBIT(I2CON_1
, 0xd8, 1);
181 SBIT(I2CON_0
, 0xd8, 0);
187 SBIT(CRSEL
, 0xd8, 0);
188 SFR(I2DAT
, 0xda); // I2C-bus data register
189 SFR(I2SCLH
, 0xdd); // Serial clock generator/SCL duty cycle register high
190 SFR(I2SCLL
, 0xdc); // Serial clock generator/SCL duty cycle register low
191 SFR(I2STAT
, 0xd9); // I2C-bus status register
197 SFR(IEN0
, 0xa8); // Interrupt enable 0
198 SBIT(IEN0_7
, 0xa8, 7);
199 SBIT(IEN0_6
, 0xa8, 6);
200 SBIT(IEN0_5
, 0xa8, 5);
201 SBIT(IEN0_4
, 0xa8, 4);
202 SBIT(IEN0_3
, 0xa8, 3);
203 SBIT(IEN0_2
, 0xa8, 2);
204 SBIT(IEN0_1
, 0xa8, 1);
205 SBIT(IEN0_0
, 0xa8, 0);
207 SBIT(EWDRT
, 0xa8, 6);
215 SFR(IEN1
, 0xe8); // Interrupt enable 1
216 SBIT(IEN1_7
, 0xe8, 7);
217 SBIT(IEN1_6
, 0xe8, 6);
218 SBIT(IEN1_5
, 0xe8, 5);
219 SBIT(IEN1_4
, 0xe8, 4);
220 SBIT(IEN1_3
, 0xe8, 3);
221 SBIT(IEN1_2
, 0xe8, 2);
222 SBIT(IEN1_1
, 0xe8, 1);
223 SBIT(IEN1_0
, 0xe8, 0);
230 SFR(IP0
, 0xb8); // Interrupt priority 0
231 SBIT(IP0_7
, 0xb8, 7);
232 SBIT(IP0_6
, 0xb8, 6);
233 SBIT(IP0_5
, 0xb8, 5);
234 SBIT(IP0_4
, 0xb8, 4);
235 SBIT(IP0_3
, 0xb8, 3);
236 SBIT(IP0_2
, 0xb8, 2);
237 SBIT(IP0_1
, 0xb8, 1);
238 SBIT(IP0_0
, 0xb8, 0);
239 SBIT(PWDRT
, 0xb8, 6);
247 SFR(IP0H
, 0xb7); // Interrupt priority 0 high
256 SFR(IP1
, 0xf8); // Interrupt priority 1
257 SBIT(IP1_7
, 0xf8, 7);
258 SBIT(IP1_6
, 0xf8, 6);
259 SBIT(IP1_5
, 0xf8, 5);
260 SBIT(IP1_4
, 0xf8, 4);
261 SBIT(IP1_3
, 0xf8, 3);
262 SBIT(IP1_2
, 0xf8, 2);
263 SBIT(IP1_1
, 0xf8, 1);
264 SBIT(IP1_0
, 0xf8, 0);
271 SFR(IP1H
, 0xf7); // Interrupt priority 1 high
278 SFR(KBCON
, 0x94); // Keypad control register
281 SFR(KBMASK
, 0x86); // Keypad interrupt mask register
282 SFR(KBPATN
, 0x93); // Keypad pattern register
283 SFR(P0
, 0x80); // Port 0
294 SBIT(CMP_1
, 0x80, 6);
296 SBIT(CMPREF
, 0x80, 5);
298 SBIT(CIN1A
, 0x80, 4);
300 SBIT(CIN1B
, 0x80, 3);
302 SBIT(CIN2A
, 0x80, 2);
304 SBIT(CIN2B
, 0x80, 1);
306 SBIT(CMP_2
, 0x80, 0);
308 SFR(P1
, 0x90); // Port 1
325 SFR(P2
, 0xa0); // Port 2
334 SBIT(SPICLK
, 0xa0, 5);
338 SFR(P3
, 0xb0); // Port 3
347 SBIT(XTAL1
, 0xb0, 1);
348 SBIT(XTAL2
, 0xb0, 0);
349 SFR(P0M1
, 0x84); // Port 0 output mode 1
358 SFR(P0M2
, 0x85); // Port 0 output mode 2
367 SFR(P1M1
, 0x91); // Port 1 output mode 1
375 SFR(P1M2
, 0x92); // Port 1 output mode 2
383 SFR(P2M1
, 0xa4); // Port 2 output mode 1
392 SFR(P2M2
, 0xa5); // Port 2 output mode 2
401 SFR(P3M1
, 0xb1); // Port 3 output mode 1
404 SFR(P3M2
, 0xb2); // Port 3 output mode 2
407 SFR(PCON
, 0x87); // Power control register
415 SFR(PCONA
, 0xb5); // Power control register A
422 SFR(PSW
, 0xd0); // Programstatus word
423 SBIT(PSW_7
, 0xd0, 7);
424 SBIT(PSW_6
, 0xd0, 6);
425 SBIT(PSW_5
, 0xd0, 5);
426 SBIT(PSW_4
, 0xd0, 4);
427 SBIT(PSW_3
, 0xd0, 3);
428 SBIT(PSW_2
, 0xd0, 2);
429 SBIT(PSW_1
, 0xd0, 1);
430 SBIT(PSW_0
, 0xd0, 0);
439 SFR(PT0AD
, 0xf6); // Port 0 digital input disable
445 SFR(RSTSRC
, 0xdf); // Reset source register
453 SFR(RTCCON
, 0xd1); // RTC control
459 SFR(RTCH
, 0xd2); // RTC register high
460 SFR(RTCL
, 0xd3); // RTC register low
461 SFR(SADDR
, 0xa9); // Serial port address register
462 SFR(SADEN
, 0xb9); // Serial port address enable
463 SFR(SBUF
, 0x99); // Serial Port data buffer register
464 SFR(SCON
, 0x98); // Serial port control
465 SBIT(SCON_7
, 0x98, 7);
466 SBIT(SCON_6
, 0x98, 6);
467 SBIT(SCON_5
, 0x98, 5);
468 SBIT(SCON_4
, 0x98, 4);
469 SBIT(SCON_3
, 0x98, 3);
470 SBIT(SCON_2
, 0x98, 2);
471 SBIT(SCON_1
, 0x98, 1);
472 SBIT(SCON_0
, 0x98, 0);
482 SFR(SSTAT
, 0xba); // Serial port extended status register
491 SFR(SP
, 0x81); // Stack pointer
492 SFR(SPCTL
, 0xe2); // SPI control register
501 SFR(SPSTAT
, 0xe1); // SPI status register
504 SFR(SPDAT
, 0xe3); // SPI data register
505 SFR(TAMOD
, 0x8f); // Timer 0 and 1 auxiliary mode
508 SFR(TCON
, 0x88); // Timer 0 and 1 control
509 SBIT(TCON_7
, 0x88, 7);
510 SBIT(TCON_6
, 0x88, 6);
511 SBIT(TCON_5
, 0x88, 5);
512 SBIT(TCON_4
, 0x88, 4);
513 SBIT(TCON_3
, 0x88, 3);
514 SBIT(TCON_2
, 0x88, 2);
515 SBIT(TCON_1
, 0x88, 1);
516 SBIT(TCON_0
, 0x88, 0);
525 SFR(TH0
, 0x8c); // Timer 0 high
526 SFR(TH1
, 0x8d); // Timer 1 high
527 SFR(TL0
, 0x8a); // Timer 0 low
528 SFR(TL1
, 0x8b); // Timer 1 low
529 SFR(TMOD
, 0x89); // Timer 0 and 1 mode
538 SFR(TRIM
, 0x96); // Internal oscillator trim register
547 SFR(WDCON
, 0xa7); // Watchdog control register
554 SFR(WDL
, 0xc1); // Watchdog load
555 SFR(WFEED1
, 0xc2); // Watchdog feed 1
556 SFR(WFEED2
, 0xc3); // Watchdog feed 2
557 SFRX(BODCFG
, 0xffc8); // BOD configuration register
560 SFRX(CLKCON
, 0xffde); // CLOCK Control register
567 SFRX(TPSCON
, 0xffca); // Temperature sensor control register
570 SFRX(RTCDATH
, 0xffbf); // Real-time clock data register high
571 SFRX(RTCDATL
, 0xffbe); // Real-time clock data register low
572 #endif /*REG_P89LPC9331_H*/