1 /*-------------------------------------------------------------------------
2 p89lpc933_4.h - This header allows to use the microcontrolers NXP
3 (formerly Philips) p89lpc933, 934.
5 Copyright (C) 2008, Gudjon I. Gudjonsson <gudjon AT gudjon.org>
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 /*-------------------------------------------------------------------------
31 The registered are ordered in the same way as in the NXP data sheet:
32 http://www.standardics.nxp.com/products/lpc900/datasheet/p89lpc933.p89lpc934.p89lpc935.p89lpc936.pdf
33 -------------------------------------------------------------------------*/
35 #ifndef __P89LPC933_4_H__
36 #define __P89LPC933_4_H__
40 SFR(ACC
, 0xE0); // Accumulator
49 SFR(ADCON0
, 0x8E); // A/D control register 0
51 SFR(ADCON1
, 0x97); // A/D control register 1
60 SFR(ADINS
, 0xA3); // A/D input select
65 SFR(ADMODA
, 0xC0); // A/D mode register A
67 SBIT(BURST1
, 0xC0, 6);
70 SFR(ADMODB
, 0xA1); // A/D mode register B
77 SFR(AD0DAT3
, 0xF4); // A/D_0 data register 3
78 SFR(AD1BH
, 0xC4); // A/D_1 boundary high register
79 SFR(AD1BL
, 0xBC); // A/D_1 boundary low register
80 SFR(AD1DAT0
, 0xD5); // A/D_1 data register 0
81 SFR(AD1DAT1
, 0xD6); // A/D_1 data register 1
82 SFR(AD1DAT2
, 0xD7); // A/D_1 data register 2
83 SFR(AD1DAT3
, 0xF5); // A/D_1 data register 3
84 SFR(AUXR1
, 0xA2); // Auxilary function register
89 #define SRST 0x08 // Bit 2 is always 0
91 SFR(B
, 0xF0); // B register
100 SFR(BRGR0
, 0xBE); // Baud rate generator rate low
101 SFR(BRGR1
, 0xBF); // Baud rate generator rate high
102 SFR(BRGCON
, 0xBD); // Baud rate generator control
105 SFR(CMP1
, 0xAC); // Comparator 1 control register
112 SFR(CMP2
, 0xAD); // Comparator 2 control register
119 SFR(DIVM
, 0x95); // CPU clock divide-by-M control
120 SFR(DPH
, 0x83); // Data Pointer High
121 SFR(DPL
, 0x82); // Data Pointer Low
122 SFR(FMADRH
, 0xE7); // Program flash address high
123 SFR(FMADRL
, 0xE6); // Program flash address low
125 // Program flash control (Read)
131 // Program flash control (Write)
140 SFR(FMDATA
, 0xE5); // Program flash data
141 SFR(I2ADR
, 0xDB); // I2C slave address register
150 SFR(I2CON
, 0xD8); // I2C control register
156 SBIT(CRSEL
, 0xD8, 0);
157 SFR(I2DAT
, 0xDA); // I2C data register
158 SFR(I2SCLH
, 0xDD); // I2C serial clock generator/SCL duty cycle register high
159 SFR(I2SCLL
, 0xDC); // I2C serial clock generator/SCL duty cycle register low
160 SFR(I2STAT
, 0xD9); // I2C status register
165 #define STA_0 0x08 // Only write 0 to the lowest three bits
166 SFR(ICRAH
, 0xAB); // Input capture A register high
167 SFR(ICRAL
, 0xAA); // Input capture A register low
168 SFR(ICRBH
, 0xAF); // Input capture B register high
169 SFR(ICRBL
, 0xAE); // Input capture B register low
170 SFR(IEN0
, 0xA8); // Interrupt Enable 0
172 SBIT(EWDRT
, 0xA8, 6);
174 SBIT(ES_ESR
, 0xA8, 4);
179 SFR(IEN1
, 0xE8); // Interrupt Enable 1
186 SFR(IP0
, 0xB8); // Interrupt Priority 0
187 SBIT(PWDRT
, 0xB8, 6);
189 SBIT(PS_PSR
, 0xB8, 4);
194 SFR(IP0H
, 0xB7); // Interrupt Priority 0 high
197 #define PSH_PSRH 0x10
202 SFR(IP1
, 0xF8); // Interrupt Priority 1
209 SFR(IP1H
, 0xF7); // Interrupt Priority 1 High
216 SFR(KBCON
, 0x94); // Keypad control register
217 #define PATN_SEL 0x02
219 SFR(KBMASK
, 0x86); // Keypad interrupt mask register
220 SFR(KBPATN
, 0x93); // Keypad pattern register
221 SFR(P0
, 0x80); // Port 0
226 SBIT(CMP_1
, 0x80, 6); // Renamed, not to conflict with the CMP1 register
229 SBIT(CMPREF
,0x80, 5);
232 SBIT(CIN1A
, 0x80, 4);
235 SBIT(CIN1B
, 0x80, 3);
238 SBIT(CIN2A
, 0x80, 2);
241 SBIT(CIN2B
, 0x80, 1);
244 SBIT(CMP_2
, 0x80, 0); // Renamed, not to conflict with the CMP2 register
246 SFR(P1
, 0x90); // Port 1
263 SFR(P2
, 0xA0); // Port 2
267 SBIT(SPICLK
, 0xA0, 5);
276 SFR(P3
, 0xB0); // Port 3
287 SFR(P0M1
, 0x84); // Port 0 output mode 1
296 SFR(P0M2
, 0x85); // Port 0 output mode 2
305 SFR(P1M1
, 0x91); // Port 1 output mode 1
313 SFR(P1M2
, 0x92); // Port 1 output mode 2
321 SFR(P2M1
, 0xA4); // Port 2 output mode 1
330 SFR(P2M2
, 0xA5); // Port 2 output mode 2
339 SFR(P3M1
, 0xB1); // Port 3 output mode 1
342 SFR(P3M2
, 0xB2); // Port 3 output mode 2
345 SFR(PCON
, 0x87); // Power control register
354 SFR(PCONA
, 0xB5); // Power control register A
361 SFR(PSW
, 0xD0); // Program Status Word
370 SFR(PT0AD
, 0xF6); // Port 0 digital input disable
376 SFR(RSTSRC
, 0xDF); // Reset source register
383 SFR(RTCCON
, 0xD1); // Real-time clock control
389 SFR(RTCH
, 0xD2); // Real-time clock register high
390 SFR(RTCL
, 0xD3); // Real-time clock register low
391 SFR(SADDR
, 0xA9); // Serial port address register
392 SFR(SADEN
, 0xB9); // Serial port address enable
393 SFR(SBUF
, 0x99); // Serial port data buffer register
394 SFR(SCON
, 0x98); // Serial port control
395 SBIT(SM0_FE
, 0x98, 7);
403 SFR(SSTAT
, 0xBA); // Serial port extended status register
412 SFR(SP
, 0x81); // Stack Pointer
413 SFR(SPCTL
, 0xE2); // SPI control register
422 SFR(SPSTAT
, 0xE1); // SPI status register
425 SFR(SPDAT
, 0xE3); // SPI data register
426 SFR(TAMOD
, 0x8F); // Timer 0 and 1 auxiliary mode
429 SFR(TCON
, 0x88); // Timer 0 and 1 control
438 SFR(TH0
, 0x8C); // Timer 0 high
439 SFR(TH1
, 0x8D); // Timer 1 high
440 SFR(TL0
, 0x8A); // Timer 0 low
441 SFR(TL1
, 0x8B); // Timer 1 low
442 SFR(TMOD
, 0x89); // Timer 0 and 1 mode
451 SFR(TRIM
, 0x96); // Internal oscillator trim register
460 SFR(WDCON
, 0xA7); // Watchdog control register
467 SFR(WDL
, 0xC1); // Watchdog load
468 SFR(WFEED1
, 0xC2); // Watchdog feed 1
469 SFR(WFEED2
, 0xC3); // Watchdog feed 2
470 #endif // __P89LPC933_4_H__