1 /*-------------------------------------------------------------------------
2 p89lpc935_6.h - This header allows to use the microcontrolers NXP
3 (formerly Philips) p89lpc935, 936.
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 __P89LPC935_6_H__
36 #define __P89LPC935_6_H__
40 SFR(ACC
, 0xE0); // Accumulator
49 SFR(ADCON0
, 0x8E); // A/D control register 0
58 SFR(ADCON1
, 0x97); // A/D control register 1
67 SFR(ADINS
, 0xA3); // A/D input select
76 SFR(ADMODA
, 0xC0); // A/D mode register A
78 SBIT(BURST1
, 0xC0, 6);
82 SBIT(BURST0
, 0xC0, 2);
85 SFR(ADMODB
, 0xA1); // A/D mode register B
93 SFR(AD0BH
, 0xBB); // A/D_0 boundary high register
94 SFR(AD0BL
, 0xA6); // A/D_0 boundary low register
95 SFR(AD0DAT0
, 0xC5); // A/D_0 data register 0
96 SFR(AD0DAT1
, 0xC6); // A/D_0 data register 1
97 SFR(AD0DAT2
, 0xC7); // A/D_0 data register 2
98 SFR(AD0DAT3
, 0xF4); // A/D_0 data register 3
99 SFR(AD1BH
, 0xC4); // A/D_1 boundary high register
100 SFR(AD1BL
, 0xBC); // A/D_1 boundary low register
101 SFR(AD1DAT0
, 0xD5); // A/D_1 data register 0
102 SFR(AD1DAT1
, 0xD6); // A/D_1 data register 1
103 SFR(AD1DAT2
, 0xD7); // A/D_1 data register 2
104 SFR(AD1DAT3
, 0xF5); // A/D_1 data register 3
105 SFR(AUXR1
, 0xA2); // Auxilary function register
111 #define DPS 0x01 // Bit 2 is always 0
112 SFR(B
, 0xF0); // B register
121 SFR(BRGR0
, 0xBE); // Baud rate generator rate low
122 SFR(BRGR1
, 0xBF); // Baud rate generator rate high
123 SFR(BRGCON
, 0xBD); // Baud rate generator control
126 SFR(CCCRA
, 0xEA); // Capture compare A control register
135 SFR(CCCRB
, 0xEB); // Capture compare B control register
144 SFR(CCCRC
, 0xEC); // Capture compare C control register
148 SFR(CCCRD
, 0xED); // Capture compare D control register
152 SFR(CMP1
, 0xAC); // Comparator 1 control register
159 SFR(CMP2
, 0xAD); // Comparator 2 control register
166 SFR(DEECON
, 0xF1); // Data EEPROM control register
172 SFR(DEEDAT
, 0xF2); // Data EEPROM data register
173 SFR(DEEADR
, 0xF3); // Data EEPROM address register
174 SFR(DIVM
, 0x95); // CPU clock divide-by-M control
175 SFR(DPH
, 0x83); // Data Pointer High
176 SFR(DPL
, 0x82); // Data Pointer Low
177 SFR(FMADRH
, 0xE7); // Program flash address high
178 SFR(FMADRL
, 0xE6); // Program flash address low
180 // Program flash control (Read)
186 // Program flash control (Write)
195 SFR(FMDATA
, 0xE5); // Program flash data
196 SFR(I2ADR
, 0xDB); // I2C slave address register
205 SFR(I2CON
, 0xD8); // I2C control register
211 SBIT(CRSEL
, 0xD8, 0);
212 SFR(I2DAT
, 0xDA); // I2C data register
213 SFR(I2SCLH
, 0xDD); // I2C serial clock generator/SCL duty cycle register high
214 SFR(I2SCLL
, 0xDC); // I2C serial clock generator/SCL duty cycle register low
215 SFR(I2STAT
, 0xD9); // I2C status register
220 #define STA_0 0x08 // Only write 0 to the lowest three bits
221 SFR(ICRAH
, 0xAB); // Input capture A register high
222 SFR(ICRAL
, 0xAA); // Input capture A register low
223 SFR(ICRBH
, 0xAF); // Input capture B register high
224 SFR(ICRBL
, 0xAE); // Input capture B register low
225 SFR(IEN0
, 0xA8); // Interrupt Enable 0
227 SBIT(EWDRT
, 0xA8, 6);
229 SBIT(ES_ESR
, 0xA8, 4);
234 SFR(IEN1
, 0xE8); // Interrupt Enable 1
235 SBIT(EADEE
, 0xE8, 7);
242 SFR(IP0
, 0xB8); // Interrupt Priority 0
243 SBIT(PWDRT
, 0xB8, 6);
245 SBIT(PS_PSR
, 0xB8, 4);
250 SFR(IP0H
, 0xB7); // Interrupt Priority 0 high
253 #define PSH_PSRH 0x10
258 SFR(IP1
, 0xF8); // Interrupt Priority 1
259 SBIT(PADEE
, 0xF8, 7);
266 SFR(IP1H
, 0xF7); // Interrupt Priority 1 High
274 SFR(KBCON
, 0x94); // Keypad control register
275 #define PATN_SEL 0x02
277 SFR(KBMASK
, 0x86); // Keypad interrupt mask register
278 SFR(KBPATN
, 0x93); // Keypad pattern register
279 SFR(OCRAH
, 0xEF); // Output compare A register high
280 SFR(OCRAL
, 0xEE); // Output compare A register low
281 SFR(OCRBH
, 0xFB); // Output compare B register high
282 SFR(OCRBL
, 0xFA); // Output compare B register low
283 SFR(OCRCH
, 0xFD); // Output compare C register high
284 SFR(OCRCL
, 0xFC); // Output compare C register low
285 SFR(OCRDH
, 0xFF); // Output compare D register high
286 SFR(OCRDL
, 0xFE); // Output compare D register low
287 SFR(P0
, 0x80); // Port 0
292 SBIT(CMP_1
, 0x80, 6); // Renamed, not to conflict with the CMP1 register
295 SBIT(CMPREF
, 0x80, 5);
298 SBIT(CIN1A
, 0x80, 4);
301 SBIT(CIN1B
, 0x80, 3);
304 SBIT(CIN2A
, 0x80, 2);
307 SBIT(CIN2B
, 0x80, 1);
310 SBIT(CMP_2
, 0x80, 0); // Renamed, not to conflict with the CMP2 register
312 SFR(P1
, 0x90); // Port 1
331 SFR(P2
, 0xA0); // Port 2
337 SBIT(SPICLK
, 0xA0, 5);
348 SFR(P3
, 0xB0); // Port 3
359 SFR(P0M1
, 0x84); // Port 0 output mode 1
368 SFR(P0M2
, 0x85); // Port 0 output mode 2
377 SFR(P1M1
, 0x91); // Port 1 output mode 1
385 SFR(P1M2
, 0x92); // Port 1 output mode 2
393 SFR(P2M1
, 0xA4); // Port 2 output mode 1
402 SFR(P2M2
, 0xA5); // Port 2 output mode 2
411 SFR(P3M1
, 0xB1); // Port 3 output mode 1
414 SFR(P3M2
, 0xB2); // Port 3 output mode 2
417 SFR(PCON
, 0x87); // Power control register
426 SFR(PCONA
, 0xB5); // Power control register A
435 SFR(PSW
, 0xD0); // Program Status Word
444 SFR(PT0AD
, 0xF6); // Port 0 digital input disable
450 SFR(RSTSRC
, 0xDF); // Reset source register
457 SFR(RTCCON
, 0xD1); // Real-time clock control
463 SFR(RTCH
, 0xD2); // Real-time clock register high
464 SFR(RTCL
, 0xD3); // Real-time clock register low
465 SFR(SADDR
, 0xA9); // Serial port address register
466 SFR(SADEN
, 0xB9); // Serial port address enable
467 SFR(SBUF
, 0x99); // Serial port data buffer register
468 SFR(SCON
, 0x98); // Serial port control
469 SBIT(SM0_FE
, 0x98, 7);
477 SFR(SSTAT
, 0xBA); // Serial port extended status register
486 SFR(SP
, 0x81); // Stack Pointer
487 SFR(SPCTL
, 0xE2); // SPI control register
496 SFR(SPSTAT
, 0xE1); // SPI status register
499 SFR(SPDAT
, 0xE3); // SPI data register
500 SFR(TAMOD
, 0x8F); // Timer 0 and 1 auxiliary mode
503 SFR(TCON
, 0x88); // Timer 0 and 1 control
512 SFR(TCR20
, 0xC8); // CCU control register 0
513 SBIT(PLEEN
, 0xC8, 7);
514 SBIT(HLTRN
, 0xC8, 6);
515 SBIT(HLTEN
, 0xC8, 5);
516 SBIT(ALTCD
, 0xC8, 4);
517 SBIT(ALTAB
, 0xC8, 3);
518 SBIT(TDIR2
, 0xC8, 2);
519 SBIT(TMOD21
, 0xC8, 1);
520 SBIT(TMOD20
, 0xC8, 0);
521 SFR(TCR21
, 0xF9); // CCU control register 1
527 SFR(TH0
, 0x8C); // Timer 0 high
528 SFR(TH1
, 0x8D); // Timer 1 high
529 SFR(TH2
, 0xCD); // CCU timer high
530 SFR(TICR2
,0xC9); // CCU interrupt control register
538 SFR(TIFR2
,0xE9); // CCU interrupt flag register
546 SFR(TISE2
,0xDE); // CCU interrupt status encode register
550 SFR(TL0
, 0x8A); // Timer 0 low
551 SFR(TL1
, 0x8B); // Timer 1 low
552 SFR(TL2
, 0xCC); // CCU timer low
553 SFR(TMOD
, 0x89); // Timer 0 and 1 mode
562 SFR(TOR2H
, 0xCF); // CCU reload register high
563 SFR(TOR2L
, 0xCE); // CCU reload register low
564 SFR(TPCR2H
,0xCB); // Prescaler control register high
565 #define TPCR2H_1 0x02
566 #define TPCR2H_0 0x01
567 SFR(TPCR2L
,0xCA); // Prescaler control register low
568 #define TPCR2L_7 0x80
569 #define TPCR2L_6 0x40
570 #define TPCR2L_5 0x20
571 #define TPCR2L_4 0x10
572 #define TPCR2L_3 0x08
573 #define TPCR2L_2 0x04
574 #define TPCR2L_1 0x02
575 #define TPCR2L_0 0x01
576 SFR(TRIM
, 0x96); // Internal oscillator trim register
585 SFR(WDCON
, 0xA7); // Watchdog control register
592 SFR(WDL
, 0xC1); // Watchdog load
593 SFR(WFEED1
, 0xC2); // Watchdog feed 1
594 SFR(WFEED2
, 0xC3); // Watchdog feed 2
595 #endif // __P89LPC935_6_H__