|
If you can't view the Datasheet, Please click here to try to view without PDF Reader . |
|
Datasheet File OCR Text: |
preliminary w79e225a/226a/227a data sheet 8-bit microcontroller publication release date: april 15, 2008 - 1 - revision a4.0 table of contents- 1. general des cription ......................................................................................................... 5 2. features ....................................................................................................................... .......... 6 3. parts inform ation list ..................................................................................................... 7 3.1 lead free (rohs) parts informati on li st......................................................................... 7 4. pin config uration .............................................................................................................. . 8 5. pin descri ption................................................................................................................ ... 10 5.1 port 4 ......................................................................................................................... ... 12 6. memory orga nization...................................................................................................... 13 6.1 program memory (o n-chip flash) ................................................................................. 13 6.2 data me mory ................................................................................................................ 13 6.3 auxiliary sram ............................................................................................................. 14 6.4 nvm data flash............................................................................................................ 14 6.4.1 operat ion...................................................................................................................... .. 19 7. special function registers ......................................................................................... 21 8. instruction set................................................................................................................ .. 74 8.1 instruction timing.......................................................................................................... 84 8.1.1 external data memo ry access timing............................................................................ 86 9. power mana gement.......................................................................................................... 89 9.1 idle mode ...................................................................................................................... 89 9.2 power down mode ....................................................................................................... 89 10. reset cond itions............................................................................................................... 91 10.1 sources of reset............................................................................................................ 91 10.1.1 external reset .............................................................................................................. 91 10.1.2 power-on rese t (por)................................................................................................ 91 10.1.3 watchdog time r reset................................................................................................. 91 10.2 reset state ................................................................................................................... 92 11. interrupts ..................................................................................................................... ...... 93 11.1 interrupt sources .......................................................................................................... 93 11.2 priority level structure ................................................................................................. 93 11.2.1 response time ............................................................................................................ 97 12. programmable time rs/counters ............................................................................... 98 12.1 timer/counter s 0 & 1.................................................................................................... 98 12.1.1 time-base se lection .................................................................................................... 98 12.1.2 mode 0 ......................................................................................................................... 98 12.1.3 mode 1 ......................................................................................................................... 99 12.1.4 mode 2 ......................................................................................................................... 99 12.1.5 mode 3 ....................................................................................................................... 100
preliminary w79e225a/226a/227a data sheet publication release date: april 15, 2008 - 2 - revision a4.0 12.2 timer/count er 2 .......................................................................................................... 100 12.2.1 capture mode............................................................................................................. 101 12.2.2 auto-reload mode, counti ng up .................................................................................. 101 12.2.3 auto-reload mode, co unting up /down ....................................................................... 102 12.2.4 baud rate gener ator mode ....................................................................................... 103 13. watchdog timer............................................................................................................... 104 14. pulse-width-modulated (pwm) ou tputs ................................................................. 107 14.1 pwm feat ures ............................................................................................................ 107 14.2 pwm control registers .............................................................................................. 108 14.3 pwm pin st ructures ................................................................................................... 110 14.4 complementary pwm with dead-t ime and override functions .................................. 113 14.5 dead-time insertion ................................................................................................... 114 14.6 pwm output override ................................................................................................ 115 14.7 edge aligned pwm (up-counter) ................................................................................ 118 14.8 center aligned pwm (up/down counter) .................................................................... 121 14.9 single shot (u p-counter) ........................................................................................... 123 14.10 smart fault detector .............................................................................................. 126 14.11 pwm power-down/wakeup procedures ................................................................ 128 15. motion feed back module ............................................................................................. 130 15.1 input capture module (ic) .......................................................................................... 130 15.1.1 compare mode........................................................................................................... 138 15.1.2 reload mode .............................................................................................................. 138 15.2 quadrature encoder interface (qei) .......................................................................... 138 15.2.1 free-counti ng m ode ................................................................................................... 140 15.2.2 compare-coun ting mode ............................................................................................ 140 15.2.3 x2/x4 counti ng modes............................................................................................... 140 15.2.4 direction of co unt....................................................................................................... 140 15.2.5 up-count ing ............................................................................................................... 142 15.2.6 down-co unting........................................................................................................... 142 16. serial port .................................................................................................................... .... 143 16.1 mode 0 ........................................................................................................................ 143 16.2 mode 1 ........................................................................................................................ 144 16.3 mode 2 ........................................................................................................................ 145 16.4 mode 3 ........................................................................................................................ 146 16.5 framing error detection ............................................................................................. 147 16.6 multiprocessor communications................................................................................. 147 17. i2c serial ports ............................................................................................................... 149 17.1 sio port ...................................................................................................................... 149 17.2 the i2c contro l registers .......................................................................................... 149 17.2.1 slave address regi sters, i2addr ............................................................................. 150 17.2.2 data regist er, i2dat ................................................................................................. 150 17.2.3 control regist er, i2con............................................................................................. 150 preliminary w79e225a/226a/227a data sheet publication release date: april 15, 2008 - 3 - revision a4.0 17.2.4 status regist er, i2status........................................................................................ 151 17.2.5 i2c clock baud rate control, i2clk.......................................................................... 151 17.2.6 i2c time-out c ounter, i2 timer ................................................................................... 151 17.2.7 i2c maskable sl ave addr ess ..................................................................................... 152 17.3 modes of operation .................................................................................................... 152 17.3.1 master trans mitter mode ........................................................................................... 152 17.3.2 master rece iver mode ............................................................................................... 152 17.3.3 slave receiv er mode ................................................................................................. 153 17.3.4 slave transmi tter m ode ............................................................................................. 153 17.4 data transfer flow in five oper ating modes............................................................. 153 17.4.1 master/trans mitter mode ........................................................................................... 154 17.4.2 figure 17-5: master transmitter modemaster/re ceiver mode ................................... 155 17.4.3 slave/transmi tter m ode ............................................................................................. 156 17.4.4 slave/receiv er mode ................................................................................................. 157 17.4.5 gc m ode .................................................................................................................... 158 18. serial peripheral in terface (spi)............................................................................. 159 18.1 general descriptions ................................................................................................... 159 18.2 block descr iptions ....................................................................................................... 159 18.3 functional descriptions ............................................................................................... 161 18.3.1 master mode .............................................................................................................. 161 18.3.2 slave mode ................................................................................................................ 164 18.3.3 slave se lect ................................................................................................................ 168 18.3.4 /ss out put................................................................................................................... 168 18.3.5 spi i/o pi ns m ode ...................................................................................................... 169 18.3.6 programmable serial clo ck?s phase a nd pola rity ........................................................ 170 18.3.7 receive double buffe red data r egist er........................................................................ 171 18.3.8 lsb firs t enabl e .......................................................................................................... 172 18.3.9 write collisi on detec tion ............................................................................................. 172 18.3.10 transfer comple te inte rrupt ...................................................................................... 172 18.3.11 mode fa ult ............................................................................................................... 172 19. analog-to-digita l converter .................................................................................... 175 19.1 operation of adc ....................................................................................................... 175 19.2 adc resolution and analog supply ........................................................................... 176 20. timed access protection ............................................................................................ 177 21. port 4 st ructure ............................................................................................................ 179 22. in-system pr ogramming................................................................................................ 182 22.1 the loader program locate s at ldflas h memo ry .................................................... 182 22.2 the loader program locate s at apflash memory .................................................... 182 23. option bits .................................................................................................................... ..... 183 23.1 config0........................................................................................................................ 183 23.2 config1........................................................................................................................ 184 24. electrical cha racteristics....................................................................................... 185 24.1 absolute maxi mum ratings ........................................................................................ 185 preliminary w79e225a/226a/227a data sheet publication release date: april 15, 2008 - 4 - revision a4.0 24.2 dc characte ristics ...................................................................................................... 185 24.3 ac characteristics ...................................................................................................... 188 24.3.1 external clock c haracteri stics.................................................................................... 188 24.3.2 ac specif ication ......................................................................................................... 188 24.3.3 movx characteristics usin g stretch memory cycle .................................................. 189 24.4 the adc converter dc elec trical chara cteristics ................................... 191 24.5 i2c bus timing ch aracteristics .................................................................................. 191 24.6 program memory read cycle .................................................................................... 192 24.7 data memory read cy cle........................................................................................... 193 24.8 data memory write cycle........................................................................................... 193 25. typical applicat ion cir cuits ...................................................................................... 194 25.1 expanded external program memory and crystal ..................................................... 194 25.2 expanded external data me mory and o scillat or........................................................ 194 26. package dime nsion ......................................................................................................... 195 26.1 44l plcc ................................................................................................................... 195 26.2 48l lqfp (7x7x1.4mm footprint 2.0mm) ................................................................... 196 27. applicatio n note ............................................................................................................. 197 28. revision histor y .............................................................................................................. 203 preliminary w79e225a/226a/227a data sheet publication release date: april 15, 2008 - 5 - revision a4.0 1. general description the w79e22x series is a fast, 8051/52-compatible microcontroller with a redesigned processor core that eliminates wasted clock and memory cycles. typically, the w79e22x series executes instructions 1.5 to 3 times faster than that of the traditional 8051/52, depending on the type of instruction, and the overall performance is about 2.5 times better at the same crystal speed. as a result, with the fully-static cmos design, the w79e22x series can accomplish the same throughput with a lower clock speed, r educing power consumption. the w79e22x series provides 256 bytes of on-chip ram; 1/2/2 -kb of nvm data flash eprom; 1/2/2 -kb of auxiliary ram; four 8-bit, bi-directional and bit-addressable i/o ports; an additional 4 -bit port p4 and 2 -bit port p5; three 16-bit timer/counters; motion feedback module support; 2 uart serial ports; 1 channels of i2c with master/slave capability; 1 channels of serial peripheral interface (spi), 8 channels of 12 bit pwm with configurable dead time and 8 channels of 10-bit adc. these peripherals are all supported by 20 interrupt sources with 4 levels of priority. the w79e22x series also contains a 16/32/64 -kb flash eprom whose contents may be updated in-system by a loader program stored in an auxiliary, 4 -kb flash eprom. once the contents are confirmed, it can be protected for security. preliminary w79e225a/226a/227a data sheet publication release date: april 15, 2008 - 6 - revision a4.0 2. features z fully-static-design 8-bit 4t-8051 cmos microcontroller up to 40mhz. z 16/32/64 -kb of in-system-programmable flash eprom (ap flash eprom). z 4 -kb of auxiliary flash eprom for the loader pr ogram (ld flash eprom). user can optionally reboot from ld flash eprom by pull low at eit her p4.3 or p3.6 and p3.7, at external reset. z 1/2/2 -kb auxiliary ram, software-selectabl e, accessed by movx instruction. z 1/2/2 -kb of nvm data flash eprom fo r customer data storage used. z 256 bytes of scratch-pad ram. z four 8-bit bi-directional ports; port 0 has internal pull-up resisters enabled by software. z multipurpose i/o port4 (4 bits for 48l lqfp; 2 bits for 44l plcc) with chips select (cs) and boot function. z two bits bi-directional port5. z three 16-bit timers. z one 16-bit timer 3 for motion feed-back module. z motion feedback module - qei decoder and 3 inputs capture. z eight channels of 12-bit pwm:- c ? complementary paired output with programmable dead-time insertion. c ? three modes: edge aligned, center aligned and single shot. c ? output override control for bldc motor application. z 10-bit adc with 8-channel inputs. z two enhanced full-duplex uart with framing-erro r detection and automatic address recognition. z one channel of i2c with master/slave capability. z one channel of spi with master/slave capability. z software programmable access cycle to external ram/peripherals. z 20 interrupt sources with four levels of priority. z software reset function. z optional h/l state of ale/ psen during power down mode. z built-in power management. z code protection. z package: c ? lead free (rohs) plcc 44: w79e225apg c ? lead free (rohs) lqfp 48: w79e225afg c ? lead free (rohs) plcc 44: w79e226apg c ? lead free (rohs) lqfp 48: w79e226afg c ? lead free (rohs) plcc 44: w79e227apg c ? lead free (rohs) lqfp 48: W79E227AFG c preliminary w79e225a/226a/227a data sheet publication release date: april 15, 2008 - 7 - revision a4.0 3. parts information list 3.1 lead free (rohs) parts information list part no. eprom flash size ram operating frequency operating voltage nvm flash eprom package remark up to 40mhz up to 20mhz 4.5v ~ 5.5v 2.7v [1] ~ 5.5v internal memory w 79e225apg 16kb 256b + 1kb up to 24mhz 4.5v ~ 5.5v 1kb plcc-44 pin external memory up to 40mhz up to 20mhz 4.5v ~ 5.5v 2.7v [1] ~ 5.5v internal memory w 79e225afg 16kb 256b+ 1kb up to 24mhz 4.5v ~ 5.5v 1kb lqfp-48 pin external memory up to 40mhz up to 20mhz 4.5v ~ 5.5v 2.7v [1] ~ 5.5v internal memory w 79e226apg 32kb 256b + 2kb up to 24mhz 4.5v ~ 5.5v 2kb plcc-44 pin external memory up to 40mhz up to 20mhz 4.5v ~ 5.5v 2.7v [1] ~ 5.5v internal memory w 79e226afg 32kb 256b + 2kb up to 24mhz 4.5v ~ 5.5v 2kb lqfp-48 pin external memory up to 40mhz up to 20mhz 4.5v ~ 5.5v 2.7v [1] ~ 5.5v internal memory w 79e227apg 64kb 256b + 2kb up to 24mhz 4.5v ~ 5.5v 2kb plcc-44 pin external memory up to 40mhz up to 20mhz 4.5v ~ 5.5v 2.7v [1] ~ 5.5v internal memory w 79e227afg 64kb 256b + 2kb up to 24mhz 4.5v ~ 5.5v 2kb lqfp-48 pin external memory note: 1. minimum of 3.0v operating voltage for nvm program and erase operations. preliminary w79e225a/226a/227a data sheet publication release date: april 15, 2008 - 8 - revision a4.0 4. pin configuration 13 14 15 16 17 18 19 20 21 22 25 26 27 28 29 30 31 32 33 44 43 42 41 40 39 38 37 11 10 9 8 7 6 5 4 3 2 1 w79e225 w79e226 w79e227 (lqfp 48-pin) xtal2 xtal1 p3.1, txd p3.0, rxd vdd ale 12 23 24 34 35 36 45 46 47 48 vss p4.2 p4.3 miso, ad0, p0.0 mosi, ad1, p0.1 spclk, ad2, p0.2 int2, ad4, p0.4 int3, ad5, p0.5 int4, ad6, p0.6 int5, ad7, p0.7 p3.4, t0, ic0, qea p3.5, t1, ic1, qeb ss , ad3, p0.3 ea p3.2, int0 p3.3, int1 p3.6, wr p3.7, rd preliminary w79e225a/226a/227a data sheet publication release date: april 15, 2008 - 9 - revision a4.0 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 6 5 4 3 2 1 44 43 42 41 40 17 16 15 14 13 12 11 10 9 8 7 w79e225 w79e226 w79e227 (plcc 44-pin) xtal1 ale stadc, p4.0 adc7, p1.7 adc6, p1.6 adc5, p1.5 adc4, p1.4 rxd1, adc2, p1.2 brake, adc1, p1.1 t2, adc0, p1.0 txd1, adc3, p1.3 avss avdd p3.1, txd p3.0, rxd rst p4.1, t2ex, ic2, indx p2.0, a8, pwm0 vdd p2.1, a9, pwm1 p2.2, a10, pwm2 p2.3, a11, pwm3 p2.4, a12, pwm4 p2.5, a13, pwm5 p2.6, a14, scl p2.7, a15, sda vss xtal2 p3.4, t0, ic0, qea p3.5, t1, ic1, qeb miso, ad0, p0.0 mosi, ad1, p0.1 spclk, ad2, p0.2 int2, ad4, p0.4 int3, ad5, p0.5 int4, ad6, p0.6 int5, ad7, p0.7 ss , ad3, p0.3 psen ea p3.2, int0 p3.3, int1 p3.6, wr p3.7, rd preliminary w79e225a/226a/227a data sheet publication release date: april 15, 2008 - 10 - revision a4.0 5. pin description symbol type initial state descriptions ea i - external access enable: this pin forces the processor to execute from external rom. the rom address and data are not presented on the bus if the ea pin is high. note: this pin has no internal pull-up or pull-down. the pin needs externally pull-up to execute from internal aprom. for executing from external aprom, the pin needs externally pull- down. the pin state is internally latched during all reset. user needs to take note that changes to /ea pin state after reset will not be effective. psen o h high program store enable: psen enables the external rom data in the port 0 address/data bu s. when internal rom access is performed, psen strobe signal will not be output from this pin. ale o h high address latch enable: ale enables the address latch that separates the address from the data on port 0. rst i l - reset: set this pin high for two machine cycles while the oscillator is running to reset the device. xtal1 i - crystal 1: crystal oscillator input or external clock input. xtal2 o - crystal 2: crystal oscillator output. v ss i - ground : ground potential. v dd i - power supply: supply voltage for operation. avdd i - analog power supply. avss i - analog ground potential. p0.0 ? p0.7 i/o d s h high-z port 0 : port 0 is an open-drain bi-directional i/o port. this port also provides a multiplexed low byte address/data bus during accesses to external memory. there is an embedded weakly pull- up resistor on each port 0 pin which can be enabled or disabled by setting or clearing of pup0, bit0 in a2h. the ports have alternate functions which are described below: p0.0, ad0, miso p0.1, ad1, mosi p0.2, ad2, spclk p0.3, ad3, /ss p0.4, ad4, int2 p0.5, ad5, int3 p0.6, ad6, int4 p0.7, ad7, int5 preliminary w79e225a/226a/227a data sheet publication release date: april 15, 2008 - 11 - revision a4.0 pin description, continued symbol type initial state descriptions p1.0 ? p1.7 i/o s h high port 1 : 8-bit, bi-directional i/o port with internal pull-ups. the ports have alternate functions which are described below: p1.0, adc0, t2 p1.1, adc1, brake p1.2, adc2, rxd1 p1.3, adc3, txd1 p1.4, adc4 p1.5, adc5 p1.6, adc6 p1.7, adc7 p2.0-p2.5 i/o s tri-state p2.6-p2.7 i/o d high-z port 2 : 8-bit, bi-directional i/o port. this port also provides the upper address bits for accesses to external memory. p2.6 to p2.7 can be software configured as i2c serial ports. p2.0 to p2.5 also provides pwm0 to pwm5 outputs. p2.0, a8, pwm0 p2.1, a9, pwm1 p2.2, a10, pwm2 p2.3, a11, pwm3 p2.4, a12, pwm4 p2.5, a13, pwm5 p2.6, a14, scl p2.7, a15, sda note: p2.6 and p2.7 are permanent open drain pins. when access to external memory beyond 16k region, user requires to add external pull-up registers (up to 2kohm) on these pins. this will result in slight incr ease in current consumption. p3.0-p3.7 i/o s h high port 3 : 8-bit, bi-directional i/o port with internal pull-ups. the ports have alternate functions which are described below: p3.0, rxd p3.1, txd p3.2, /int0 p3.3, /int1 p3.4, t0, ic0, qea p3.5, t1, ic1, qeb p3.6, /wr p3.7, /rd preliminary w79e225a/226a/227a data sheet publication release date: april 15, 2008 - 12 - revision a4.0 pin description, continued symbol type initial state descriptions p4.0-p4.3 i/o s h high port 4 : 4-bit multipurpose programmable i/o port with alternate functions. the port 4 has four different operation modes. p4.0, stadc p4.1, t2ex, ic2 p4.2 p4.3 note: p4.2 & p4.3 are not supported in plcc44 pins package. p5.0-p5.1 i/o s tri-state port 5 : 2-bit, bit-directional i/o port. this port is not bit addressable. the alternate f unctions are described below: p5.0, pwm6 p5.1, pwm7 note: p5.0 & p5.1 are not supported in plcc44 pins package. note j type i: input, o: output, i/o: bi-directional, h: pull-hi gh, l: pull-low, d: open drain s: schmitt trigger 5.1 port 4 port 4, sfr p4 at address a5h, is a 4-bit multi purpose programmable i/o port which functions are i/o and chip-select function. it has four different operation modes: z mode 0 - p4.0 ~ p4.3 is 4-bit bi-directional i/o port which is the same as port 1. the default port 4 is a general i/o function. z mode1 - p4.0 ~ p4.3 are read data strobe signals which are synchronized with rd signal at specified addresses. these read data strobe signals can be used as chip-select signals for external peripherals. z mode2 - p4.0 ~ p4.3 are write data strobe signals which are synchronized with wr signal at specified addresses. these write data strobe signals can be used as chip-select signals for external peripherals. z mode3 - p4.0 ~ p4.3 are read/write data st robe signals which are synchronized with rd or wr signal at specified addresses. these read/writ e data strobe signals can be used as chip- select signals for external peripherals. when port 4 is configured with the feature of ch ip-select signals, the chip-select signal address range depends on the contents of the sfr p4xah, p4xal, p4cona and p4conb. p4xah and p4xal contain the 16-bit base address of p4.x. p4cona and p4conb contain the control bits to configure the port 4 operation mode. preliminary w79e225a/226a/227a data sheet publication release date: april 15, 2008 - 13 - revision a4.0 6. memory organization the w79e22x series separates the memory into tw o sections; program memory and data memory. program memory stores instruct ion op-codes, while data memory stores data or memory-mapped devices. 6.1 program memory (on-chip flash) w79e22x series includes one 16/32/64 k bytes of main flash eprom for application program (ap flash eprom) and one 4k bytes of flash eprom for loader program (ld flash eprom) to operate the in-system programming (isp) feature, and one 1/2/2 k bytes of nvm flash eprom for data storage. the 16/32/64 k bytes flash eprom is ap0 bank. the default active bank is ap0. in normal operation, the microcontroller will ex ecute the code from main flash eprom. by setting program registers, user can force the microcontrol ler to switch to programming mode which will cause it to execute the code (loader program) from t he 4k bytes of auxiliary ld flash eprom to update the contents of the 16/32/64 k bytes of main flash eprom. afte r reset, the microcontroller will executes the new application program in the main flash eprom. this isp feature makes the job easy and efficient in which the application needs to update firmware frequently without opening the chassis. 6.2 data memory w79e22x series can access up to 64kbytes of exte rnal data memory. this memory region is accessed by the movx instructions. unlike the 8051 derivatives, w79e22x ser ies contains on-chip 1/2/2 kbytes of data memory, which only can be accessed by movx instructions. these 1/2/2 kbytes of sram is between address 0000h and 03ffh/07ffh . access to the on-chip data memory is optional under software control. when enabled by dm eo bit of pmr register, a movx instruction that uses this area will go to the on-chip ram. if mo vx instruction accesses the addresses greater than 03ffh/07ffh cpu will automatically access external memo ry through port 0 and 2. when disabled, the 1/2/2 kb memory area is transparent to the sy stem memory map. any movx directed to the space between 0000h and ffffh goes to the expanded bu s on the port 0 and 2. this is the default condition. in addition, the device has the standard 256 bytes of on -chip ram. this can be accessed either by direct addressing or by indirect addressing. there are also some special function registers (sfrs), which can only be accessed by direct addressing. preliminary w79e225a/226a/227a data sheet publication release date: april 15, 2008 - 14 - revision a4.0 figure 6-1: w79e22x seriesa memory map 6.3 auxiliary sram w79e22x series has a 1/2/2 kb of data space sram which is read/write accessible and is memory mapped. this on-chip sram is accessed by the mo vx instruction. there is no conflict or overlap among the 256 bytes scratch-pad memory and the 1/2/2 kb auxiliary sram as they use different addressing modes and instructions. access to the on-chip data memory is optional under software control. set dmeo bit of pmr sfr to 1 will enable the on-chip 1/2/2 kb movx sram and at the same time ennvm bit must be cleared as nvm data uses the same instruction of movx. refer to. 6.4 nvm data flash w79e22x series 1/2/2 -kb nvm data block shown in the diagram on figure 6-1 shares the same address as aux-ram address. due to overlapping of aux-ram, nvm data memory and external data memory physical address, the following table is defined. ennvm bit (nvmcon.5) will enable read access to nvm data flash area. dme0 (pmr.0) will enable read access to aux-ram. ennvm dme0 data memory area 0 0 enable external ram read/write access by movx 0 1 enable aux-ram read/write access by movx 1 x enable nvm data memory read access by movx only. if eer or ewr is set and nvm flash erase or write control is busy, to set this bit read nvm data is invalid. table 6-1: bits setting for mo vx access to data memory area ennvm = 1 instructions nvm size = sram (1k) preliminary w79e225a/226a/227a data sheet publication release date: april 15, 2008 - 15 - revision a4.0 addr 1k addr > 1k movx a, @dptr (read) nvm 1 ext memory 1 movx a, @r0 (read) nvm 2 nop read access movx a, @r1 (read) nvm 2 nop movx @dptr, a (write) nop ext memory 1 movx @r0, a (write) nop nop write access movx @r1, a (write) nop nop table 6-2: w79e225 movx read/write access destination ennvm = 1 nvm size = sram (2k) instructions addr 2k addr > 2k movx a, @dptr (read) nvm 1 ext memory 1 movx a, @r0 (read) nvm 2 nop read access movx a, @r1 (read) nvm 2 nop movx @dptr, a (write) nop ext memory 1 movx @r0, a (write) nop nop write access movx @r1, a (write) nop nop table 6-3: w79e226/227 movx read/write access destination note: 1. a15~a0=dptr 2. a15~a8=xramah preliminary w79e225a/226a/227a data sheet publication release date: april 15, 2008 - 16 - revision a4.0 it is partition into 16/32/32 pages area and each page has 64 bytes data as below figure. the page 0 is from 0000h ~ 003fh, page 1 is from 0040h ~ 007fh until page 31 address located at 07coh ~ 07ffh. figure 6-2: w79e225 nvm data mapping preliminary w79e225a/226a/227a data sheet publication release date: april 15, 2008 - 17 - revision a4.0 2k bytes flash eprom page 31 64bytes page 30 64bytes | | | | | | page 03 64bytes page 02 64bytes page 01 64bytes page 00 64bytes 07ffh 07c0h 07bfh 0780h 0000h 003fh 0040h 007fh 0080h 00bfh 00c0h 00ffh 0000h 07ffh figure 6-3: w79e226/227 nvm data mapping preliminary w79e225a/226a/227a data sheet publication release date: april 15, 2008 - 18 - revision a4.0 page start address end address page start address end address 0 0000h 003fh 16 0400h 043fh 1 0040h 007fh 17 0440h 047fh 2 0080h 00bfh 18 0480h 04bfh 3 00c0h 00ffh 19 04c0h 04ffh 4 0100h 013fh 20 0500h 053fh 5 0140h 017fh 21 0540h 057fh 6 0180h 01bfh 22 0580h 05bfh 7 01c0h 01ffh 23 05c0h 05ffh 8 0200h 023fh 24 0600h 063fh 9 0240h 027fh 25 0640h 067fh 10 0280h 02bfh 26 0680h 06bfh 11 02c0h 02ffh 27 06c0h 06ffh 12 0300h 033fh 28 0700h 073fh 13 0340h 037fh 29 0740h 077fh 14 0380h 03bfh 30 0780h 07bfh 15 03c0h 03ffh 31 07c0h 07ffh [note: page 16-31 is for w79e226/227 only] table 6-4: w79e22x series nvm page (n) area definition table it has a dedicated on-chip rc oscillator that is fix ed at 6mhz +/- 25% frequency to support clock source for the 1/2/2 k nvm data flash. the on chip oscillator is enabled only during program or erase operation, through ewr or eer in nvmcon sfr. ewr or eer bits are cleared by hardware after program or erase operation completed. the progra m/erase time is automat ically controlled by hardware. figure 6-4: nvm control preliminary w79e225a/226a/227a data sheet publication release date: april 15, 2008 - 19 - revision a4.0 6.4.1 operation user is required to enable ennvm (nvmcon.5) bit for all nvm access (read/write/erase). before write data to nvm data, the page must be erased. a page is erased by setting page address which address will decode and enable page (n) on nvmaddrh and nvmaddrl, then set eer (nvmcon.7) and ennvm (nvmcon.5). the device will then automatic execute page erase. when completed, nvmf will be set by hardw are. nvmf should be cleared by software. interrupt request will be generated if envm (eie1.5) is enabled. eer bit will be cleared by hardware when erase is completed. the total erase time is about 5ms. for write, user must set address and data to nv maddrh/l and nvmdat, respectively. and then set ewr (nvmcon.6) and ennvm (nvmcon.5) to enable data write. when completed, the device will set nvmf flag. nvmf flag should be cleared by so ftware. similarly, interrupt request will be generated if envm (eie1.5) is enabled. the program time is about 50us. the following shows some examples of nvm operations (using w79e226/227): read nvm data is by movx a,@dptr/r0/r1 instruction: a read exceed 2 k will read the external address example1: dptr=0x07ff, r0/r1 = 0xff, xramah=0x07, ennvm=1 movx a,@dptr ? read nvm data at address 0x07ff movx a,@r0 ? read nvm data at address 0x07ff movx a,@r1 ? read nvm data at address 0x07ff example2: dptr = 0x2000, ennvm=1, dme0=0 movx a,@dptr ? read external ram dat a at address 0x2000, erase nvm by sfr register: example1: nvmaddrh = 0x07, nvmaddrl = 0xf0, page 31 will be enabled. after set eer, the page 31 will be erased. example2: nvmaddrh = 0x10, nvma ddrl = 0x00, invalid nvm eras e instruction (address exceed nvm boundary). write nvm by sfr register: example1: nvmaddrh = 0x 07, nvmaddrl = 0xf0 after set ewr, data will be written to the nvm address = 0x07f0 location. example2: nvmaddrh = 0x10, nvma ddrl = 0x00, after set ewr, invalid nvm write instruction (address exceed nvm boundary). during erase, write is invalid. likewise, during write, erase is invalid. an erase or write is invalid if nvmf is not clear by software. a write to nv maddrh and nvmaddrl is invalid during erase or write, and a write to nvmdat is invalid only during nvm write access. preliminary w79e225a/226a/227a data sheet publication release date: april 15, 2008 - 20 - revision a4.0 figure 6-5: nvm data memory control timing for security purposes, this nvm data flash provides an independent ?lock bit? located in security bits. it is used to protect the customer?s 1/2/2 k bytes of data code. it may be enabled after the external programmer finishes the programming and verifying sequence. once this bit is set to logic 0, the 1/2/2 k bytes of nvm flash eprom data can not be accessed again by external device. note: 1. nvmf can be polled or by h/w interrupt to indicate nvm data memory erase or write operation has completed. 2. while user program is erasing or writing to nvm data memory, the pc counter will continue to fetch for next instruction. 3. when uc is in idle mode and if nvm in terrupt and global interrupt are enabled, the completion of either erasing or programmi ng the nvm data memory will exit the idle condition. preliminary w79e225a/226a/227a data sheet publication release date: april 15, 2008 - 21 - revision a4.0 7. special function registers the w79e22x series uses special function regist ers (sfr) to control and monitor peripherals. the sfr reside in register locations 80-ffh and are only accessed by di rect addressing. the w79e22x series contains all the sfr present in the standard 8051/52, as well as some additional sfr, and, in some cases, unused bits in t he standard 8051/52 have new functions. sfr whose addresses end in 0 or 8 (hex) are bi t-addressable. the following table of sfr is condensed, with eight locations per row. empty locations indicate that there are no registers at these addresses. f8 eip eie1 eip1 ccl0 /pcntl cch0 /pcnth ccl1 /plscntl cch1 /plscnth intctrl f0 b spcr spsr spdr i2csaden eiph e8 eie i2con i2addr nvmaddrh i2dat i2status i2clk i2timer e0 acc adccon adch adcl pdtc1 pdtc0 pwmcon4 d8 wdcon pwmpl pwm0l nvmaddrl pwmcon1 pwm2l pwm6l pwmcon3 d0 psw pwmph pwm0h nvmdat qeicon pwm2h pwm6h wdcon2 c8 t2con t2mod rcap2l rcap2h tl2 th2 pwmcon2 pwm4l c0 scon1 sbuf1 t3mod t3con pmr fsplt adcps ta b8 ip saden saden1 povm povd pio pwmen pwm4h b0 p3 p5 rcap3l rcap3h eip1h iph a8 ie saddr saddr1 sfral sfrah sfrfd sfrcn a0 p2 xramah p4csin capcon0 capcon1 p4 ccl2 /maxcntl cch2 /maxcnth 98 scon sbuf p42al p42ah p43al p43ah nvmcon chpcon 90 p1 exif p4cona p4conb p40al p40ah p41al p41ah 88 tcon tmod tl0 tl1 th0 th1 ckcon ckcon1 80 p0 sp dpl dph tl3 th3 pcon table 7-1: special functi on register location table preliminary w79e225a/226a/227a data sheet publication release date: april 15, 2008 - 22 - revision a4.0 symbol definition add ress msb bit_ a ddress, symbol lsb reset intctrl interrupt control register ffh - - int5ct1 int5ct0 int4ct1 i nt4ct0 int3ct1 int3ct0 xx00 0000 b cch1 /plscnth capture counter high 1 register feh cch1.7 /plscn th.7 cch1.6 /plscn th.6 cch1.5 /plscn th.5 cch1.4 /plscn th.4 cch1.3 /plscn th.3 cch1.2 /plscn th.2 cch1.1 /plscn th.1 cch1.0 /plscn th.0 0000 0000 b ccl1 /plscntl capture counter low 1 register fdh ccl1.7 /plscn tl.7 ccl1.6 /plscn tl.6 ccl1.5 /plscn tl.5 ccl1.4 /plscn tl.4 ccl1.3 /plscn tl.3 ccl1.2 /plscn tl.2 ccl1.1 /plscn tl.1 ccl1.0 /plscn tl.0 0000 0000 b cch0 /pcnth capture counter high 0 register fch cch0.7 /pcnth. 7 cch0.6 /pcnth. 6 cch0.5 /pcnth. 5 cch0.4 /pcnth. 4 cch0.3 /pcnth. 3 cch0.2 /pcnth. 2 cch0.1 /pcnth. 1 cch0.0 /pcnth. 0 0000 0000 b ccl0 /pcntl capture counter low 0 register fbh ccl0.7 /pcntl. 7 ccl0.6 /pcntl. 6 ccl0.5 /pcntl. 5 ccl0.4 /pcntl. 4 ccl0.3 /pcntl. 3 ccl0.2 /pcntl. 2 ccl0.1 /pcntl. 1 ccl0.0 /pcntl. 0 0000 0000 b eip1 extended interrupt priority 1 fah - - pnvmi pcptf pt3 pbkf ppwmf pspi xx00 0000 b eie1 interrupt enable 1 f9h - - envm ecptf et3 ebk epwm espi xx00 0000 b eip extended interrupt priority f8h (ff) ps1 (fe) px5 (fd) px4 (fc) pwdi (fb) px3 (fa) px2 (f9) - (f8) pi2c 0000 00x0 b eiph extended interrupt high priority f7h ps1h px5h px4h pwdih px3h px2h - pi2ch 0000 00x0 b i2csaden i2c slave address mask f6h i2csad en.7 i2csad en.6 i2csad en.5 i2csad en.4 i2csad en.3 i2csad en.2 i2csad en.1 i2csad en.0 1111 1110 b spdr serial peripheral data register f5h spd.7 spd.6 spd.5 spd.4 spd.3 spd.2 spd.1 spd.0 xxxx xxxxb spsr serial peripheral status register f4h spif wcol spiovf modf drss - - - 0000 0xxxb spcr serial peripheral control register f3h ssoe spe lsbfe mstr cpol cpha spr1 spr0 0000 0100 b b b register f0h (f7) (f6) (f5) (f4) (f3) (f2) (f1) (f0) 0000 0000 b i2timer i2c timer counter register efh - - - - - enti div4 tif xxxx x000b i2clk i2c clock rate eeh i2clk.7 i2clk.6 i2clk. 5 i2clk.4 i2clk.3 i2clk.2 i2clk.1 i2clk.0 0000 0000 b i2status i2c status register edh i2statu s.7 i2statu s.6 i2statu s.5 i2statu s.4 i2statu s.3 - - - 1111 1000 b i2dat i2c data ech i2dat.7 i2dat.6 i2dat.5 i 2dat.4 i2dat.3 i2dat.2 i2dat.1 i2dat.0 0000 0000 b n vmaddr h nvm high byte address ebh - - - - - nvmad drh.10 nvmad drh.9 nvmad drh.8 xxxx x000b i2addr i2c slave address eah addr.7 addr.6 addr.5 addr.4 addr.3 addr.2 addr.1 gc 0000 0000 b i2con i2c control register e9h - ens sta sto si aa i2cin - x000 000x b eie extended interrupt enable e8h (ef) es1 (ee) ex5 (ed) ex4 (ec) ewdi (eb) ex3 (ea) ex2 (e9) (e8) ei2c 0000 00x0 b pwmcon4 pwm control register 4 e7h pwmeo m pwmoo m pwm6o m pwm7o m - - - bkf 0000 xxx0b pdtc0 dead time control register 0 e6h pdtc0.7 pdtc0.6 pdtc0.5 pdtc0.4 pd tc0.3 pdtc0.2 pdtc0.1 pdtc0.0 0000 0000 b pdtc1 dead time control register 1 e5h pdtc1.7 pdtc1.6 pdtc1.5 pdtc1.4 pd tc1.3 pdtc1.2 pdtc1.1 pdtc1.0 0000 0000 b adcl adc converter result low byte e3h adclk1 adclk0 - - - - adc.1 adc.0 00xx xxxxb preliminary w79e225a/226a/227a data sheet publication release date: april 15, 2008 - 23 - revision a4.0 continued symbol definition addr ess msb bit_ a ddress, symbol lsb reset adch adc converter result high byte e2h adc.9 adc.8 adc.7 adc.6 adc.5 adc.4 adc.3 adc.2 xxxx xxxxb adccon adc control register e1h adcen - adcex adci adcs aadr2 aadr1 aadr0 0x00 0000 b acc accumulator e0h (e7) (e6) (e5) (e4) (e3) (e2) (e1) (e0) 0000 0000 b pwmcon3 pwm control register 3 dfh pwm7b pwm6b pwm5b pwm4b pwm3b pwm2b pwm1b pwm0b 0000 0000 b pwm6l pwm 6 low bits register deh pwm6.7 pwm6.6 pwm6.5 pwm6.4 pwm6.3 pwm6.2 pwm6.1 pwm6.0 0000 0000 b pwm2l pwm 2 low bits register ddh pwm2.7 pwm2.6 pwm2.5 pwm2.4 pwm2.3 pwm2.2 pwm2.1 pwm2.0 0000 0000 b pwmcon1 pwm control register 1 dch pwmru n load pwmf clrpw m pwm6i pwm4i pwm2i pwm0i 0000 0000 b n vmaddrl nvm low byte address dbh nvmad drh.7 nvmad drh.6 nvmad drh.5 nvmad drh.4 nvmad drh.3 nvmad drh.2 nvmad drh.1 nvmad drh.8 0000 0000 b pwm0l pwm 0 low bits register dah pwm0.7 pwm0.6 pwm0.5 pwm0.4 pwm0.3 pwm0.2 pwm0.1 pwm0.0 0000 0000 b pwmpl pwm counter low register d9h pwmp.7 pwmp.6 pwmp.5 pwmp.4 pwmp.3 pwmp.2 pwmp.1 pwmp.0 0000 0000 b wdcon watch-dog control d8h (df) - (de) por (dd) - (dc) - (db) wdif (da) wtrf (d9) ewt (d8) rwt 0100 0000 b wdcon2 watch-dog control2 d7h - - - - - - - strld 0000 0000 b pwm6h pwm 6 high bits register d6h - - - - pwm6.1 1 pwm6.1 0 pwm6.9 pwm6.8 xxxx 0000b pwm2h pwm 2 high bits register d5h - - - - pwm2.1 1 pwm2.1 0 pwm2.9 pwm2.8 xxxx 0000b qeicon qei control register d4h - - - disidx dir qeim1 qeim0 qeien xxx0 0000b nvmdat nvm data d3h nvmda t.7 nvmda t.6 nvmda t.5 nvmda t.4 nvmda t.3 nvmda t.2 nvmda t.1 nvmda t.0 0000 0000 b pwm0h pwm 0 high bits register d2h - - - - pwm0.1 1 pwm0.1 0 pwm0.9 pwm0.8 xxxx 0000b pwmph pwm counter high register d1h - - - - pwmp.1 1 pwmp.1 0 pwmp.9 pwmp.8 xxxx 0000b psw program status word d0h (d7) cy (d6) ac (d5) f0 (d4) rs1 (d3) rs0 (d2) ov (d1) f1 (d0) p 0000 0000 b pwm4l pwm 4 low bits register cfh pwm4.7 pwm4.6 pwm4.5 pwm4.4 pwm4.3 pwm4.2 pwm4.1 pwm4.0 0000 0000 b pwmcon2 pwm control register 2 ceh bkch bkps bpen bken fp1 fp0 pmod1 pmod0 0000 0000 b th2 t2 reg. high cdh th2.7 th2.6 th2. 5 th2.4 th2.3 th2.2 th2.1 th2.0 0000 0000 b tl2 t2 reg. low cch tl2.7 tl2.6 tl2.5 tl2.4 tl2.3 tl2.2 tl2.1 tl2.0 0000 0000 b rcap2h t2 capture low cbh rcap2h .7 rcap2h .6 rcap2h .5 rcap2h .4 rcap2h .3 rcap2h .2 rcap2h .1 rcap2h .0 0000 0000 b rcap2l t2 capture high cah rcap2l .7 rcap2l .6 rcap2l .5 rcap2l .4 rcap2l .3 rcap2l .2 rcap2l .1 rcap2l .0 0000 0000 b t2mod timer 2 mode c9h hc5 hc4 hc3 hc2 t2cr - - dcen 0000 0xx0 b t2con timer 2 control c8h (cf) tf2 (ce) exf2 (cd) rclk (cc) tclk (cb) exen2 (ca) tr2 (c9) t c/ (c8) rl2 cp/ 0000 0000 b ta time access register c7h ta.7 ta.6 ta.5 ta.4 ta.3 ta.2 ta.1 ta.0 0000 0000 b ddio disable digital i/o c6h ddio.7 ddio.6 ddio.5 ddio.4 ddio.3 ddio.2 ddio.1 ddio.0 0000 0000 b preliminary w79e225a/226a/227a data sheet publication release date: april 15, 2008 - 24 - revision a4.0 continued symbol definition addr ess msb bit_ a ddress, symbol lsb reset fsplt fault sampling time register c5h scmp1 scmp0 sfp1 sfp0 sfcen sfcst sfcdir lsbd 0000 0000 b pmr power management register c4h - - - - - aleoff - dme0 xxxx x0x0b t3con timer 3 control c3h tf3 - - - - tr3 - 0xxx x0x0b t3mod timer 3 mode control c2h enld icen2 icen1 icen0 t3cr - - - 0000 0xxxb sbuf1 serial buffer 1 c1h sbuf1.7 sbuf1.6 sbuf1 .5 sbuf1.4 sbuf1.3 sbuf1.2 sbuf1.1 sbuf1.0 xxxx xxxxb scon1 serial control 1 c0h (bf) sm0_1/f e_1 (be) sm1_1 (bd) sm2_1 (bc) ren_1 (bb) tb8_1 (ba) rb8_1 (b9) ti_1 (b8) ri_1 0000 0000 b pwm4h pwm 4 high bits register bfh - - - - pwm4.11 pwm4.1 0 pwm4.9 pwm4.8 xxxx 0000b pwmen pwm output enable register beh pwm7e n pwm6e n pwm5e n pwm4e n pwm3e n pwm2e n pwm1e n pwm0e n 0000 0000 b pio pwm pin output source select bdh pio7 pio6 pio5 pio4 pio3 pio2 pio1 pio0 0000 0000 b povd pwm output state registers bch povd.7 povd.6 povd.5 povd.4 povd .3 povd.2 povd.1 povd.0 0000 0000 b povm pwm output override control registers bbh povm.7 povm.6 povm.5 povm.4 povm .3 povm.2 povm.1 povm.0 0000 0000 b saden1 slave address mask 1 bah saden1 .7 saden1 .6 saden1 .5 saden1 .4 saden1 .3 saden1 .2 saden1 .1 saden1 .0 0000 0000 b saden slave address mask b9h saden. 7 saden. 6 saden. 5 saden. 4 saden. 3 saden. 2 saden. 1 saden. 0 0000 0000 b ip interrupt priority b8h (bf) (be) padc (bd) pt2 (bc) ps (bb) pt1 (ba) px1 (b9) pt0 (b8) px0 0000 0000 b iph interrupt high priority b7h - padch pt2h psh pt1h px1h pt0h px0h x000 0000 b eip1h extended interrupt high priority 1 b6h - - pnvmih pcptfh pt3h pbkfh ppwmh pspih xx00 0000 b rcap3h reload capture 3 high register b5h rcap3h .7 rcap3h .6 rcap3h .5 rcap3h .4 rcap3h .3 rcap3h .2 rcap3h .1 rcap3h .0 0000 0000 b rcap3l reload capture 3 low register b4h rcap3l .7 rcap3l .6 rcap3l .5 rcap3l .4 rcap3l .3 rcap3l .2 rcap3l .1 rcap3l .0 0000 0000 b p5 port 5 b1h - - - - - - pwm7 pwm6 xxxx xx11b p3 port 3 b0h (b7) rd (b6) wr (b5) t1/ ic1/qeb (b4) t0/ ico/qe a (b3) /int1 (b2) /int0 (b1) txd (b0) rxd 1111 1111 b sfrcn f/w flash control afh - wfwin noe nce ctrl3 ct rl2 ctrl1 ctrl0 x011 1111 b sfrfd f/w flash data aeh d7 d6 d5 d4 d3 d2 d1 d0 xxxx xxxxb sfrah f/w flash high address adh a15 a14 a13 a12 a11 a10 a9 a8 0000 0000 b sfral f/w flash low address ach a7 a6 a5 a4 a3 a2 a1 a0 0000 0000 b saddr1 slave address 1 aah saddr1 .7 saddr1 .6 saddr1 .5 saddr1 .4 saddr1 .3 saddr1 .2 saddr1 .1 saddr1 .0 0000 0000 b saddr slave address a9h saddr. 7 saddr. 6 saddr. 5 saddr. 4 saddr. 3 saddr. 2 saddr. 1 saddr. 0 0000 0000 b ie interrupt enable a8h (af) ea (ae) eadc (ad) et2 (ac) es (ab) et1 (aa) ex1 (a9) et0 (a8) ex0 0000 0000 b preliminary w79e225a/226a/227a data sheet publication release date: april 15, 2008 - 25 - revision a4.0 continued symbol definition addr ess msb bit_ a ddress, symbol lsb reset cch2/max cnth input capture 2 high register/ maximum counter high register a7h cch2.7 /maxcn th.7 cch2.6 maxcn th.6 cch2.5 /maxcn th.5 cch2.4 /maxcn th.4 cch2.3 /maxcn th.3 cch2.2 /maxcn th.2 cch2.1 /maxcn th.1 cch2.0 /maxcn th.0 0000 0000 b ccl2/max cntl input capture 2 low register/ maximum counter low register a6h ccl2.7 /maxcn tl.7 ccl2.6 /maxcn tl.6 ccl2.5 /maxcn tl.5 ccl2.4 /maxcn tl.4 ccl2.3 /maxcn tl.3 ccl2.2 /maxcn tl.2 ccl2.1 /maxcn tl.1 ccl2.0 /maxcn tl.0 0000 0000 b p4 port 4 a5h - - - - p4.3 p4.2 t2ex/ic 2 stadc xxxx 1111b capcon1 capture control 1 register a4h - - enf2 enf1 enf0 cptf2 cptf1/ dirf cptf0/ qeif xx00 0000 b capcon0 capture control 0 register a3h cct2.1 cct2.0 cct1.1 cct1.0 cct0.1 cct0.0 ccld1 ccld0 0000 0000 b p4csin p4 cs sign a2h p43inv p42inv p41inv p40inv - pwdnh rmwfp p0up 0000 x000 b xramah ram high byte address a1h - - - - - a10 a9 a8 0000 0000 b p2 port 2 a0h (a7) a15/ sda (a6) a14/ scl (a5) a13/ pwm5 (a4) a12/ pwm4 (a3) a11/ pwm3 (a2) a10/ pwm2 (a1) a9/ pwm1 (a0) a8/ pwm0 1111 1111 b chpcon on chip programming control 9fh swrst/ reboot - ld/ap - - - ldsel enp 0000 0000 b nvmcon nvm control 9eh eer ewr ennvm - - - - nvmf 000x xxx0b p43ah hi addr. comparator of p4.3 9dh a15 a14 a13 a12 a11 a10 a9 a8 0000 0000 b p43al lo addr. comparator of p4.3 9ch a7 a6 a5 a4 a3 a2 a1 a0 0000 0000 b p42ah hi addr. comparator of p4.2 9bh a15 a14 a13 a12 a11 a10 a9 a8 0000 0000 b p42al lo addr. comparator of p4.2 9ah a7 a6 a5 a4 a3 a2 a1 a0 0000 0000 b sbuf serial buffer 99h sbuf.7 sbuf.6 sbuf. 5 sbuf.4 sbuf.3 sbuf.2 sbuf.1 sbuf.0 xxxx xxxxb scon serial control 98h (9f) sm0/fe (9e) sm1 (9d) sm2 (9c) ren (9b) tb8 (9a) rb8 (99) ti (98) ri 0000 0000 b p41ah hi addr. comparator of p4.1 97h a15 a14 a13 a12 a11 a10 a9 a8 0000 0000 b p41al lo addr. comparator of p4.1 96h a7 a6 a5 a4 a3 a2 a1 a0 0000 0000 b p40ah hi addr. comparator of p4.0 95h a15 a14 a13 a12 a11 a10 a9 a8 0000 0000 b p40al lo addr. comparator of p4.0 94h a7 a6 a5 a4 a3 a2 a1 a0 0000 0000 b p4conb p4 control register b 93h p43fun 1 p43fun 0 p43cmp 1 p43cmp 0 p42fun 1 p42fun 0 p42cmp 1 p42cmp 0 0000 0000 b p4cona p4 control register a 92h p41fun 1 p41fun 0 p41cmp 1 p41cmp 0 p40fun 1 p40fun 0 p40cmp 1 p40cmp 0 0000 0000 b exif external interrupt flag 91h ie5 ie4 ie3 ie2 - - - - 0000 xxxxb p1 port 1 90h (97) adc7 (96) adc6 (95) adc5 (94) adc4 (93) txd1/ adc3 (92) rxd1/ adc2 (91) adc1/ brake (90) t2/ adc0 1111 1111 b ckcon1 clock control 1 8fh - - - - - - ccdiv1 ccdiv0 0000 0000 b ckcon clock control 8eh wd1 wd0 t2m t1m t0m md2 md1 md0 0000 0001 b th1 timer high 1 8dh th1.7 th1.6 th1. 5 th1.4 th1.3 th1.2 th1.1 th1.0 0000 0000 b preliminary w79e225a/226a/227a data sheet publication release date: april 15, 2008 - 26 - revision a4.0 continued symbol definition addr ess msb bit_ a ddress, symbol lsb reset th0 timer high 0 8ch th0.7 th0.6 th0. 5 th0.4 th0.3 th0.2 th0.1 th0.0 0000 0000 b tl1 timer low 1 8bh tl1.7 tl1.6 tl1.5 tl1.4 tl1.3 tl1.2 tl1.1 tl1.0 0000 0000 b tl0 timer low 0 8ah tl0.7 tl0.6 tl0.5 tl0.4 tl0.3 tl0.2 tl0.1 tl0.0 0000 0000 b tmod timer mode 89h gate t c / m1 m0 gate t c / m1 m0 0000 0000 b tcon timer control 88h (8f) tf1 (8e) tr1 (8d) tf0 (8c) tr0 (8b) ie1 (8a) it1 (89) ie0 (88) it0 0000 0000 b pcon power control 87h smod sm od0 - - gf1 gf0 pd idl 00xx 0000 b th3 timer high 3 85h th3.7 th3.6 th3. 5 th3.4 th3.3 th3.2 th3.1 th3.0 0000 0000 b tl3 timer low 3 84h tl3.7 tl3.6 tl3.5 tl3.4 tl3.3 tl3.2 tl3.1 tl3.0 0000 0000 b dph data pointer high 83h dph.7 dph.6 dp h.5 dph.4 dph.3 dph.2 dph.1 dph.0 0000 0000 b dpl data pointer low 82h dpl.7 dpl.6 dpl.5 dpl.4 dpl.3 dpl.2 dpl.1 dpl.0 0000 0000 b sp stack pointer 81h sp.7 sp.6 sp.5 sp.4 sp.3 sp.2 sp.1 sp.0 0000 0111 b p0 port 0 80h (87) int5 (86) int4 (85) int3 (84) int2 (83) /ss (82) spclk (81) mosi (80) miso 1111 1111 b table 7-2: special function registers preliminary w79e225a/226a/227a data sheet publication release date: april 15, 2008 - 27 - revision a4.0 port 0 bit: 7 6 5 4 3 2 1 0 p0.7 p0.6 p0.5 p0.4 p0.3 p0.2 p0.1 p0.0 mnemonic: p0 address: 80h port 0 is an open-drain 8-bit bi-directional i/o port. as an alternate function port 0 can function as the multiplexed address/data bus to access off-chip me mory. during the time when ale is high, the lsb of a memory address is pres ented. when ale is low, the port transi ts to a bi-directional data bus. this bus is used for reading external rom and for reading or writing external ram memory or peripherals. when used as a memory bus, the port provides active high drivers. the reset condition of port 0 is tri- state. pull-up resistors are required when using port 0 as an i/o port. bit name function 0 p0.0 miso: spi master in slave out. 1 p0.1 mosi: spi master out slave in. 2 p0.2 spclk: spi clock. 3 p0.3 /ss: slave select. 4 p0.4 int2: external interrupt 2. 5 p0.5 int3: external interrupt 3. 6 p0.6 int4: external interrupt 4. 7 p0.7 int5: external interrupt 5. stack pointer bit: 7 6 5 4 3 2 1 0 sp.7 sp.6 sp.5 sp.4 sp.3 sp.2 sp.1 sp.0 mnemonic: sp address: 81h the stack pointer stores the scratch-pad ram addre ss where the stack begin s. in other words it always points to the top of the stack. data pointer low bit: 7 6 5 4 3 2 1 0 dpl.7 dpl.6 dpl.5 dpl.4 dpl.3 dpl.2 dpl.1 dpl.0 mnemonic: dpl address: 82h this is the low byte of the standard 8032 16-bit data pointer. preliminary w79e225a/226a/227a data sheet publication release date: april 15, 2008 - 28 - revision a4.0 data pointer high bit: 7 6 5 4 3 2 1 0 dph.7 dph.6 dph.5 dph.4 dph.3 dph.2 dph.1 dph.0 mnemonic: dph address: 83h this is the high byte of the standard 8032 16-bit data pointer. timer 3 lsb bit: 7 6 5 4 3 2 1 0 tl3.7 tl3.6 tl3.5 tl3.4 tl3.3 tl3.2 tl3.1 tl3.0 mnemonic: tl3 address: 84h bit name function 7-0 timer 3 lsb lsb of timer3 timer 3 msb bit: 7 6 5 4 3 2 1 0 th3.7 th3.6 th3.5 th3.4 th3.3 th3.2 th3.1 th3.0 mnemonic: th3 address: 85h bit name function 7-0 timer 3 msb msb of timer3 power control bit: 7 6 5 4 3 2 1 0 smod smod0 - - gf1 gf0 pd idl mnemonic: pcon address: 87h bit name function 7 smod this bit doubles the serial port baud rate in mode 1, 2, and 3 when set to 1. 6 smod0 framing error detection enable. when smod0 is set to 1, then scon.7 (scon1.7) now indicates a frame error and acts as the fe (fe_1) flag. when smod0 is 0, then scon.7 (scon1.7) acts as per the standard 8032 function. 5-4 - reserved. 3-2 gf1-0 these two bits are general purpose user flags. 1 pd setting this bit causes the device to go into the powerdown mode. in this mode all the clocks are stopped and program execution is frozen. 0 idl setting this bit causes the device to go into the idle mode. in this mode the clock to the cpu is stopped, so program ex ecution is frozen, but the clock to the serial ports, timer, pwm, adc, spi and interrupt blocks is not stopped, and these blocks continue operating unhindered. preliminary w79e225a/226a/227a data sheet publication release date: april 15, 2008 - 29 - revision a4.0 timer control bit: 7 6 5 4 3 2 1 0 tf1 tr1 tf0 tr0 ie1 it1 ie0 it0 mnemonic: tcon address: 88h bit name function 7 tf1 timer 1 overflow flag. this bit is set when timer 1 overflows. it is cleared automatically when the program does a timer 1 interrupt service routine. software can also set or clear this bit. 6 tr1 timer 1 run control. this bit is set or cleared by software to turn timer/counter on or off. 5 tf0 timer 0 overflow flag. this bit is set when timer 0 overflows. it is cleared automatically when the program does a timer 0 interrupt service routine. software can also set or clear this bit. 4 tr0 timer 0 run control. this bit is set or cleared by software to turn timer/counter on or off. 3 ie1 interrupt 1 edge detect flag: set by hardware when an edge/level is detected on int1. this bit is cleared by hardware when the service routine is vectored to only if the interrupt was edge triggered. otherwise it follows the inverse of the pin. 2 it1 interrupt 1 type control. set/cleared by software to specify falling edge/ low level triggered external inputs. 1 ie0 interrupt 0 edge detect flag. set by hardware when an edge/level is detected on int0. this bit is cleared by hardware when the service routine is vectored to only if the interrupt was edge triggered. otherwise it follows the inverse of the pin. 0 it0 interrupt 0 type control: set/cleared by software to specify falling edge/ low level triggered external inputs. preliminary w79e225a/226a/227a data sheet publication release date: april 15, 2008 - 30 - revision a4.0 timer mode control bit: 7 6 5 4 3 2 1 0 gate t c / m1 m0 gate t c / m1 m0 timer1 timer0 mnemonic: tmod address: 89h bit name function 7 gate gating control: when this bit is set, timer 1 is enabled only while the int1 pin is high and the tr1 control bit is set. when cleared, the int1 pin has no effect, and timer 1 is enabled whenever tr1 is set. 6 t c/ timer or counter select: when clear, timer 1 is incremented by the internal clock. when set, the timer counts falling edges on the t1 pin. 5 m1 timer 1 mode select bit 1. see table below. 4 m0 timer 1 mode select bit 0. see table below. 3 gate gating control: when this bit is set, timer 0 is enabled only while the int0 pin is high and the tr0 control bit is set. when cleared, the int0 pin has no effect, and timer 0 is enabled whenever tr0 is set. 2 t c/ timer or counter select: when clear, timer 0 is incremented by the internal clock. when set, the timer counts falling edges on the t0 pin. 1 m1 timer 0 mode select bit 1. see table below. 0 m0 timer 0 mode select bit 0. see table below. m1, m0: mode select bits: m1 m0 mode 0 0 mode 0: 8-bit timer/counter tlx serves as 5-bit pre-scale. 0 1 mode 1: 16-bit timer/counter, no pre-scale. 1 0 mode 2: 8-bit timer/counter with auto-reload from thx 1 1 mode 3: (timer 0) tl0 is an 8-bit timer/counter c ontrolled by the standard timer-0 control bits. th0 is an 8-bit timer only controlled by timer-1 control bits. (timer 1) timer/counter 1 is stopped. timer 0 lsb bit: 7 6 5 4 3 2 1 0 tl0.7 tl0.6 tl0.5 tl0.4 tl0.3 tl0.2 tl0.1 tl0.0 mnemonic: tl0 address: 8ah tl0.7-0 timer 0 lsb timer 1 lsb bit: 7 6 5 4 3 2 1 0 tl1.7 tl1.6 tl1.5 tl1.4 tl1.3 tl1.2 tl1.1 tl1.0 mnemonic: tl1 address: 8bh tl1.7-0 timer 1 lsb preliminary w79e225a/226a/227a data sheet publication release date: april 15, 2008 - 31 - revision a4.0 timer 0 msb bit: 7 6 5 4 3 2 1 0 th0.7 th0.6 th0.5 th0.4 th0.3 th0.2 th0.1 th0.0 mnemonic: th0 address: 8ch th0.7-0 timer 0 msb timer 1 msb bit: 7 6 5 4 3 2 1 0 th1.7 th1.6 th1.5 th1.4 th1.3 th1.2 th1.1 th1.0 mnemonic: th1 address: 8dh th1.7-0 timer 1 msb clock control bit: 7 6 5 4 3 2 1 0 wd1 wd0 t2m t1m t0m md2 md1 md0 mnemonic: ckcon address: 8eh bit name function 7 wd1 watchdog timer mode select bit 1. see table below. 6 wd0 watchdog timer mode select bit 0. see table below. 5 t2m timer 2 clock select: 1: divide-by-4 clock. 0: divide-by-12 clock. 4 t1m timer 1 clock select: 1: divide-by-4 clock. 0: divide-by-12 clock. 3 t0m timer 0 clock select: 1: divide-by-4 clock. 0: divide-by-12 clock. 2 md2 stretch movx select bit 2: md2, md1, and md0 select the stretch value for the movx instruction. the rd or wr strobe is stretched by the selected interval, which enables the device to access faster or slower external memory de vices or peripherals without the need for external circuits. by default, the stretch value is one. see table below. (note: when accessing on-chip sram, these bits have no effect, and the movx instruction always takes two machine cycles.) 1 md1 stretch movx select bit 1. see md2. 0 md0 stretch movx select bit 0. see md2. preliminary w79e225a/226a/227a data sheet publication release date: april 15, 2008 - 32 - revision a4.0 wd1, wd0: mode select bits: these bits determine the time-out periods for the watchdog timer. the reset time-out period is 512 clocks more than the interrupt time-out period. wd1 wd0 interrupt time-out reset time-out 0 0 2 17 2 17 + 512 0 1 2 20 2 20 + 512 1 0 2 23 2 23 + 512 1 1 2 26 2 26 + 512 md2, md1, md0: stretch movx select bits: md2 md1 md0 stretch value movx duration 0 0 0 0 2 machine cycles 0 0 1 1 3 machine cycles (default) 0 1 0 2 4 machine cycles 0 1 1 3 5 machine cycles 1 0 0 4 6 machine cycles 1 0 1 5 7 machine cycles 1 1 0 6 8 machine cycles 1 1 1 7 9 machine cycles clock control 1 bit: 7 6 5 4 3 2 1 0 - - - - - - ccdiv1 ccdiv0 mnemonic: ckcon1 address: 8fh bit name function 7-2 - reserved. 1-0 ccdiv timer 3 clock select. ccdiv1 ccdiv0 timer 3 clock 0 0 fosc 0 1 fosc/4 1 0 fosc/16 1 1 fosc/32 port 1 bit: 7 6 5 4 3 2 1 0 p1.7 p1.6 p1.5 p1.4 p1.3 p1.2 p1.1 p1.0 mnemonic: p1 address: 90h preliminary w79e225a/226a/227a data sheet publication release date: april 15, 2008 - 33 - revision a4.0 bit name function 7-0 p1 general purpose i/o port. most instructions will read t he port pins in case of a port read access, however in case of r ead-modify-write instructions, the port latch is read. some pins also have alternate input or output functions. the alternate functions are described below. alternate function1 alternate function2 p1.0 t2: external i/o for timer/counter 2 adc0: analog input0 p1.1 pwm brake adc1: analog input1 p1.2 rxd1 adc2: analog input2 p1.3 txd1 adc3: analog input3 p1.4 adc4: analog input4 p1.5 adc5: analog input5 p1.6 adc6: analog input6 p1.7 adc7: analog input7 external interrupt flag bit: 7 6 5 4 3 2 1 0 ie5 ie4 ie3 ie2 - - - - mnemonic: exif address: 91h bit name function 7 ie5 external interrupt 5 flag. set by har dware when a rising/falling/both edges is detected onint5 pin. 6 ie4 external interrupt 4 flag. set by har dware when a rising/falling/both edges is detected on int4 pin. 5 ie3 external interrupt 3 flag. set by har dware when a rising/falling/both edges is detected on int3 pin. 4 ie2 external interrupt 2 flag. set by hardw are when a rising edge is detected on int2 pin. 3-0 - reserved. port 4 control register a bit: 7 6 5 4 3 2 1 0 p41fun1 p41fun0 p41cmp1 p41cmp 0 p40fun1 p40fun0 p40cmp1 p40cmp0 mnemonic: p4cona address: 92h preliminary w79e225a/226a/227a data sheet publication release date: april 15, 2008 - 34 - revision a4.0 port 4 control register b bit: 7 6 5 4 3 2 1 0 p43fun1 p43fun0 p43cmp1 p43cmp 0 p42fun1 p42fun0 p42cmp1 p42cmp0 mnemonic: p4conb address: 93h bit name function p4xfun1, p4xfun0 port 4 alternate modes. =00: mode 0. p4.x is a general purpose i/o port which is the same as port 1. =01: mode 1. p4.x is a read strobe signal for chip select purpose. the address range depends on the sfr p4xah, p4xal and bits p4xcmp1, p4xcmp0. =10: mode 2. p4.x is a write strobe signal for chip select purpose. the address range depends on the sfr p4xah, p4xal and bits p4xcmp1, p4xcmp0. =11: mode 3. p4.x is a read/write str obe signal for chip select purpose. the address range depends on the sfr p4xah, p4xal and bits p4xcmp1, p4xcmp0. p4xcmp1, p4xcmp0 port 4 chip-select mode address comparison: =00: compare the full address (16 bits length) with the base address registers p4xah and p4xal. =01: compare the 15 high bits (a15-a1) of address bus with the base address registers p4xah and p4xal. =10: compare the 14 high bits (a15-a2) of address bus with the base address registers p4xah and p4xal. =11: compare the 8 high bits (a15-a8) of address bus with the base address registers p4xah and p4xal. p4.0 base address low byte register bit: 7 6 5 4 3 2 1 0 a7 a6 a5 a4 a3 a2 a1 a0 mnemonic: p40al address: 94h p4.0 base address high byte register bit: 7 6 5 4 3 2 1 0 a15 a14 a13 a12 a11 a10 a9 a8 mnemonic: p40ah address: 95h p4.1 base address low byte register bit: 7 6 5 4 3 2 1 0 a7 a6 a5 a4 a3 a2 a1 a0 mnemonic: p41al address: 96h preliminary w79e225a/226a/227a data sheet publication release date: april 15, 2008 - 35 - revision a4.0 p4.1 base address high byte register bit: 7 6 5 4 3 2 1 0 a15 a14 a13 a12 a11 a10 a9 a8 mnemonic: p41ah address: 97h serial port control bit: 7 6 5 4 3 2 1 0 sm0/fe sm1 sm2 ren tb8 rb8 ti ri mnemonic: scon address: 98h bit name function 7 sm0/fe serial port mode select bit 0 or framing error flag: this bit is controlled by the smod0 bit in the pcon register. (sm0) see table below. (fe) this bit indicates an invalid stop bit. it must be manually cleared by software. 6 sm1 serial port mode select bit 1. see table below. 5 sm2 serial port clock or multi-processor communication. (mode 0) this bit controls the serial port cloc k. if set to zero, the serial port runs at a divide-by-12 clock of the oscillator. this is compatible with the standard 8051/52. if set to one, the serial clock is a di vide-by-4 clock of the oscillator. (mode 1) if sm2 is set to one, ri is not ac tivated if a valid stop bit is not received. (modes 2 / 3) this bit enables multi-proces sor communication. if sm2 is set to one, ri is not activated if rb8, the ninth data bit, is zero. 4 ren receive enable: 1: enable serial reception. 0: disable serial reception. 3 tb8 (modes 2 / 3) this is the 9th bit to transmit. this bit is set by software. 2 rb8 (mode 0) no function. (mode 1) if sm2 = 0, rb8 is t he stop bit that was received. (modes 2 / 3) this is the 9th bit that was received. 1 ti transmit interrupt flag: this flag is set by the hardware at the end of the 8th bit in mode 0 or at the beginning of the stop bi t in the other modes during serial transmission. this bit must be cleared by software. 0 ri receive interrupt flag: this flag is set by the hardware at the end of the 8th bit in mode 0 or halfway through the stop bits in the other modes during serial reception. however, sm2 can restrict this behavior. this bit can only be cleared by software. sm1, sm0: mode select bits: sm0 sm1 mode description length baud rate 0 0 0 synchronous 8 tclk divided by 4 or 12 0 1 1 asynchronous 10 variable 1 0 2 asynchronous 11 tclk divided by 32 or 64 1 1 3 asynchronous 11 variable preliminary w79e225a/226a/227a data sheet publication release date: april 15, 2008 - 36 - revision a4.0 erial data buffer bit: 7 6 5 4 3 2 1 0 sbuf.7 sbuf.6 sbuf.5 sbuf.4 sbuf.3 sbuf.2 sbuf.1 sbuf.0 mnemonic: sbuf address: 99h bit name function 7-0 sbuf serial data is read from or written to this location. it consists of two separate 8 bit registers. one is the receive buffer, and t he other is the transmit buffer. any read access gets data from the receive data bu ffer, while write access is to the transmit data buffer. p4.2 base address low byte register bit: 7 6 5 4 3 2 1 0 a7 a6 a5 a4 a3 a2 a1 a0 mnemonic: p42al address: 9ah p4.2 base address high byte register bit: 7 6 5 4 3 2 1 0 a15 a14 a13 a12 a11 a10 a9 a8 mnemonic: p42ah address: 9bh p4.3 base address low byte register bit: 7 6 5 4 3 2 1 0 a7 a6 a5 a4 a3 a2 a1 a0 mnemonic: p43al address: 9ch p4.3 base address high byte register bit: 7 6 5 4 3 2 1 0 a15 a14 a13 a12 a11 a10 a9 a8 mnemonic: p43ah address: 9dh nvm control bit: 7 6 5 4 3 2 1 0 eer ewr ennvm - - - - nvmf mnemonic: nvmcon address: 9eh bit name function 7 eer set this bit to erase nvm data of page (n) to ffh. the nvm has 32 pages that each page has 64 bytes data memory. by select nvmaddrh and nvmaddrl of nvm addres s registers that will automatic enable page area. if set this bit, the page will be page erased, after finished, the nvmf flag will be set to ?1?, then this bit will be cleared. if nvmf flag is set, the erase and write nvm data memory are invalid. preliminary w79e225a/226a/227a data sheet publication release date: april 15, 2008 - 37 - revision a4.0 continued bit name function 6 ewr set this bit is write data to nvm data memory by nvmaddrh and nvmaddrl to decode nvm data memory. if finished, nvmf flag will be set to ?1?, and then this bit will be cleared. if nvmf flag is set, the erase and write nvm are invalid. 5 ennvm to enable read nvm data memory area, refer as below table. 0: to disable the movx instruction to read nvm data memory. 1: to enable the movx instruction to read nvm data memory, the external ram or aux-ram will be disabled. 4~1 - reserved. 0 nvmf nvm data memory erases or writes finished flag. if nvm data memory is finished by eras e or write, it will be set to ?1? by hardware and clear by software. and it will be interrupted when nvm erase/write interrupt is enabled. isp control register bit: 7 6 5 4 3 2 1 0 swrst/ hwb - ld/ap - - - ldsel enp mnemonic: chpcon address: 9fh bit name function 7 w:swrst r:hwb write access to this bit is different from read access. write this bit to 1 to force the microcon troller to reset to the initial condition, just like power-on reset. this action re -boots the microcontroller and starts normal operation. this bit w ill be cleared during the reset. read this bit to determine whether or not a hardware reboot is in progress. if cpu is rebooted by p3.6 & p3.7 or p4.3, this bit is set to 1 after the hardware reboot. note: p4.3 pin is available in 48l lqfp package only. 6 - reserved. 5 ld/ap (read-only) 0: cpu is executing ap flash eprom 1: cpu is executing ld flash eprom 4-2 - reserved. 1 ldsel (write-only) loader program location selection. this bit should be set before entering isp mode. 0: the executing program is in the 64-kb ap flash eprom. the 4-kb ld flash eprom is the destination for re-programming. 1: the executing program is in the 4-kb memory bank. the 64-kb ap flash eprom is the destination for re-programming. 0 enp flash eprom programming enable. 1: enable in-system programming mode. in this mode, erase, program and read operations are achieved. 0: disable in-system programming mode. the on-chip flash memory is read- only. preliminary w79e225a/226a/227a data sheet publication release date: april 15, 2008 - 38 - revision a4.0 the way to enter isp mode is to set enp to 1 and write ldsel properly then force cpu in idle mode, after idle mode is released cpu will restart from ap or ld rom according the value of ldsel. port 2 bit: 7 6 5 4 3 2 1 0 p2.7 p2.6 p2.5 p2.4 p2.3 p2.2 p2.1 p2.0 mnemonic: p2 address: a0h bit name function 7-0 p2 this port functions as an address bus dur ing external memory access, and as a general-purpose i/o port on devices that incorporate internal program memory. when p2 functions a non-multiplexed address bus a15-a8 the port latch cannot be used for general i/o purposes but exists to support the movx instructions. port 2 data will only be brought out on the p2.7-0 pins during indirect movx instructions. alternate function p2.0 pwm0 output. p2.1 pwm1 output. p2.2 pwm2 output. p2.3 pwm3 output. p2.4 pwm4 output. p2.5 pwm5 output. p2.6 scl, i2c serial clock. p2.7 sda, i2c serial data. xramah bit: 7 6 5 4 3 2 1 0 - - - - - a10 a9 a8 mnemonic: xramah address: a1h bit name function 7-3 - reserved. 2-0 a10-8 xramah is used for high byte addres s memory access through a15-8, when cpu executes movx with r0 (or r1) instructions. depending ennvm and dme0 setting, and address, the memory accessed may differs. table below shows the memory access destination. this device has on-chip sram at 1/2/2 k bytes. note: user should take care when accessing the memory with this instruction. access to invalid regions may cause undesirable results. preliminary w79e225a/226a/227a data sheet publication release date: april 15, 2008 - 39 - revision a4.0 port 4 chip-select polarity bit: 7 6 5 4 3 2 1 0 p43inv p42inv p41inv p40inv - pwdnh rmwfp pup0 mnemonic: p4csin address: a2h bit name function 7-4 p4xinv the active polarity of p4.x when it is set as a chip-select strobe output. high = active high. low = active low. note: x = 3,2,1,0. 3 - reserved. 2 pwdnh set pwdnh to logic 1 then ale and psen will keep high state, clear this bit to logic 0 then ale and psen will outpu t low during power down mode. 1 rmwfp control read path of instruction ?read-m odify-write?. when this bit is set, the read path of executing ?read-m odify-write? instruction is from port pin otherwise from sfr. 0 pup0 enable port 0 weak pull up. capture control 0 register bit: 7 6 5 4 3 2 1 0 cct2.1 cct2.0 cct1.1 cct1.0 cct0.1 cct0.0 ccld1 ccld0 mnemonic: capcon0 address: a3h bit name function 7-6 cct2.1-0 capture 2 edge select. cct2.1 cct2.0 description 0 0 rising edge trigger 0 1 falling edge trigger 1 0 rising and falling edge trigger 1 1 reserved. 5-4 cct1.1-0 capture 1 edge select. cct1.1 cct1.0 description 0 0 rising edge trigger 0 1 falling edge trigger 1 0 rising and falling edge trigger 1 1 reserved. 3-2 cct0.1-0 capture 0 edge select. cct0.1 cct0.0 description 0 0 rising edge trigger 0 1 falling edge trigger 1 0 rising and falling edge trigger 1 1 reserved. preliminary w79e225a/226a/227a data sheet publication release date: april 15, 2008 - 40 - revision a4.0 continued bit name function 1-0 ccld.1-0 reload trigger select. ccld1 ccld0 description 0 0 timer 3 overflow (default) 0 1 reload by capture 0 block 1 0 reload by capture 1 block 1 1 reload by capture 2 block capture control 1 register bit: 7 6 5 4 3 2 1 0 - - enf2 enf1 enf0 cptf2 cptf1/ cptf0 mnemonic: capcon1 address: a4h bit name function 7-6 - reserved. 5 enf2 enable filter for capture input 2. 4 enf1 enable filter for capture input 1. 3 enf0 enable filter for capture input 0. 2 cptf2 input capture/reload 2 interrupt flag. 1 cptf1/dirf input capture 2 flag share the same bit with dirf flag. ic mode - input capture/reload 1 interrupt flag. qei mode - direction changed interrupt flag. bit is set by hardware when direction index (dir) changes state and direction change interrupt is requested if it is enabled. dirf is cleared by software. 0 cptf0/qeif input capture 0 flag share the same bit with qei flag. ic mode ? input capture/reload 0 interrupt flag. qei mode - qei interrupt flag. 1. in free-counting mode, if pulse counter overflows or underflows. 2. in compare-counting mode, if pulse counter overflows from maximum count to zero or underflows from zero to maximum count. port 4 bit: 7 6 5 4 3 2 1 0 - - - - p4.3 p4 .2 p4.1 p4.0 mnemonic: p4 address: a5h bit name function 7-4 - reserved. 3-2 p4 gpio. 1 p4 gpio. alternate function t2ex/ic2 for time r 2 external trigger/input capture 2 respectively. 0 p4 gpio. alternate function stadc. external start adc trigger input. preliminary w79e225a/226a/227a data sheet publication release date: april 15, 2008 - 41 - revision a4.0 input capture 2/maximum counter low register bit: 7 6 5 4 3 2 1 0 ccl2.7/ maxcnt l.7 ccl2.6/ maxcnt l.6 ccl2.5/ maxcnt l.5 ccl2.4/ maxcnt l.4 ccl2.3/ maxcnt l.3 ccl2.2/ maxcnt l.2 ccl2.1/ maxcnt l.1 ccl2.0/ maxcnt l.0 mnemonic: ccl2/maxcntl address: a6h input capture 2/maximum counter high register bit: 7 6 5 4 3 2 1 0 cch2.7/ maxcnt h.7 cch2.6/ maxcnt h.6 cch2.5/ maxcnt h.5 cch2.4/ maxcnt h.4 cch2.3/ maxcnt h.3 cch2.2/ maxcnt h.2 cch2.1/ maxcnt h.1 cch2.0/ maxcnt h.0 mnemonic: cch2/maxcnth address: a7h interrupt enable bit: 7 6 5 4 3 2 1 0 ea eadc et2 es et1 ex1 et0 ex0 mnemonic: ie address: a8h bit name function 7 ea global enable: enable/disable all interrupts. 6 eadc enable adc interrupt. 5 et2 enable timer 2 interrupt. 4 es enable serial port 0 interrupts. 3 et1 enable timer 1 interrupt. 2 ex1 enable external interrupt 1. 1 et0 enable timer 0 interrupt. 0 ex0 enable external interrupt 0. slave address bit: 7 6 5 4 3 2 1 0 saddr.7 saddr.6 saddr.5 saddr.4 saddr.3 saddr.2 saddr.1 saddr.0 mnemonic: saddr address: a9h bit name function 7-0 saddr the saddr should be programmed to the given or broadcast address for serial port to which the slave processor is designated. slave address 1 bit: 7 6 5 4 3 2 1 0 saddr1.7 saddr1.6 saddr1.5 saddr1.4 saddr1.3 saddr1.2 saddr1.1 saddr1.0 mnemonic: saddr1 address: aah preliminary w79e225a/226a/227a data sheet publication release date: april 15, 2008 - 42 - revision a4.0 bit name function 7-0 saddr1 the saddr1 should be programmed to the given or broadcast address for serial port 1 to which the slave processor is designated. isp address low byte bit: 7 6 5 4 3 2 1 0 a7 a6 a5 a4 a3 a2 a1 a0 mnemonic: sfral address: ach low byte destination address for in system programming operations. isp address high byte bit: 7 6 5 4 3 2 1 0 a15 a14 a13 a12 a11 a10 a9 a8 mnemonic: sfrah address: adh low byte destination address for in system pr ogramming operations. (sfrah, sfral) represents the address of the rom byte that will be erased, programmed or read. isp data buffer bit: 7 6 5 4 3 2 1 0 d7 d6 d5 d4 d3 d2 d1 d0 mnemonic: sfrfd address: aeh in isp mode, read/write a specific byte rom content must go through sfrfd register. isp operation modes bit: 7 6 5 4 3 2 1 0 - wfwin noe nce ctrl3 ctrl2 ctrl1 ctrl0 mnemonic: sfrcn address: afh bit name function 7 - reserved. 6 wfwin on-chip flash eprom bank select for in-system programming. 0= ap flash eprom bank is selected as destination for re-programming. 1= ld flash eprom bank is selected as destination for re-programming. 5 noe flash eprom output enable. 4 nce flash eprom chip enable. 3-0 ctrl the flash control signals. preliminary w79e225a/226a/227a data sheet publication release date: april 15, 2008 - 43 - revision a4.0 isp mode wfwin noe nce ctrl[3:0] sfrah, sfral sfrfd erase 4kb ld flash 1 1 0 0010 x x erase 16/32/64k ap flash 0 1 0 0010 x x program 4kb ld flash 1 1 0 0001 address in data in program 16/32/64kb ap flash 0 1 0 0001 address in data in read 4kb ld flash 1 0 0 0000 address in data out read 16/32/64kb ap flash 0 0 0 0000 address in data out port 3 bit: 7 6 5 4 3 2 1 0 p3.7 p3.6 p3.5 p3.4 p3.3 p3.2 p3.1 p3.0 mnemonic: p3 address: b0h bit name function 7-0 p3 general purpose i/o port. each pin also has an alternate input or output function that is controlled by other sfrs. the alternate function is enabled if the corresponding port latch bit is set to 1. alternate function p3.7 rd strobe for read from external ram. p3.6 wr strobe for writ e to external ram. p3.5 t1/ic1/qeb; timer/counter 1 external count input/input capture 1/qei input b. p3.4 t0/ic0/qea; timer/counter 0 external count input/input capture 0/qei input a. p3.3 /int0 external interrupt 1. p3.2 /int1 external interrupt 0. p3.1 txd serial port output. p3.0 rxd serial port input. port 5 bit: 7 6 5 4 3 2 1 0 - - - - - - p5.1 p5.0 mnemonic: p5 address: b1h bit name function 7-2 - reserved. 1-0 p5 general purpose i/o port. each pin also has an alternate input or output function. this port can not support bit addressable. preliminary w79e225a/226a/227a data sheet publication release date: april 15, 2008 - 44 - revision a4.0 alternate function p5.1 pwm7 output function p5.0 pwm6 output function timer 3 reload lsb bit: 7 6 5 4 3 2 1 0 rcap3l.7 rcap3l.6 rcap3l.5 rcap3l.4 rcap3l.3 rcap3l.2 rcap3l.1 rcap3l.0 mnemonic: rcap3l address: b4h bit name function 7-0 rcap3l timer 3 reload lsb: this register is lsb of a 16 bit reload value when timer 3 is configured in reload mode. it served also as a compare register when timer 3 is configured as compare mode (see cmp/rl3 bit). timer 3 reload msb bit: 7 6 5 4 3 2 1 0 rcap3h.7 rcap3h.6 rcap3h.5 rcap3h.4 rcap3h.3 rcap3h.2 rcap3h.1 rcap3h.0 mnemonic: rcap3h address: b5h bit name function 7-0 rcap3h timer 3 reload msb: this register is msb of a 16 bit reload value when timer 3 is configured in reload mode. it served al so as a compare register when timer 3 is configured as compare mode (see cmp/rl3 bit). extended interrupt high priority 1 bit: 7 6 5 4 3 2 1 0 - - pnvmih pcptfh pt3h pbkfh ppwmfh pspih mnemonic: eip1 address: b6h bit name function 7-6 - reserved. 5 pnvmih nvm interrupt high priority. pnvmih = 1 sets it to highest priority level. 4 pcptfh capture/reload interrupt high priority. pc ptfh = 1 sets it to highest priority level. 3 pt3h timer 3 interrupt high priority. pt3h = 1 sets it to highest priority level. 2 pbkfh pwm brake interrupt high priority. pbkfh = 1 sets it to highest priority level. 1 ppwmfh pwm period interrupt high priority. ppw mfh = 1 sets it to highest priority level. 0 pspih spi interrupt high priority. pspih = 1 sets it to highest priority level. interrupt high priority bit: 7 6 5 4 3 2 1 0 - padch pt2h pshh pt1h px1h pt0h px0h mnemonic: iph address: b7h preliminary w79e225a/226a/227a data sheet publication release date: april 15, 2008 - 45 - revision a4.0 bit name function 7 - reserved. 6 padch this bit defines the adc interrupt high priority. padch = 1 sets it to highest priority level. 5 pt2h this bit defines the timer 2 interrupt hi gh priority. pt2h = 1 sets it to highest priority level. 4 psh this bit defines the serial port 0 interrupt high priority. psh = 1 sets it to highest priority level. 3 pt1h this bit defines the timer 1 interrupt hi gh priority. pt1h = 1 sets it to highest priority level. 2 px1h this bit defines the external interrupt 1 high priority. px1h = 1 sets it to highest priority level. 1 pt0h this bit defines the timer 0 interrupt hi gh priority. pt0h = 1 sets it to highest priority level. 0 px0h this bit defines the external interrupt 0 high priority. px0h = 1 sets it to highest priority level. interrupt priority bit: 7 6 5 4 3 2 1 0 - padc pt2 ps pt1 px1 pt0 px0 mnemonic: ip address: b8h bit name function 7 - reserved. 6 padc this bit defines the adc interrupt priority . padc = 1 sets it to higher priority level. 5 pt2 this bit defines the timer 2 interrupt priority. pt2 = 1 sets it to higher priority level. 4 ps this bit defines the serial port 0 interrupt pr iority. ps = 1 sets it to higher priority level. 3 pt1 this bit defines the timer 1 interrupt priority. pt1 = 1 sets it to higher priority level. 2 px1 this bit defines the external interrupt 1 pr iority. px1 = 1 sets it to higher priority level. 1 pt0 this bit defines the timer 0 interrupt priority. pt0 = 1 sets it to higher priority level. 0 px0 this bit defines the external interrupt 0 pr iority. px0 = 1 sets it to higher priority level. preliminary w79e225a/226a/227a data sheet publication release date: april 15, 2008 - 46 - revision a4.0 slave address mask enable bit: 7 6 5 4 3 2 1 0 saden.7 saden.6 sad en.5 saden.4 saden.3 sad en.2 saden.1 saden.0 mnemonic: saden address: b9h bit name function 7-0 saden this register enables the automatic addr ess recognition feature of the serial port. when a bit in the saden is set to 1, the same bit location in saddr will be compared with the incoming serial port data. when saden.n is 0, then the bit becomes don't care in the comparison. this register enables the automatic address recognition feature of the serial port. when all the bits of saden are 0, interrupt will occur for any incoming address. slave address mask enable 1 bit: 7 6 5 4 3 2 1 0 saden1.7 saden1.6 saden1. 5 saden1.4 saden1.3 saden1. 2 saden1.1 saden1.0 mnemonic: saden1 address: bah bit name function 7-0 saden1 this register enables the automatic addr ess recognition feature of the serial port 1. when a bit in the saden1 is set to 1, the same bit location in saddr1 will be compared with the incoming serial port data. when saden1.n is 0, then the bit becomes don't care in the comparison. this register enables the automatic address recognition feature of the serial port. when all the bits of saden1 are 0, interrupt will occur for any incoming address. pwm output override control registers bit: 7 6 5 4 3 2 1 0 povm.7 povm.6 povm.5 povm.4 povm.3 povm.2 povm.1 povm.0 mnemonic: povm address: bbh bit name function 7-0 povm pwm override mode enable bits; 0: the pwm output follows the corresponding pwm generator. 1: the pwm output is equal to corresponding bit in povd. pwm output state registers bit: 7 6 5 4 3 2 1 0 povd.7 povd.6 povd.5 povd.4 povd.3 povd.2 povd.1 povd.0 mnemonic: povd address: bch preliminary w79e225a/226a/227a data sheet publication release date: april 15, 2008 - 47 - revision a4.0 bit name function 7-0 povd pwm override data represents the value of pwm[7:0] respectively in override mode. 1 = output on pwm i/o pin is active when the corresponding pwm output override bit is cleared. 0 = output on pwm i/o pin is inactive when the corresponding pwm output override bit is cleared. pwm pin output source select bit: 7 6 5 4 3 2 1 0 pio7 pio6 pio5 pio4 pio3 pio2 pio1 pio0 mnemonic: pio address: bdh bit name function 7-0 pio.x select pin output source from pwm or i/o register; x=0~7; pion is effective only when option bit pwmoe/pwmee/pwm6e/pwm7e is in enabled status. reset value=0; 1 = correspondent i/o pin with high source/sink current. 0 = pwmn output; n=0~7 with high source/sink current. pwm output enable register bit: 7 6 5 4 3 2 1 0 pwm7en pwm6en pwm5en pwm4en pwm3en pwm2en pwm1en pwm0en mnemonic: pwmen address: beh bit name function 6,4,2,0 pwmeen set high to enable even pwm output; e = 0,2,4,6; reset value=0; 1 = enable pwm output. 0 = disable pwm output. 7,5,3,1 pwmoen set high to enable odd pwm output; o = 1,3,5,7; reset value=0; 1 = enable pwm output. 0 = disable pwm output. pwm 4 high bits register bit: 7 6 5 4 3 2 1 0 - - - - pwm4.11 pwm4.10 pwm4.9 pwm4.8 mnemonic: pwm4h address: bfh bit name function 7~4 - reserved 3~0 pwm4.11 ~pwm4.8 the pwm 4 register bit 11~8. preliminary w79e225a/226a/227a data sheet publication release date: april 15, 2008 - 48 - revision a4.0 serial port control 1 bit: 7 6 5 4 3 2 1 0 sm0_1/fe_1 sm1_1 sm2_1 ren_1 tb8_1 rb8_1 ti_1 ri_1 mnemonic: scon1 address: c0h bit name function 7 sm0_1/ fe_1 serial port 1 mode select bit 0 or framing error flag: this bit is controlled by the smod0 bit in the pcon register. (sm0) see table below. (fe) this bit indicates an invalid stop bit. it must be manually cleared by software. 6 sm1_1 serial port 1 mode select bit 1. see table below. 5 sm2_1 serial port clock or multi-processor communication. (mode 0) this bit controls the serial port cloc k. if set to zero, the serial port runs at a divide-by-12 clock of the oscillator. this is compatible with the standard 8051/52. if set to one, the serial clock is a di vide-by-4 clock of the oscillator. (mode 1) if sm2_1 is set to one, ri_1 is not activated if a valid stop bit is not received. (modes 2 / 3) this bit enables multi-proc essor communication. if sm2_1 is set to one, ri_1 is not activated if rb 8_1, the ninth data bit, is zero. 4 ren_1 receive enable: 1: enable serial reception. 0: disable serial reception. 3 tb8_1 (modes 2 / 3) this is the 9th bit to transmit. this bit is set by software. 2 rb8_1 (mode 0) no function. (mode 1) if sm2_1 = 0, rb8_1 is t he stop bit that was received. (modes 2 / 3) this is the 9th bit that was received. 1 ti_1 transmit interrupt flag: this flag is set by the hardware at the end of the 8th bit in mode 0 or at the beginning of the stop bi t in the other modes during serial transmission. this bit must be cleared by software. 0 ri_1 receive interrupt flag: this flag is set by the hardware at the end of the 8th bit in mode 0 or halfway through the stop bits in the other modes during serial reception. however, sm2_1 can restrict this behav ior. this bit can only be cleared by software. sm1_1, sm0_1: mode select bits: sm0_1 sm1_1 mode description length baud rate 0 0 0 synchronous 8 tclk divided by 4 or 12 0 1 1 asynchronous 10 variable 1 0 2 asynchronous 11 tclk divided by 32 or 64 1 1 3 asynchronous 11 variable preliminary w79e225a/226a/227a data sheet publication release date: april 15, 2008 - 49 - revision a4.0 serial data buffer 1 bit: 7 6 5 4 3 2 1 0 sbuf_1.7 sbuf_1.6 sbuf_1.5 sbuf_1.4 sbuf_1.3 sbuf_1.2 sbuf_1.1 sbuf_1.0 mnemonic: sbuf1 address: c1h bit name function 7-0 sbuf_1 for serial port 1. serial data is read fr om or written to this location. it actually consists of two separate 8 bit registers. one is the receive buffer, and the other is the transmit buffer. any read access gets data from the receive data buffer, while write access is to the transmit data buffer. timer 3 mode control bit: 7 6 5 4 3 2 1 0 enld icen2 icen1 icen0 t3cr - - - mnemonic: t3mod address: c2h bit name function 7 enld enable reloads from rcap3 registers to timer 3 counters. 6 icen2 capture 2 external enable. this bit enabl es the capture/reload function on the ic2 pin. an edge trigger (programmable by capcon0.cct2[1:0] bits) detected on the ic2 pin will result in capture from free running timer 3 counters to input capture 2 registers, or reload from rcap3 registers to timer 3 counters. 1 = enable. 0 = disable. 5 icen1 capture 1 external enable. this bit enabl es the capture/reload function on the ic1 pin. an edge trigger (programmable by capcon0.cct1[1:0] bits) detected on the ic1 pin will result in capture from free running timer 3 counters to input capture 1 registers, or reload from rcap3 registers to timer 3 counters. 1 = enable. 0 = disable. 4 icen0 capture 0 external enable. this bit enabl es the capture/reload function on the ic0 pin. an edge trigger (programmable by capcon0.cct0[1:0] bits) detected on the ic0 pin will result input capture fr om free running timer 3 counters to input capture 0 registers, or reload from rcap3 registers to timer 3 counters. 1 = enable. 0 = disable. 3 t3cr timer 3 capture reset. in the timer 3 capture mode this bit enables/disables hardware automatically reset timer 3 while the value in tl3 and th3 have been transferred into the input capture register (cclx, cchx). priority is given to t3cr to reset counter after capture. 2-0 - reserved. preliminary w79e225a/226a/227a data sheet publication release date: april 15, 2008 - 50 - revision a4.0 timer 3 control bit: 7 6 5 4 3 2 1 0 tf3 - - - - tr3 - cmp / rl3 mnemonic: t3con address: c3h bit name function 7 tf3 timer 3 overflows flag. this bit is set when timer 3 overflows. it is cleared only by software and set by hardware. 6-3 - reserved. 2 tr3 timer 3 run control. this bit enables/disables the operation of timer 3. halting this will preserve the current count in th3, tl3. 1 - reserved. 0 cmp / rl3 compare/reload select. this bit determines whether the timer 3 will be use for compare or reload function. 0 = timer 3 as reload mode, tf3 indicates the overflow flag 1 = timer 3 as compare mode, tf3 indicates the compare match flag. power management register bit: 7 6 5 4 3 2 1 0 - - - - - aleoff - dme0 mnemonic: pmr address: c4h bit name function 7-3 - reserved. 2 aleoff this bit disables the expression of the ale signal on the device pin during all on board program and data memory accesses . external memory accesses will automatically enable ale independent of aleoff. aleoff=0: ale expression is enabled. aleoff=1: ale expression is disabled. 1 - reserved. 0 dme0 this bit determines the on chip movx sram to be enabled or disabled. set this bit to 1 will enable the on chip 2 kb movx sram. fault sampling time register bit: 7 6 5 4 3 2 1 0 scmp1 scmp0 sfp1 sfp0 sfcen sfcst sfcdir lsbd mnemonic: fsplt address: c5h preliminary w79e225a/226a/227a data sheet publication release date: april 15, 2008 - 51 - revision a4.0 bit name function 7-6 scmp [1:0] smart fault compare value selector (read/write): 00 = 4 01 = 16 10 = 64 11 = 128 5-4 sfp[1:0] smart fault sampling frequency selector (read/write): 00 = fosc/4 01 = fosc/8 10 = fosc/16 11 = fosc/128 3 sfcen smart fault/brake counter enable (read/write): 0 = disable, and clear internal smart fault counter. 1 = enable smart fault detector. 2 sfcst smart fault/brake counter status (read only): 0 = counter is non-active. 1 = counter is active. 1 sfcdir smart fault/brake counters direction status (read only): 0 = down counting. 1 = up counting. 0 lsbd low level smart brake detector: 0 = disable low level smart brake detector. 1 = enable low level smart brake detector. it will be cleared by software. adc pin select bit: 7 6 5 4 3 2 1 0 adcps.7 adcps.6 adcps.5 adcps. 4 adcps.3 adcps.2 a dcps.1 adcps.0 mnemonic: adcps address: c6h bit name function 7-0 adcps adc input pin select. there are 8 adc input pins shared with p1.0~p1.7. its? functions are controlled by the bit value in adcps. set the bit to switch the corresponding pin to adc input port; clear the bit to disable the pin to perform adc input port. the reset value is 00h. bit corresponding pin bit corresponding pin adcps.0 p1.0 adcps.4 p1.4 adcps.1 p1.1 adcps.5 p1.5 adcps.2 p1.2 adcps.6 p1.6 adcps.3 p1.3 adcps.7 p1.7 timed access bit: 7 6 5 4 3 2 1 0 ta.7 ta.6 ta.5 ta.4 ta.3 ta.2 ta.1 ta.0 mnemonic: ta address: c7h preliminary w79e225a/226a/227a data sheet publication release date: april 15, 2008 - 52 - revision a4.0 bit name function 7-0 ta the timed access register controls the access to protected bits. to access protected bits, the user must first writ e aah to ta. this must be immediately followed by a write of 55h to ta. now a wi ndow is opened in the protected bits for three machine cycles, during which the user can write to these bits. for detail data, please refer "timed access protection" section. timer 2 control bit: 7 6 5 4 3 2 1 0 tf2 exf2 rclk tclk exen2 tr2 2 t c / 2 rl cp / mnemonic: t2con address: c8h bit name function 7 tf2 timer 2 overflows flag. this bit is set when timer 2 overflows. it is also set when the count is equal to the capture register in down count mode. it can be set only if rclk and tclk are both 0. it is clea red only by software. software can also set this bit. 6 exf2 timer 2 external flag. a negative transition on the t2ex pin (p4.1) or timer 2 underflow/overflow will cause this flag to set based on 2 rl cp / , exen2 and dcen bits. if exf2 is set by a negative transition, this flag must be cleared by software. setting this bit in software or detection of a negative transition on t2ex pin will force a timer interrupt if enabled. 5 rclk receive clock flag. this bit determines t he serial port time-base when receiving data in serial modes 1 or 3. if it is 0, then timer 1 overflow is used for baud rate generation, else timer 2 overflow is used. setting this bit forces timer 2 in baud rate generator mode. 4 tclk transmit clock flag: this bit determines the serial port time-base when transmitting data in mode 1 and 3. if it is set to 0, the timer 1 overflow is used to generate the baud rate clock; else timer 2 overflow is used. setting this bit forces timer 2 in baud rate generator mode. 3 exen2 timer 2 external enable. this bit enabl es the capture/reload function on the t2ex pin if timer 2 is not generating baud clocks for the serial port. if this bit is 0, then the t2ex pin will be ignored, el se a negative transition detected on the t2ex pin will result in capture or reload. 2 tr2 timer 2 run control. this bit enables/disabl es the operation of timer 2. halting this will preserve the current count in th2, tl2. 1 t c/ counter/timer select. this bit determines whether timer 2 will function as a timer or a counter. independent of this bit, the timer will run at 2 clocks per tick when used in baud rate generator mode. if it is set to 0, then timer 2 operates as a timer at a speed depending on t2m bit (ckcon.5), else, it will count negative edges on t2 pin. 0 rl2 cp/ capture/reload select. this bit deter mines whether the capture or reload function will be used for timer 2. if either rclk or tclk is se t, this bit will not function and the timer will function in an auto-reload mode following each overflow. if the bit is 0 then auto-reload will occur when timer 2 overflows or a falling edge is detected on t2ex if exen2 =1. if this bit is 1, then timer 2 captures will occur when a falling edge is detected on t2ex if exen2=1. preliminary w79e225a/226a/227a data sheet publication release date: april 15, 2008 - 53 - revision a4.0 timer 2 mode control bit: 7 6 5 4 3 2 1 0 hc5 hc4 hc3 hc2 t2cr - - dcen mnemonic: t2mod address: c9h bit name function 7 hc5 hardware clears int5 flag. setting this bi t allows the flag of external interrupt 5 to be automatically cleared by hardwar e while entering the interrupt service routine. 6 hc4 hardware clears int4 flag. setting this bi t allows the flag of external interrupt 4 to be automatically cleared by hardwar e while entering the interrupt service routine. 5 hc3 hardware clears int3 flag. setting this bi t allows the flag of external interrupt 3 to be automatically cleared by hardwar e while entering the interrupt service routine. 4 hc2 hardware clears int2 flag. setting this bi t allows the flag of external interrupt 2 to be automatically cleared by hardwar e while entering the interrupt service routine. 3 t2cr timer 2 capture reset. in the timer 2 capture mode this bit enables/disables hardware automatically reset timer 2 while the value in tl2 and th2 have been transferred into the capture register. 2-1 - reserved. 0 dcen down count enable. this bit, in conjunction with the t2ex pin, controls the up/down direction that timer 2 counts in 16-bit auto-reload mode. timer 2 capture lsb bit: 7 6 5 4 3 2 1 0 rcap2l. 7 rcap2l. 6 rcap2l. 5 rcap2l. 4 rcap2l. 3 rcap2l. 2 rcap2l. 1 rcap2l. 0 mnemonic: rcap2l address: cah bit name function 7-0 rcap2l timer 2 capture lsb: this register is used to capture the tl2 value when a timer 2 is configured in capture mode. rcap2l is also used as the lsb of a 16 bit reload value when timer 2 is configured in auto reload mode. timer 2 capture msb bit: 7 6 5 4 3 2 1 0 rcap2h. 7 rcap2h. 6 rcap2h. 5 rcap2h. 4 rcap2h. 3 rcap2h. 2 rcap2h. 1 rcap2h. 0 mnemonic: rcap2h address: cbh preliminary w79e225a/226a/227a data sheet publication release date: april 15, 2008 - 54 - revision a4.0 bit name function 7-0 rcap2h timer 2 capture hsb: this register is used to capture the th2 value when a timer 2 is configured in capture mode. rc ap2h is also used as the hsb of a 16 bit reload value when timer 2 is configured in auto reload mode. timer 2 lsb bit: 7 6 5 4 3 2 1 0 tl2.7 tl2.6 tl2.5 tl2.4 tl2.3 tl2.2 tl2.1 tl2.0 mnemonic: tl2 address: cch tl2 timer 2 lsb timer 2 msb bit: 7 6 5 4 3 2 1 0 th2.7 th2.6 th2.5 th2.4 th2.3 th2.2 th2.1 th2.0 mnemonic: th2 address: cdh th2 timer 2 msb pwm control register 2 bit: 7 6 5 4 3 2 1 0 bkch bkps bpen bken fp1 fp0 pmod1 pmod0 mnemonic: pwmcon2 address: ceh bit name function 7 bkch see table below for bkch settings. 6 bkps select which brake condition triggers br ake flag. lsbd bit is described in sfr fsplt. bkps lsbd description 0 0 0 = brake is asserted if p1.1 is low. 1 0 1 = brake is asserted if p1.1 is high x 1 low level smart brake detector. 5 bpen see table below for bpen settings. 4 bken 0 = the brake is never asserted. 1 = the brake is enabled. bit name function 3-2 fp[1:0] select pwm frequency prescaler select bits. the clock source of prescaler, fpwm is in phase wi th fosc if pwmrun=1. fp[1:0] fpwm 00 f osc 01 f osc /2 10 f osc /4 11 f osc /16 preliminary w79e225a/226a/227a data sheet publication release date: april 15, 2008 - 55 - revision a4.0 continued bit name function 1-0 pmod[1:0] pwm mode selects bits: pmod[1:0] description 00 edge-aligned mode. (up counter) 01 single-shot mode. (up counter) 10 center aligned mode (up-down counter) 11 reserved brake condition table bpen bkch brake condition 0 0 brake on, (software brake and keeping brake). software brake condition. when acti ve (bpen=bkch=0, and bken=1), pwm output follows pwmnb setting. this br ake has no effect on pwmrun bit; therefore, internal pwm generator continue s to run. when the brake is released, the state of pwm output depends on the current state of pwm generator output during the release. 0 1 brake on, when pwm is not running (pwmrun=0), the pwm output condition is follow pwmnb setting. when the brake is released (by disabling bken = 0), the pwm output resumes to the state when pwm generator stop running prior to enabling the brake. brake off, when pwm is running (pwmrun=1). 1 0 brake on, when brake pin asserted, pw m output follows pwmnb setting. the pwmrun will be clear. external pin brake condition. when active (by external pin), pwm output follows pwmnb setting. pwmrun will be cleared by hardware. bkf flag will be set. when the brake is released (by de-assert ing the external pin + disabling bken = 0), the pwm output resumes to the stat e of the pwm generator output prior to the brake. 1 1 this brake condition (by brake pin) c auses bkf to be set, but pwm generator continues to run. the pwm output does not follow pwmnb, instead it output continuously as per normal without affected by the brake. pwm 4 low bits register bit: 7 6 5 4 3 2 1 0 pwm4.7 pwm4.6 pwm4.5 pwm4.4 pwm4.3 pwm4.2 pwm4.1 pwm4.0 mnemonic: pwm4l address: cfh pwm4.7-0 pwm4 low bits register. program status word bit: 7 6 5 4 3 2 1 0 cy ac f0 rs1 rs0 ov f1 p mnemonic: psw address: d0h preliminary w79e225a/226a/227a data sheet publication release date: april 15, 2008 - 56 - revision a4.0 bit name function 7 cy carry flag. set for an arithmetic operation which results in a carry being generated from the alu. it is also used as the accumulator for the bit operations. 6 ac auxiliary carry: set when the previous operation resulted in a carry (during addition) or a borrow (during subtract ion) from the high order nibble. 5 f0 user flag 0. a general purpose flag that can be set or cleared by the by software. 4-3 rs.1-0 register bank selects bits: rs1 rs2 register bank address 0 0 0 00-07h 0 1 1 08-0fh 1 0 2 10-17h 1 1 3 18-1fh 2 ov overflow flag. set when a carry was generat ed from the seventh bit but not from the 8th bit as a result of the previous operation or vice-versa. 1 f1 user flag 1. general purpose flag that can be set or cleared by the user by software. 0 p parity flag. set/cleared by hardware to indicate odd/even number of 1's in the accumulator. pwmp counter high bits register bit: 7 6 5 4 3 2 1 0 - - - - pwmp.11 pwmp.10 pwmp.9 pwmp.8 mnemonic: pwmph address: d1h bit name function 7-4 - reserved. 3-0 pwmp.11~pwmp.8 pwm counter register bits 11~8. pwm 0 high bits register bit: 7 6 5 4 3 2 1 0 - - - - pwm0.11 pwm0.10 pwm0.9 pwm0.8 mnemonic: pwm0h address: d2h bit name function 7~4 - reserved. 3~0 pwm0.11 ~pwm0.8 the pwm 0 register bit 11~8. nvm data bit: 7 6 5 4 3 2 1 0 nvmdat.7 nvmdat.6 nvmdat.5 nvmdat.4 nvmdat.3 nvmdat.2 nvmdat.1 nvmdat.0 mnemonic: nvmdat address: d3h preliminary w79e225a/226a/227a data sheet publication release date: april 15, 2008 - 57 - revision a4.0 bit name function 7~0 nvmdat.7~nvmdat.0 the nvm data write register. the read nvm data is by movx instruction. qei control register bit: 7 6 5 4 3 2 1 0 - - - disidx dir qeim1 qeim0 qeien mnemonic: qeicon address: d4h bit name function 7-5 - reserved. 4 disidx disable input capture 2 edge detection function: 0 = enable ic2 edge detection function (default). 1 = disable ic2 edge detection function. this bit is effective when qeien=1. 3 dir direction index of motion detection bit: 1 = forward (up-counting). 0 = backward (down-counting). this bit is writable and readable. 2-1 qeim[1:0] qei mode select bits: qeim1 qeim0 descriptions 0 0 x4 free-counting mode 0 1 x2 free-counting mode 1 0 x4 compare-counting mode 1 1 x2 compare-counting mode 0 qeien input module mode select bit: 0 = input module performs input c apture functions. (default value). 1 = input module works as qei. pwm 2 high bits register bit: 7 6 5 4 3 2 1 0 - - - - pwm2.11 pwm2.10 pwm2.9 pwm2.8 mnemonic: pwm2h address: d5h bit name function 7~4 - reserved 3~0 pwm2.11 ~pwm2.8 pwm 2 register bit 11~8. pwm 6 high bits register bit: 7 6 5 4 3 2 1 0 - - - - pwm6.11 pwm6.10 pwm6.9 pwm6.8 mnemonic: pwm6h address: d6h preliminary w79e225a/226a/227a data sheet publication release date: april 15, 2008 - 58 - revision a4.0 bit name function 7~4 - reserved 3~0 pwm6.11 ~pwm6.8 pwm 6 register bit 11~8. watchdog control 2 bit: 7 6 5 4 3 2 1 0 - - - - - - - strld mnemonic: wdcon2 address: d7h bit name function 7-6 - reserved. 0 strld set this bit, cpu will restart from ld flash eprom after watchdog reset. clear this bit, cpu will restart from ap fl ash eprom after watchdog reset. this register is protected by timer access (ta) register. watchdog control bit: 7 6 5 4 3 2 1 0 - por - - wdif wtrf ewt rwt mnemonic: wdcon address: d8h bit name function 7 - reserved. 6 por power-on reset flag. hardware will set this flag on a power up condition. this flag can be read or written by software. a write by software is the only way to clear this bit once it is set. 5-4 - reserved. 3 wdif watchdog timer interrupt flag. this bit is set by hardware to indicate that the time-out period has elapsed and invoke watch dog timer interrupt if enabled (ewdi=1). this bit must be clear by software. 2 wtrf watchdog timer reset flag. hardware will set this bit when the watchdog timer causes a reset if ewt= 1. software can read it but must clear it manually. a power-on reset will also clear the bit. this bit helps software in determining the cause of a reset 1 ewt enable watchdog timer reset. setting this bit will enable the watchdog timer reset function after 512 clocks delay from time out and setting wtrf flag. 0 rwt reset watchdog timer. this bit restarts the watchdog timer and helps in putting the watchdog timer into a know state. it also helps in resetting the watchdog timer before a time-out occurs. if ewdi (eie.4) is set, an interrupt will occur when time-out. if ewt is set, 512 clocks after the time-out, a system reset will occur and cpu starts from 0000h. this bit is self-clearing. the wdcon sfr is set to a 0x0x0xx0b on an ex ternal reset. wtrf is set to a 1 on a watchdog timer reset, but to a 0 on power on resets. wtrf is not altered by an external reset. por is set to 1 by a power-on reset. ewt is cleared to 0 on a power-on reset and unaffected by other resets. preliminary w79e225a/226a/227a data sheet publication release date: april 15, 2008 - 59 - revision a4.0 the wdcon sfr is set to x0xx 0000b on an external reset. wtrf is set to a 1 on a watchdog timer reset, but to a 0 on power on resets. por is set to 1 by a power-on reset. ewt is cleared to 0 on a power-on reset, reset pin reset, watch dog timer reset and isp reset. all the bits in this sfr have unrestricted read ac cess. the bits of por, wdif, ewt and rwt require timed access (ta) procedure to write. the remain ing bits have unrestricted write accesses. please refer ta register description. pwmp counter low bits register bit: 7 6 5 4 3 2 1 0 pwmp.7 pwmp.6 pwmp.5 pwmp .4 pwmp.3 pwmp.2 pwmp.1 pwmp.0 mnemonic: pwmpl address: d9h bit name function 7~0 pwmp.7 ~pwmp.0 pwm counter low bits register. pwm0 low bits register bit: 7 6 5 4 3 2 1 0 pwm0.7 pwm0.6 pwm0.5 pwm0 .4 pwm0.3 pwm0.2 pwm0.1 pwm0.0 mnemonic: pwm0l address: dah bit name function 7~0 pwm0.7 ~pwm0.0 pwm 0 low bits register. nvm low byte address bit: 7 6 5 4 3 2 1 0 nvmaddr l.7 nvmaddr l.6 nvmaddr l.5 nvmaddr l.4 nvmaddr l.3 nvmaddr l.2 nvmaddr l.1 nvmaddr l.0 mnemonic: nvmaddrl address: dbh bit name function 7~0 nvmaddrl.7~ nvmaddrl.0 nvm low byte address. pwm control register 1 bit: 7 6 5 4 3 2 1 0 pwmrun load pwmf clrpwm pwm6i pwm4i pwm2i pwm0i mnemonic: pwmcon1 address: dch preliminary w79e225a/226a/227a data sheet publication release date: april 15, 2008 - 60 - revision a4.0 bit name function 7 pwmrun 0 = the pwm is not running. 1 = the pwm counter is running. 6 load this bit is auto cleared by hardware a fter the pwmp and pwmn are transferred to counter and compare register: 0 = the registers value of pwmp and pwmn is never loaded to counter and compare registers. 1 = the pwmp and pwmn registers load value to counter and compare registers at the counter underflow/match. 5 pwmf 12 bit counter overflow flag: 0 = the 12-bit counter is not underflow/match. 1 = the 12-bit counter is underflow/match. it will be set by hardware and cleared by software. 4 clrpwm 1 = clear 12-bit pwm counter to 000h. it will be automatically clear by hardware. 3-0 pwmxi 0 = pwm0 output is non-inverted. 1 = pwm0 output is inverted. note: x = 0,2,4,6. pwm 2 low bits register bit: 7 6 5 4 3 2 1 0 pwm2.7 pwm2.6 pwm2.5 pwm2 .4 pwm2.3 pwm2.2 pwm2.1 pwm2.0 mnemonic: pwm2l address: ddh bit name function 7~0 pwm2.7 ~pwm2.0 pwm 2 low bits register. pwm 6 low bits register bit: 7 6 5 4 3 2 1 0 pwm6.7 pwm6.6 pwm6.5 pwm6 .4 pwm6.3 pwm6.2 pwm6.1 pwm6.0 mnemonic: pwm6l address: deh bit name function 7~0 pwm6.7 ~pwm6.0 pwm 6 low bits register. pwm control register 3 bit: 7 6 5 4 3 2 1 0 pwm7b pwm6b pwm5b pwm4b pwm3b pwm2b pwm1b pwm0b mnemonic: pwmcon3 address: dfh preliminary w79e225a/226a/227a data sheet publication release date: april 15, 2008 - 61 - revision a4.0 bit name function 7-0 pwmxb 0 = the pwm0 output is low, when brake is asserted. 1 = the pwm0 output is high, when brake is asserted. note: x = 0~7 accumulator bit: 7 6 5 4 3 2 1 0 acc.7 acc.6 acc.5 acc.4 acc.3 acc.2 acc.1 acc.0 mnemonic: acc address: e0h bit name function 7-0 acc the a or acc register is the standard 8032 accumulator adc control register bit: 7 6 5 4 3 2 1 0 adcen - adcex adci adcs aadr.2 aadr.1 aadr.0 mnemonic: adccon address: e1h bit name function 7 adcen enable a/d converter function. set a dcen to logic high to enable adc block. 6 - reserved. 5 adcex enable external start control of adc conversion by a rising edge from p4.0. adcex=0: disable external start. adce x=1: enable external start control. 4 adci a/d converting complete/interrupt flag. th is flag is set when adc conversion is completed. the adc interrupt is requested if the interrupt is enabled. adci is set by hardware and cleared by software only. 3 adcs adc start and status: set this bit to star t an a/d conversion. it may also be set by stadc if adcex is 1. this signal remains high while the adc is busy and is reset right after adci is set. notes: 1. it is recommended to clear adci before adcs is set. however, if adci is cleared and adcs is set at the same time, a new a/d conversion may start on the same channel. 2. software clearing of adcs will abort conversion in progress. 3. adc cannot start a new conversion while adcs or adci is high. 2-0 aadr select and enable analog input channel from adc0 to adc7. aadr[2:0] adc selected input aadr[2:0] adc selected input 000 adcch0 (p1.0) 100 adcch4 (p1.4) 001 adcch1 (p1.1) 101 adcch5 (p1.5) 010 adcch2 (p1.2) 110 adcch6 (p1.6) 011 adcch3 (p1.3) 111 adcch7 (p1.7) preliminary w79e225a/226a/227a data sheet publication release date: april 15, 2008 - 62 - revision a4.0 the adci and adcs control the adc conversion as below: adci adcs adc status 0 0 adc not busy; a conversion can be started. 0 1 adc busy; start of a new conversion is blocked. 1 0 conversion completed; start of a new conversion requires adci = 0. 1 1 this is an internal temporary state that user can ignore it. adc converter result high register bit: 7 6 5 4 3 2 1 0 adc.9 adc.8 adc.7 adc.6 adc.5 adc.4 adc.3 adc.2 mnemonic: adch address: e2h bit name function 7-0 adc[9:2] 8 msb of 10 bit a/d conversion result. adch is a read only register. adc converter result low register bit: 7 6 5 4 3 2 1 0 adclk.1 adclk.0 - - - - adc.1 adc.0 mnemonic: adcl address: e3h bit name function 7-6 adclk adc clock frequency select. the 10 bit adc needs a clock to drive the converting that the clock frequency may not over 4mhz. adclk[1:0] controls the frequency of the clock to adc block: adclk.1 adclk.0 adc clock frequency 0 0 crystal clock / 4 (default) 0 1 crystal clock / 8 1 0 crystal clock / 16 1 1 reserved 1-0 adc 2 lsb of 10-bit a/d conversion result. both bits are read only. pwm dead-time control register 1 bit: 7 6 5 4 3 2 1 0 pdtc1.7 pdtc1.6 pdtc1.5 pdtc1.4 pdtc1.3 pdtc1.2 pdtc1.1 pdtc1.0 mnemonic: pdtc1 address: e5h preliminary w79e225a/226a/227a data sheet publication release date: april 15, 2008 - 63 - revision a4.0 bit name function 7-6 pdtc1 dead-time clock frequency (fdt) prescaler select bits. pdtc1.7 pdtc1.6 fdt 0 0 f osc/2 0 1 f osc /4 1 0 f osc /8 1 1 f osc /16 5-0 pdtc1 dead time counter. unsigned 6 bit dead time value bits for dead time unit. dead-time = fdt * (pdtc1 [5:0]+1) pwm dead-time control register 0 bit: 7 6 5 4 3 2 1 0 pdtc0.7 pdtc0.6 pdtc0.5 pdtc0.4 pdtc0.3 pdtc0.2 pdtc0.1 pdtc0.0 mnemonic: pdtc0 address: e6h bit name function 7-4 pdtc0 control complementary pwm to delay a dead-time at every rising edge or falling edge. reset value = 0. 1 = dead-time is inserted at falling edge. 0 = dead-time is inserted at rising edge. pdtc0.4 - controls the pair of (pwm0, pwm1). pdtc0.5 - controls the pair of (pwm2, pwm3). pdtc0.6 - controls the pair of (pwm4, pwm5). pdtc0.7 - controls the pair of (pwm6, pwm7). 3-0 pdtc0 enable dead-time insertion; dead-time inse rtion is only active when the pair of complementary pwm is enabled. reset value=0. if dead-time insertion is inactive, the outputs of pin pair ar e complementary without any delay. 1 = programmable dead-time is inserted in to the pair signals of comparator output to delay the pair signals change from low to high. 0 = disable dead-time insertion. pdtc0.0 - enables the dead-time inse rtion on the pin pair (pwm0, pwm1). pdtc0.1 - enables the dead-time inse rtion on the pin pair (pwm2, pwm3). pdtc0.2 - enables the dead-time inse rtion on the pin pair (pwm4, pwm5). pdtc0.3 - enables the dead-time inse rtion on the pin pair (pwm6, pwm7). pwm control register 4 bit: 7 6 5 4 3 2 1 0 pwmeom pwmoom pwm6om pwm7om - - - bkf mnemonic: pwmcon4 address: e7h preliminary w79e225a/226a/227a data sheet publication release date: april 15, 2008 - 64 - revision a4.0 bit name function 7 pwmeom pwm channel 0, 2 and 4 output mode. 0 = disable pwm channels 0, 2 and 4 to pwm output pins. 1 = enable pwm channels 0, 2 and 4 to pwm output pins. 6 pwmoom pwm channel 1, 3 and 5 output mode. 0 = disable pwm channels 1, 3 and 5 to pwm output pins. 1 = enable pwm channels 1, 3 and 5 to pwm output pins. 5 pwm6om pwm channel 6 output mode. 0 = disable pwm channel 6 to pwm output pin. 1 = enable pwm channel 6 to pwm output pin. 4 pwm7om pwm channel 7 output mode. 0 = disable pwm channel 7 to pwm output pin. 1 = enable pwm channel 7 to pwm output pin. 3-1 - reserved. 0 bkf the external brake pin flag. 0 = the pwm is not brake. 1 = the pwm is brake by external brak e pin. it will be cleared by software. together with option bits (pwmee and pwmo e), pwmeom, pwmoom, pwm6om and pwm7om control the pwm pin structure, as follow; pwmee/pwmoe (option bits) pwmeom/pwmoom /pwm6om/pwm7om pio.x (x = 0-7) pin structures x 0 x tri-state 1 (d isable 1 x quasi (i/o output) 0 (enable) 1 0 push pull (pwm output) 0 (enable) 1 1 push pull (i/o output) table 7-2: pwm pin structures (d uring internal rom execution) pwmee/pwmoe (option bits) pwmeom/pwmoom /pwm6om/pwm7om pio.x (x = 0-7) pin output pin structures 1 (disable) x x external access push pull & |