![]() |
|
| If you can't view the Datasheet, Please click here to try to view without PDF Reader . |
|
|
| Datasheet File OCR Text: |
| preliminary N79E875 d ata sheet 8- bit microcontroller publication release date: april 13, 2009 - 1 - revision a 02 table of contents - 1 general description ......................................................................................................... 5 2 features ................................................................................................................................. 6 3 parts inform ation list ..................................................................................................... 8 3.1 lead free (rohs) parts information list ......................................................................... 8 4 pin configuration ............................................................................................................... 9 5 pin description ................................................................................................................... 10 6 memory organization ...................................................................................................... 12 6.1 program flash memory ................................................................................................ 12 6.2 data flash memory ...................................................................................................... 12 6.3 data memory (accessed by movx) ............................................................................. 12 6.4 scratch - pad ram and register map ............................................................................ 12 6.5 working registers ........................................................................................................ 15 6.6 bit addressable locations ............................................................................................. 15 6.7 stack ............................................................................................................................. 15 7 special function reg isters ......................................................................................... 16 7.1 sfr location table ...................................................................................................... 16 7.2 sfr detail bit descriptions .......................................................................................... 20 8 instruction .......................................................................................................................... 70 9 power management .......................................................................................................... 80 9.1 idle mode ...................................................................................................................... 80 9.2 power down mode ....................................................................................................... 80 10 reset conditions ............................................................................................................... 81 10.1 external reset .............................................................................................................. 81 10.2 power - on reset (por) ................................................................................................ 81 10.3 watchdog timer reset ................................................................................................. 81 10.4 software reset ............................................................................................................. 81 10.5 brownout reset ............................................................................................................ 81 10.6 reset state ................................................................................................................... 81 11 interrupts ........................................................................................................................... 83 11.1 interrupt sources .......................................................................................................... 83 11.2 priority level structure ................................................................................................. 85 11.3 interrupt response time .............................................................................................. 87 12 nvm memory ......................................................................................................................... 8 9 13 programmable timers/ counters ............................................................................... 90
preliminary N79E875 data s heet - 2 - 13.1 timer/counters 0 & 1 ............................................................................................ 90 13.2 time - base selection ..................................................................................................... 90 13.3 mod e 0 ........................................................................................................................ 90 13.4 mode 1 ........................................................................................................................ 91 13.5 mode 2 ........................................................................................................................ 92 13.6 mode 3 ........................................................................................................................ 93 14 watchdog timer ................................................................................................................. 95 14.1 watchdog control .............................................................................................. 96 14.2 clock control of watchdog .................................................................................. 96 15 timer2/input capture modules .................................................................................... 98 15.1 capture mode ............................................................................................................... 98 15.2 compare mode ........................................................................................................... 106 15.3 reload mode ............................................................................................................... 106 16 timer3 ................................................................................................................................... 107 16.1 timer/ counter mode ................................................................................................... 108 16.2 capture mode ............................................................................................................. 108 16.3 compare mode ........................................................................................................... 109 16. 4 auto - reload mode ....................................................................................................... 110 17 serial port (uart) ........................................................................................................... 111 17.1 mode 0 ...................................................................................................................... 111 17.2 mode 1 ...................................................................................................................... 112 17.3 mode 2 ...................................................................................................................... 114 17.4 mode 3 ...................................................................................................................... 115 17.5 framing er ror detection ............................................................................................. 116 17.6 multiprocessor communications ................................................................................. 116 18 i2c serial control .......................................................................................................... 118 18.1 i2c port ....................................................................................................................... 118 18.2 sfr for i2c function .................................................................................................. 119 18.2.1 i2c address registers, i2addr ................................................................................. 119 18.2.2 i2c data register, i2dat ........................................................................................... 119 18.2.3 i2c control register, i2con ...................................................................................... 120 18.2.4 i2 c status register, i2status ................................................................................. 120 18.2.5 i2c clock baud rate bits, i2clk ............................................................................... 121 18.2.6 i2c time - out counter register, i2toc ...................................................................... 121 18.3 modes of operation .................................................................................................... 121 18.3.1 master transmitter mode ........................................................................................... 122 18.3.2 master receiver mode ............................................................................................... 122 18.3.3 slave receiver mode ................................................................................................. 122 preliminary N79E875 data s heet publication release date: april 13, 2009 - 3 - revision a02 18.3.4 slave transmitter mode ............................................................................................. 122 18.4 data transfer flow in five operating modes ............................................................. 122 19 serial pheripheral i nterface (spi) .......................................................................... 129 19.1 ge neral descriptions ................................................................................................... 129 19.2 block descriptions ....................................................................................................... 129 19.3 functional descriptions ............................................................................................... 131 19.3.1 master mode .............................................................................................................. 131 19.3.2 slave mode ................................................................................................................ 134 19.3.3 slave select ................................................................................................................ 138 19.3.4 slave select output enable ......................................................................................... 138 19.3.5 spi i/o pins mode ...................................................................................................... 139 19.3.6 programmable serial clock?s p hase and polarity ......................................................... 140 19.3.7 receive double buffered data register ........................................................................ 140 19.3.8 lsb first enable .......................................................................................................... 140 19.3.9 write collision detection ............................................................................................. 141 19.3.10 transfer complete interrupt ...................................................................................... 141 19.3.11 mode fau lt ............................................................................................................... 141 20 timed access protect ion ............................................................................................ 144 21 keyboard interrupt ( kbi) ............................................................................................. 146 22 i/o port configurati on ................................................................................................. 147 22.1 quasi - bidirectional output configuration ................................................................... 147 22.2 open drain output configuration ............................................................................... 148 22.3 push - pull output configuration .................................................................................. 148 22.4 input only configuration ............................................................................................. 149 22.5 sfr of i/o port configuration ..................................................................................... 149 23 oscillator ......................................................................................................................... 150 23.1 on - chip rc oscillator option ..................................................................................... 150 23.2 external clock input option ........................................................................................ 150 24 power monitoring fun ction ...................................................................................... 151 24.1 power on dete ct ........................................................................................................ 151 24.2 brownout detect ......................................................................................................... 151 24.3 sfr of brown - out detection ....................................................................................... 152 25 pulse - width - modulated (pwm) outp uts ................................................................. 153 25.1 pwm features ............................................................................................................ 153 25.2 pwm operation .......................................................................................................... 155 25.2.1 pwm operation mode ................................................................................................ 156 25.2.2 edge aligned pwm (up - counter) ................................................................................ 156 25.2.3 center aligned pwm (up /down counter) .................................................................... 159 25.3 pwm brake function .................................................................................................. 162 25.4 pwm output driving control ...................................................................................... 164 preliminary N79E875 data s heet - 4 - 25.5 pwm modes ............................................................................................................... 164 25.5.1 independent mode ...................................................................................................... 164 25.5.2 complementary mode ................................................................................................ 165 25.5.3 synchronous mode ..................................................................................................... 165 25.5.4 group mode ............................................................................................................... 165 25.6 polarity control ........................................................................................................... 166 25.7 pwm mask output ...................................................................................................... 166 25.8 sfr of pwm unit ....................................................................................................... 170 26 analog - to - digital converter (ad c) ......................................................................... 171 26.1 operation of adc ....................................................................................................... 171 26.1.1 normal operation of adc ........................................................................................... 171 26.1.2 adc start synchronous with pwm ............................................................................ 173 26.1.3 adc converting in power - dwon and idle mode ......................................................... 173 26.2 adc resolution and anal og supply: .......................................................................... 173 26.3 adc continuous mode ............................................................................................... 174 26.4 adc compare function .............................................................................................. 174 27 op amplifier ....................................................................................................................... 176 28 analog comparators .................................................................................................... 177 29 icp (in - circuit program) fla sh program ............................................................... 178 30 config bits ......................................................................................................................... 179 30.1 config0 .................................................................................................................... 179 30.2 config1 .................................................................................................................... 181 31 electrical character istics ....................................................................................... 183 31.1 absolute maximum ratings ........................................................................................ 183 31.2 dc electrical characteristic s ...................................................................................... 184 31.3 adc converter dc electrical characteristics ............................................................. 186 31.4 op amplifier electrical characteristics ....................................................................... 187 31.5 comparator electrical characteristics ........................................................................ 188 31.6 ac electrical characteristics ...................................................................................... 189 31.6.1 external clock characteristics .................................................................................... 189 31.6.2 supplied voltage - frequency ...................................................................................... 189 31.6.3 internal rc oscillator characteristics ......................................................................... 189 31.6.4 typical crystal application circuits ............................................................................. 190 32 package dimensions ....................................................................................................... 191 32.1 48l lqfp (7x7x1.4mm footprint 2.0mm) ................................................................... 191 33 revision history .............................................................................................................. 192 preliminary N79E875 data s heet publication release date: april 13, 2009 - 5 - revision a02 1 general description N79E875 series are 8 - bit turbo 51 microcontroller s wh ich ha ve embedded flash that can be programmed by icp (in circuit program) or by writer. the instruction sets of the N79E875 series are fully compatible with the standard 8052. N79E875 series contain a 16k bytes of main flash eprom; a 256 bytes of ram; 256 bytes aux - ram; 128 bytes nvm data flash eprom support; two 16- bit timer/counters; one 16- bit timer with 3 capture inputs; one 12- bit capture/compare/auto - reload timer; 8 - channel multiplexed 10 - bit a/d converter; 8 - channel 12 - bit pwm that includes 6 - channe l for 3 pairs complementary pwm; three serial ports that includes a spi, an i2c and an enhanced full duplex serial port; one op amplifier; two analog comparators; 3 - level selectable brownout detector. these peripherals are supported by 17 sources of four - l evel interrupt capability. to facilitate programming and verification, the flash eprom inside N79E875 series allow the program memory to be programmed and read electronically. once the code is confirmed, the user can protect the code for security. N79E875 series , built - in efficient pwm generator and input capture/timer, are designed for motor control applications such as e - bike, inverter s of dc / bldc /ac induction/stepping motor and home appliance, etc. the built - in rich functions and peripheral also suit to general application. preliminary N79E875 data s heet - 6 - 2 features ? fully static design 8 - bit turbo 51 cmos microcontroller; ? v dd = 4.5v to 5.5v @40mhz ? v dd = 3.0v to 5.5v @24mhz ? v dd = 2.4v to 5.5v @8mhz ? operating temperature range ? n79 e 875a/n79 e 875ra series: - 40 c ~ 8 5 c ? flexible cpu clock sour ce configurable by config - bit and software: ? high speed external oscillator: up to 40mhz crystal and resonator (enabled by config - bit). ? internal oscillator: nominal 22mhz/11mhz (selected by config - bit) N79E875 a series: 22mhz/11mhz with 2 5 % accuracy N79E875 ra series: 22.1184mhz/11.0592mhz with 2% accuracy, at 3. 3v/ 25 c ? on - chip memory ? 16k bytes of application program flash memory, with icp and external writer programmable mode. ? 128 bytes (8 pages x 16 bytes) data flash for customer data storage used and 10 k writer cycles ; data flash program/erase v dd =3.0v to 5.5v ? 256 bytes of on - chip scratch - pad ram. ? 256 bytes of auxiliary ram, software - selectable, accessed by movx instruction. ? maximum 36 i/o pins. ? four outputs mode and ttl/schmitt trigger selectable port. ? 17 interrupts source with four levels of priority. ? four timer/counters. ? two 16 - bit timer/counters ? one 16 - bit timer supports 3 capture inputs capability for hall sensor feedback. ? one 12 - bit timer supports 12 - bit auto reload timer, capture and compare mode. ? three serial ports ? one enhanced full duplex uart port with framing error detection and automatic address recognition. ? one spi with master/slave capability. ? one i2c with master/slave capability. ? four independent 12 - bit pwm duty control units with maximum 8 port pins: ? six pwm output channels with mask control for bldc application . ? three pairs complementary pwm with programmable dead - time insertion ? independent polarity setting for each channel ? two brake/fault input pins preliminary N79E875 data s heet publication release date: april 13, 2009 - 7 - revision a02 ? up to two channels pwm independent fro m paired pwm channels. ? one build - in op amplifier. ? eight - channel multiplexed with 10 - bits a/d converter. ? support synchronized trigger with pwm period. ? support op amplifier output conversion. ? support digital compare function. ? two analog comparators with opt ional internal reference voltage input at negative end. ? eight - keypad interrupt inputs. ? built - in power management. ? idle mode ? power down mode ? led drive capability (20ma) on all port pins. ? config - bits selectable 3 level s( 4.5v/3.8v/2.6 v ) b rown - o ut voltage det ect interrupt and reset. ? independent programmable watchdog timer. ? program and data flash security protection. ? development tools: ? jtag ice(in circuit emulation) tool ? icp(in circuit programming) writer ? packages: ? lead free (rohs) lqfp 48: n79e87 5 alg series ( - 40 c ~ 8 5 c ) ? lead free (rohs) lqfp 48: n79e87 5r alg series ( - 40 c ~ 8 5 c ) preliminary N79E875 data s heet - 8 - 3 parts information li st 3.1 lead free (rohs) parts information list table 3 - 1 lead free (rohs) parts information lis t part no. program flash eprom ram data flash eprom temp c internal rc osc 1 package N79E875alg 16kb 256 b+256 b 128 b - 40~8 5 c 22mhz 25% lqfp - 48 N79E875ralg 16kb 256 b+256 b 128 b - 40~85 c 22.1184mhz 2% lqfp - 48 note: 1. factory calibration condition: v dd = 3.3v , ta = 2 5 c preliminary N79E875 data s heet publication release date: april 13, 2009 - 9 - revision a02 4 pin configuration n79e87 5alg/ n79e87 5ralg 2 4 4 1 4 3 6 5 8 7 10 9 11 4 8 4 2 4 1 4 0 3 9 3 8 3 7 32 33 30 31 28 29 26 27 25 1 3 1 4 1 5 1 6 1 8 1 9 2 0 2 1 2 2 p 4 . 0 , cp 2 nb p 4 . 1 , cp 2 pb p 0 . 0 , adc 0 , opo , kb 0 p 3 . 6 , opp p 3 . 7 , opn p 3 . 4 vdd k b 4 , c p 1 n , a d c 4 , p 0 . 4 k b 5 , a d c 5 , p 0 . 5 k b 6 , i n t 1 , a d c 6 , p 0 . 6 k b 7 , p w m 6 , a d c 7 , p 0 . 7 s c l , t 0 , b k p 1 , p 1 . 5 s d a , i n t 0 , p 1 . 6 xt 1 , p 1 . 1 avss vss txd , p 1 . 2 nc nc nc mosi , ic 2 , p 2 . 6 t 1 / p 2 . 7 lqfp 48 - pin v s s a v s s s t a d c , b k p 0 , p 1 . 7 12 1 7 2 3 2 4 34 35 36 4 6 4 7 4 3 4 5 p 0 . 2 , adc 2 , cp 2 n , kb 2 p 0 . 3 , adc 3 , cp 1 p , kb 3 nc p 3 . 5 clkout , xt 2 , p 1 . 0 nc a v d d p 0 . 1 , adc 1 , cp 2 p , kb 1 miso , ic 1 , p 2 . 5 p 4 . 2 p 3 . 2 , p w m 5 p 3 . 1 , p w m 3 p 3 . 0 , p w m 1 p 2 . 4 , i c 0 , s s p 2 . 3 , t 3 , s c l k p 4 . 3 p 2 . 0 , p w m 0 , c p 2 o p 2 . 1 , p w m 2 , c p 1 o p 2 . 2 , p w m 4 p 3 . 3 , p w m 7 n c r x d , p 1 . 3 r s t , p 1 . 4 preliminary N79E875 data s heet - 10 - 5 pin description symbol alternate function 1 alternate function 2 alternate function 3 type descriptions vdd p power supply: supply voltage for operation. vss p ground: ground poten tial. avdd p analog power supply avss p analog ground. p0.0 adc0 opo kb0 i/o port0: support 4 mode output and 2 mode input. multifunction pins. p0.1 adc1 cp2pa kb1 i/o p0.2 adc2 cp2na kb2 i/o p0.3 adc3 cp1p kb3 i/o p0.4 adc4 cp1n kb4 i/o p0.5 adc5 kb5 i/o p0.6 adc6 /int1 kb6 i/o p0.7 adc7 pwm6 kb7 i/o p1.0 xt2 clkout i/o port1: support 4 mode output and 2 mode input. multifunction pins. p1.5 and p1.6 are permanently in open - drain type . p1.1 xt1 i/o p1.2 txd i/o p1.3 rxd i/o p1.4 /rst i, h(rst) p1.5 t0 scl bkp1 d p1.6 /int0 sda d p1.7 stadc bkp0 i/o p2.0 pwm0 cp2o i/o port2: support 4 mode output and 2 mode input. multifunction pins. p2.1 pwm2 cp1o i/o p2.2 pwm4 i/o p2.3 t3 sclk i/o p2.4 ic0 /ss i/o preliminary N79E875 data s heet publication release date: april 13, 2009 - 11 - revision a02 symbol alternate function 1 alternate function 2 alternate function 3 type descriptions p2.5 ic1 miso i/o p2.6 ic2 mosi i/o p2.7 t1 i/o p3.0 pwm1 i/o port3: support 4 modes output and 2 modes input. multifunction pins. p3.1 pwm3 i/o p3.2 pwm5 i/o p3.3 pwm7 i/o p3.4 i/o p3.5 i/o p3.6 opp i/o p3.7 opn i/o p4.0 cp2nb i/o support 4 modes output and 2 modes input. p4.1 cp2pb i/o p4.2 i/o p4.3 i/o type: p: p: power, i: input, o: output, i/o: bi - directional with 4 - type i/o modes,, h: internal pull - up, l: internal pull low, d: open drain notes: ? during p ower - on- reset, all port pins are in tri - stated. ? after power - on - reset, all port pins state will follow config0.prhi bit definition. ? all digital input pins support software enabled schmitt trigger buffer which is selected by sfr ports (ech ) in application if mcu pins need external pull - up, it is recommended to add a pull - up resistor (10k ? ) between pin and power(v dd ) instead of directly wiring pin to v dd for enhancing emc. preliminary N79E875 data s heet - 12 - 6 memory organization N79E875 series separate the memory into two se parate sections, the program memory and the data memory. the program memory is used to store the instruction op - codes, while the data memory is used to store data or for memory mapped devices. 0000 h 16 k bytes on - chip code memory unused code memory unused code memory 3 fffh ffffh fc 00 h fc 7 fh 128 bytes nvm data memory data flash memory area fc 1 fh fc 10h fc 0 fh fc 00h page 0 page 1 page 7 page 2 page 3 page 4 page 5 page 6 128 bytes nvm 16 bytes / page fc 3 fh fc 30h fc 2 fh fc 20h fc 5 fh fc 50h fc 4 fh fc 40h fc 7 fh fc 70h fc 6 fh fc 60h config 1 config 0 256 bytes on - chip aux - ram program flash memory area aux - ram configure bits figure 6 - 1 N79E875 series memory map 6.1 program flash memory the program memory on N79E875 series can be up to 16k bytes long. all instructions are fetched for execution from this memory area. the movc instruction can also access this memory region. 6.2 data flash memory the nvm data memory of flash eprom on the N79E875 series is 128 bytes long, with page size of 16 bytes . the N79E875 series read the content of data memory by using ?movc a, @a+dptr?. to write data is by nvmaddrl , nvmdat and nvmco n sfr?s registers. 6.3 data memory (accessed by movx) N79E875 provides 256 bytes aux ram accessed by the movx instruction. the data memory region is from 0000h to 00ffh. figure 6 - 1 shows the memory map for this product series. 6.4 scratch - pad ram and register map as mentioned before, N79E875 series have separate program and data memory areas. the on - chip 256 bytes scratch pad ram is in addition to the external memory. there are also several special function registers (sfrs) which can be ac cessed by software. the sfrs can be accessed only by direct addressing, while the on - chip ram can be accessed by either direct or indirect addressing. preliminary N79E875 data s heet publication release date: april 13, 2009 - 13 - revision a02 indirect ram addressing direct & indirect ram addressing sfr direct addressing only 00h 7fh 80h ffh figure 6 - 2 N79E875 series ram and sfr memory map since the scratch - pad ram is only 256 bytes it can be used only when data contents are small. there are several other special purpose areas within the scratch - pad ram. these are illustrated in next figure. preliminary N79E875 data s heet - 14 - bank 0 bank 1 bank 2 bank 3 03 02 01 00 04 05 06 07 0b 0a 09 08 0c 0d 0e 0 f 13 12 11 10 14 15 16 17 1b 1a 19 18 1c 1d 1e 1 f 23 22 21 20 24 25 26 27 2b 2a 29 28 2c 2d 2e 2 f 33 32 31 30 34 35 36 37 3b 3a 39 38 3c 3d 3e 3 f 43 42 41 40 44 45 46 47 4b 4a 49 48 4c 4d 4e 4 f 53 52 51 50 54 55 56 57 5b 5a 59 58 5c 5d 5e 5 f 63 62 61 60 64 65 66 67 6b 6a 69 68 6c 6d 6e 6 f 73 72 71 70 74 75 76 77 7b 7a 79 78 7c 7d 7e 7 f direct ram indirect ram 00h 07h 28h 08h 0fh 10h 17h 18h 1fh 20h 21h 22h 23h 24h 25h 26h 27h 29h 2ah 2bh 2ch 2 dh 2eh 2fh 30h 7fh 80h ffh figure 6 - 3 scratch - pad ram preliminary N79E875 data s heet publication release date: april 13, 2009 - 15 - revision a02 6.5 working registers there are four sets of working registers, each consisting of eight 8 - bit registers. these are termed ads banks 0, 1, 2, and 3. individual registers within the se banks can be directly accessed by separate instructions. these individual registers are named as r0, r1, r2, r3, r4, r5, r6 and r7. however, at any one time N79E875 series can work with only one particular bank. the bank selection is done by setting rs1 - rs0 bits in the psw. the r0 and r1 registers are used to store the address for indirect accessing. 6.6 bit addressable locations the scratch - pad ram area from location 20h to 2fh is byte as well as bit addressable. this means that a bit in this area can be i ndividually addressed. in addition some of the sfrs are also bit addressable. the instruction decoder is able to distinguish a bit access from a byte access by the type of the instruction itself. in the sfr area, any existing sfr whose address ends in a 0 or 8 is bit addressable. 6.7 stack the scratch - pad ram can be used for the stack. this area is selected by the stack pointer (sp), which stores the address of the top of the stack. whenever a jump, call or interrupt is invoked the return address is placed on the stack. there is no restriction as to where the stack can begin in the ram. by default however, the stack pointer contains 07h at reset. the user can then change this to any value desired. the sp will point to the last used value. therefore, the sp will be incremented and then address saved onto the stack. conversely, while popping from the stack the contents will be read first, and then the sp is decreased. preliminary N79E875 data s heet - 16 - 7 special function reg isters N79E875 series use special function registers (sfrs) to control and monitor peripherals and their modes. the sfrs reside in the register locations 80 - ffh and are accessed by direct addressing only. some of the sfrs are bit addressable. this is very useful in cases where we wish to modify a particular bit without changing t he others. the sfrs that are bit addressable are those whose addresses end in 0 or 8. N79E875 series contain all the sfrs present in the standard 8052. however some additional sfrs are added. in some cases the unused bits in the original 8052, have been gi ven new functions. the list of the sfrs is as follows. 7.1 sfr location table f8 ip1 p4m1 p4m2 pwmcon4 pwm6l pwm6h auxr2 f0 b spcr spsr spdr padids ip1h e8 eie 1 ports pme pmd ip2h e0 acc adccon adch adccon1 ccl0 cch0 ccl1 cch1 d8 wdcon (3) pwmpl pwm0l pwmcon1 pwm2l pwmb d0 psw pwmph pwm0h eie2 pwm2h pwmcon3 c8 t2con t2mod rcap2l rcap2h tl2 th2 nvmcon nvmdat c0 i2con i2addr t3con pnp nvmaddrl ta b8 ip0 saden i2data i2status i2clk i2timer b0 p3 p0m1 p0m2 p1m1 p1m2 p2m1 p2m2 ip0h a8 ie saddr dtcnt (3) cmp1 cmp2 pdtc0 (3) adcdly a0 p2 kbi auxr1 capcon0 capcon1 p4 ccl2 cch2 98 scon sbuf ip2 pio adcrl adcrh p3m1 p3m2 90 p1 t3l rcap3l rcap3ht3h pwm4l pwm4h 88 tcon tmod tl0 tl1 th0 th1 ckcon 80 p0 sp dpl dph div pcon table 7 - 1 special function register location table note : 1. the sfrs in the column with dark borders are bit - addressable 2. the table is condensed with eight locations per row. empty locations indicate that these are no registers at these address es. 3. with timed access protection on write operation. preliminary N79E875 data s heet publication release date: april 13, 2009 - 17 - revision a02 symbol definition address msb bit address, symbol lsb reset auxr2 auxr2 control regist er ffh t1oe t0oe pcmp2did s.1 pcmp2di ds.0 popdids enclk adc1sel enop 0000 0000b pwm6h pwm 6 high bits regi ster feh - pwm6.11 wm6.10 pwm6.9 pwm6.8 xxxx 0000b pwm6l pwm 6 low bits regis ter fdh pwm6.7 pwm6.6 pwm6.5 pwm6.4 pwm6.3 pwm6.2 pwm6.1 pwm6.0 0000 0000b pwmcon4 pwm control register 4 fch bk1filt.1 bk1filt.0 bk0filt.1 bk0filt.0 autobk 1 - bken1 bken0 000 0 0 x 00b p4m2 port 4 output mode 2 fbh - - - - p4m2.3 p4m2.2 p4m2.1 p4m2.0 xxxx 0000b p4m1 port 4 output mode 1 fah - - - - p4m1.3 p4m1.2 p4m1.1 p4m1.0 xxxx 0000b ip1 interrupt priority 1 f8h (ff) pcap (fe) ppwm (fd) pbrk (fc) pwdi (fb) - (fa) pci (f9) pkb (f8) pi2 0000 x000b ip1h interrupt high prior ity 1 f7h pcaph ppwmh pbrkh pwdih - pcih pkbh pi2h 0000 x000b padids port adc digital inp uts disable f6h padids.7 padids.6 padids.5 padids.4 padids.3 padids.2 padids.1 padids.0 0000 0000b spdr serial pe ripheral data register f5h spd.7 spd.6 spd.5 spd.4 spd.3 spd.2 spd.1 spd.0 xxxx xxxxb spsr serial peripheral st atus register f4h spif wcol spiovf modf drss - - - 0000 0xxxb spcr serial peripheral control register f3h ssoe spe lsbfe mstr cpol cpha spr1 spr0 0000 0100b pch pc counter high regi ster f2h 0000 0000b pcl pc counter low regis ter f1h 0000 0000b b b register f0h (f7) (f6) (f5) (f4) (f3) (f2) (f1) (f0) 0000 0000b ip2h interrupt high prior ity 2 efh - pt2h - - pspih - - pet3h x0xx 0xx0b pmd pwm mask data regist er eeh - - pmd.5 pmd.4 pmd.3 pmd.2 pmd.1 pmd.0 xx00 0000b pme pwm mask enable register edh - - pme.5 pme.4 pme.3 pme.2 pme.1 pme.0 xx00 0000b ports port shmitt register ech - - - p4s p3s p2s p1s p0s xxx0 0000b eie 1 interru pt enable 1 e8h (ef) ecptf (ee) epwm (ed) ebrk (ec) ewdi (eb) - (ea) eci (e9) ekb (e8) ei2c 0000 x000b cch1 input capture 1 high e7h cch1.7 cch1.6 cch1.5 cch1.4 cch1.3 cch1.2 cch1.1 cch1.0 0000 0000b ccl1 input capture 1 low e6h ccl1.7 ccl1.6 ccl1.5 ccl1 .4 ccl1.3 ccl1.2 ccl1.1 ccl1.0 0000 0000b cch0 input capture 0 high e5h cch0.7 cch0.6 cch0.5 cch0.4 cch0.3 cch0.2 cch0.1 cch0.0 0000 0000b ccl0 input capture 0 low e4h ccl0.7 ccl0.6 ccl0.5 ccl0.4 ccl0.3 ccl0.2 ccl0.1 ccl0.0 0000 0000b adccon1 adc contro l register 1 e3h adclk.1 adclk.0 stadct.1 stadct.0 dlydiv adccm pwmsrc .1 pwmsrc .0 0000 0000b adch adc converter result e2h adc.9 adc.8 adc.7 adc.6 adc.5 adc.4 adc.3 adc.2 xxxx xxxxb adccon adc control register e1h adc.1 adc.0 adcex adci adcs aadr2 aadr1 aadr0 xx00 0000b acc accumulator e0h (e7) (e6) (e5) (e4) (e3) (e2) (e1) (e0) 0000 0000b pwmb pwm brake output dfh - - pwm5b pwm4b pwm3b pwm2b pwm1b pwm0b xx00 0000b pwm2l pwm 2 low bits regis ter ddh pwm2.7 pwm2.6 pwm2.5 pwm2.4 pwm2.3 pwm2.2 pwm2.1 pwm2. 0 0000 0000b pwmcon1 pwm control register 1 dch pwmrun load pwmf clrpwm fbk1 fbk0 pmod.1 pmod.0 0000 0 000b pwm0l pwm 0 low bits regis ter dah pwm0.7 pwm0.6 pwm0.5 pwm0.4 pwm0.3 pwm0.2 pwm0.1 pwm0.0 0000 0000b pwmpl pwm counter low register d9h pwmp0.7 p wmp0.6 pwmp0.5 pwmp0.4 pwmp0.3 pwmp0.2 pwmp0.1 pwmp0.0 0000 0000b wdcon watch - dog control d8h (df) wdrun (de) - (dd) wd1 (dc) wd0 (db) wdif (da) wtrf (d9) ewrst (d8) wdclr external reset: 0x00 0x00b watchdog reset: 0x000100b power on reset 0x00 0000b pwm con3 pwm control register 3 d7h hz_even hz_odd grp pwmtype - - p6ctrl int_typ e xx 00 xx 00b pwm2h pwm 2 high bits regi ster d5h - - - - pwm2.11 pwm2.10 pwm2.9 pwm2.8 xxxx 0000b preliminary N79E875 data s heet - 18 - symbol definition address msb bit address, symbol lsb reset eie2 interrupt enable 2 d4h - et2 - - espi - eadcp et3 x0xx 0x00b pwm0h pwm 0 high bits register d2h - - - - pwm0.11 pwm0.10 pwm0.9 pwm0.8 xxxx 0000b pwmph pwm counter high register d1h - - - - pwmp.11 pwmp.10 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 00 00 0000b nvmdata nvm data cfh nvmdata .7 nvmdata. 6 nvmdata. 5 nvmdata .4 nvmdat a.3 nvmdat a.2 nvmdat a.1 nvmdat a.0 0000 0000b nvmcon nvm control ceh eer ewr - - - - - - 00xx xxxxb th2 timer 2 msb cdh th2.7 th2.6 th2.5 th2.4 th2.3 th2.2 th2.1 th2.0 0000 0000b tl2 timer 2 lsb cch tl2.7 tl2.6 tl2.5 tl2.4 tl2.3 tl2.2 tl2.1 tl2.0 0000 0000b rcap2h timer 2 reload msb cbh rcap2h.7 rcap2h.6 rcap2h.5 rcap2h.4 rcap2h. 3 rcap2h. 2 rcap2h. 1 rcap2h. 0 0000 0000b rcap2l timer 2 reload lsb cah rcap2l.7 rcap2l.6 rcap2l.5 rca p2l.4 rcap2l. 3 rcap2l. 2 rcap2l. 1 rcap2l. 0 0000 0000b t2mod timer 2 mode c9h enld icen2 icen1 icen0 t2cr cmpcr - - 0000 00xxb t2con timer 2 control c8h tf2 - - - - tr2 - cmp/rl2 0xxx x0x0b ta timed access protect ion c7h ta.7 ta.6 ta.5 ta.4 ta.3 ta.2 ta. 1 ta.0 0000 0000b nvmaddrl nvm low byte address c6h nvmaddr .7 nvmaddr. 6 nvmaddr .5 nvmaddr .4 nvmadd r.3 nvmadd r.2 nvmadd r.1 nvmadd r.0 0000 0000b nvmaddrh nvm high byte address c5h - - - - - - - nvmadd r.8 xxxx xxx0b pnp pwm negative polrari ty c3h - - pnp .5 pnp.4 pnp.3 pnp.2 pnp.1 pnp.0 xx00 0000b t3con timer 3 contol c2h tf3 exf3 t3cnte t3oe t3rst tr3 t3mod.1 t3mod.0 0000 0000b i2addr i2c address1 c1h addr.7 addr.6 addr.5 addr.4 addr.3 addr.2 addr.1 gc xxxx xxx0b i2con i2c control register c0h (c 7 ) - ( c 6 ) ens i (c 5 ) sta (c 4 ) sto (c 3 ) si (c 2 ) aa (c 1 ) - (c 0 ) - x00000xxb i2toc i2c timer - out counter register bfh - - - - - enti div4 tif xxxx x000b i2clk i2c clock rate beh i2clk.7 i2clk.6 i2clk.5 i2clk.4 i2clk.3 i2clk.2 i2clk.1 i2clk.0 00000000b i2status i2 c status register bdh b7 b6 b5 b4 b3 b2 b1 b0 1111 1 000b i2dat i2c data register bch i2dat.7 i2dat.6 i2dat.5 i2dat.4 i2dat.3 i2dat.2 i2dat.1 i2dat.0 xxxx xxxxb saden slave address mask b9h saden.7 saden.6 saden.5 saden.4 saden.3 saden.2 saden.1 saden.0 0 000 0000b ip0 interrupt priority b8h (bf) - (be) padc (bd) pbo (bc) ps (bb) pt1 (ba) px1 (b9) pt0 (b8) px0 x000 0000b ip0h interrupt high prior ity b7h - padch pboh psh pt1h px1h pt0h px0h x000 0000b p2m2 port 2 output mode 2 b6h p2m2.7 p2m2.6 p2m2.5 p2m 2.4 p2m2.3 p2m2.2 p2m2.1 p2m2.0 0000 0000b p2m1 port 2 output mode 1 b5h p2m1.7 p2m1.6 p2m1.5 p2m1.4 p2m1.3 p2m1.2 p2m1.1 p2m1.0 0000 0000b p1m2 port 1 output mode 2 b4h p1m2.7 - - - p1m2.3 p1m2.2 p1m2.1 p1m2.0 000x 0000b p1m1 port 1 output mode 1 b3h p 1m1.7 - - - p1m1.3 p1m1.2 p1m1.1 p1m1.0 000x 0000b p0m2 port 0 output mode 2 b2h p0m2.7 p0m2.6 p0m2.5 p0m2.4 p0m2.3 p0m2.2 p0m2.1 p0m2.0 0000 0000b p0m1 port 0 output mode 1 b1h p0m1.7 p0m1.6 p0m1.5 p0m1.4 p0m1.3 p0m1.2 p0m1.1 p0m1.0 0000 0000b p3 port 3 b0h (b7) p3.7 opn (b6) p3.6 opp (b5) p3.5 (b4) p3.4 (b3) p3.3 pwm7 (b2) p3.2 pwm5 (b1) p3.1 pwm3 (b0) p3.0 pwm1 1111 1111b (1) 0000 0000b adcdly adc delay start regi ster afh adcdly.7 adcdly.6 adcdly.5 adcdly.4 adcdly. 3 adcdly. 2 adcdly. 1 adcdly. 0 0000 000 0b pdtc0 pwm dead time contro l 0 register aeh - - - - - dtenb4 dtenb2 dtenb0 xxxx x000b cmp2 comparator 1 control register adh - hysen2 cmpen2 cp2 cn2 coe2 co2 cmf2 xx0x 0000b cmp1 comparator 1 control register ach - hysen1 cmpen1 - cn1 coe1 co1 cmf1 xx 0x 0000b dtcnt pwm dead time counter register abh dtcnt.7 dtcnt.6 dtcnt.5 dtcnt.4 dtcnt.3 dtcnt.2 dtcnt.1 dtcnt.0 0000 0000b saddr slave address a9h saddr.7 saddr.6 saddr.5 saddr.4 saddr.3 saddr.2 saddr.1 saddr.0 0000 0000b ie interrupt enable a8h (af) ea (ae) eadc (ad) ebo (ac) es (ab) et1 (aa) ex1 (a9) et0 (a8) ex0 0000 0000b cch2 input capture 2 high a7h cch2.7 cch2.6 cch2.5 cch2.4 cch2.3 cch2.2 cch2.1 cch2.0 0000 0000b preliminary N79E875 data s heet publication release date: april 13, 2009 - 19 - revision a02 symbol definition address msb bit address, symbol lsb reset ccl2 input capture 2 low a6h ccl2.7 ccl2.6 ccl2.5 ccl2.4 ccl2.3 ccl2.2 ccl2.1 cc l2.0 0000 0000b p4 port 4 a5h - - - - p4.3 p4.2 p4.1 cp2pb p4.0 cp2nb xxxx 1111b (1) xxxx 0000b capcon1 capture control 1 a4h - ic0ss enf2 enf1 enf0 cptf2 cptf1 cptf0 x000 0000b capcon0 capture control 0 a3h cct2.1 cct2.0 cct1.1 cct1.0 cct0.1 cct0.0 cc ld.1 ccld.0 0000 0000b auxr1 aux function registe r 1 a2h kbf bod boi lpbod srst adcen rcclk bos 0x00 0000b kbi keyboard interrupt a1h kbi.7 kbi.6 kbi.5 kbi.4 kbi.3 kbi.2 kbi.1 kbi.0 0000 0000b p2 port 2 a0h (a7) p2.7 t1 (a6) p2.6 ic2 mosi (a5) p2.5 ic1 miso (a4) p2.4 ic0 /ss (a3) p2.3 t3 sclk (a2) p2.2 pwm4 (a1) p2.1 pwm2 cp1o (a0) p2.0 pwm0 cp2o 1111 1111b (1) 0000 0000b p3m2 port 3 output mode 2 9fh p3m2.7 p3m2.6 p3m2.5 p3m2.4 p3m2.3 p3m2.2 p3m2.1 p3m2.0 0000 0000b p3m1 port 3 output mode 1 9eh p3m1.7 p3m1.6 p3m1.5 p3m1.4 p3m1.3 p3m1.2 p3m1.1 p3m1.0 0000 0000b adcrh adc compare referenc e high data register 9dh adcr.9 adcr.8 adcr.7 adcr.6 adcr.5 adcr.4 adcr.3 adcr.2 xxxx xxxxb adcrl adc compare referenc e low data/compare register 9ch adcr.1 adcr.0 adc po adcpi - - t3css enadcp xx10 xx00b pio pwm io register 9bh pio.7 pio.6 pio.5 pio.4 pio.3 pio.2 pio.1 pio.0 00 00 0000b ip2 interrupt priority 2 9ah - pt2 - - pspi - - pet3 x0xx 0xx0b 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 0000b pwm4h pwm 4 high bits regi ster 97h - - - - pwm4.11 pwm4.10 pwm4.9 pwm4.8 xxxx 0000b pwm4l pwm 4 low bits regis ter 96h pwm4.7 pwm4.6 pwm4.5 pwm4.4 pwm4.3 pwm4.2 pwm4.1 pwm4.0 0000 0000b rcap3ht3h timer 3 reload msb 93h rcap3.11 rcap3.10 rcap3.9 rcap3.8 t3.11 t3.10 t3.9 t3.8 0000 0000b rcap3l timer 3 reload lsb 92h rcap3.7 rcap3.6 rcap3.5 rcap3.4 rcap3.3 rcap3.2 rcap3.1 rcap3.0 0000 0000b tl3 timer 3 lsb 91h t3.7 t3.6 t3.5 t3.4 t3.3 t3.2 t3.1 t3.0 0000 0000b p1 port 1 90h (97) p1.7 stadc bkp0 (96) p1.6 /int0 sda (95) p1.5 t0 scl bkp1 (94) p1.4 /rst (93) p1.3 rxd (92) p1.2 txd (91) p1.1 xt1 (90) p1.0 xt2 clkout 1111 1111b (1) 00 00 0000b ckcon clock control 8eh - - - t1m t0m - - - xxx0 0xxxb th1 timer high 1 8dh th1.7 th1.6 th1.5 th1.4 th1.3 th1.2 th1.1 th1.0 0000 0000b th0 timer high 0 8ch th0.7 th0.6 th0.5 th0.4 th0.3 th0.2 th0.1 th0.0 0000 0000b tl1 timer low 1 8bh tl1.7 tl 1.6 tl1.5 tl1.4 tl1.3 tl1.2 tl1.1 tl1.0 0000 0000b tl0 timer low 0 8ah tl0.7 tl0.6 tl0.5 tl0.4 tl0.3 tl0.2 tl0.1 tl0.0 0000 0000b tmod timer mode 89h gate c/t m1 m0 gate c/t m1 m0 0000 0000b tcon timer control 88h (8f) tf1 (8e) tr1 (8d) tf0 (8c) tr0 (8b ) ie1 (8a) it1 (89) ie0 (88) it0 0000 0000b pcon power control 87h smod smod0 bof por gf1 gf0 pd idl 00xx 0000b div divider 86h ccdiv.1 ccdiv.0 pwmdiv.1 pwmdiv.0 t3div.1 t3div.0 t0div.1 t0div.0 0000 0000b dph data pointer high 83h dph.7 dph.6 dph.5 dph. 4 dph.3 dph.2 dph.1 dph.0 0000 0000b dpl data pointer low 82h dpl.7 dpl.6 dpl.5 dpl.4 dpl.3 dpl.2 dpl.1 dpl.0 0000 0000b sp stack pointer 81h sp.7 sp.6 sp.5 sp.4 sp.3 sp.2 sp.1 sp.0 0000 0111b p0 port 0 80h (87) p0.7 adc7 pwm6 kb7 (86) p0.6 adc6 /int1 k b6 (85) p0.5 adc5 kb5 (84) p0.4 adc4 cp1n kb4 (83) p0.3 adc3 cp1p kb3 (82) p0.2 adc2 cp2na kb2 (81) p0.1 adc1 cp2pa kb1 (80) p0.0 adc0 opo kb0 1111 1111b (1) 0000 0000b note: 1. if config0.prhi=1, the initial value is ffh at reset. if config0.prhi=0, the initial value is 00h at reset preliminary N79E875 data s heet - 20 - 7.2 sfr detail bit descriptions port 0 initial=1111_1111b/0000_0000b 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 p0.7 - 0: general purpose input/output port. most instructions will re ad the port pins in case of a port read access, however in case of read - modify - write instructions, the port latch is read. if config0.prhi=1, the initial value is ffh at reset. if config0.prhi=0, the initial value is 00h at reset. these alternate functions are described below . bit name function 7 p0.7 adc7 or pwm6 or kb7 pin or i/o pin by alternative. 6 p0.6 adc6 or /int1 or kb6 or i/o pin by alternative. 5 p0.5 adc5 or kb5 or clock (icp function) pin or i/o pin by alternative. 4 p0.4 adc4 or cp1n or kb 4 or data (icp function) pin or i/o pin by alternative. 3 p0.3 adc3 or cp1p or kb3 pin or i/o pin by alternative. 2 p0.2 adc2 or cp2na or kb2 pin or i/o pin by alternative. 1 p0.1 adc1 or cp2pa or kb1 pin or i/o pin by alternative. 0 p0.0 adc0 or opo o r kb0 pin or i/o pin by alternative. note: the initial value of the port is set by config0.prhi bit. the default setting for config0.prhi =1 which the alternative function output is turned on upon reset. if config0.prhi is set to 0, the user has to write a 1 to port sfr to turn on the alternative function output. stack pointer initial= 0000 0111 b 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 bit name function 7 - 0 sp.[7:0] the stack pointer stores the scratch - pad ram address where the stack begins. in other words it always points to the top of the stack. data pointer low initial= 0000 0 000b 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 bit name function preliminary N79E875 data s heet publication release date: april 13, 2009 - 21 - revision a02 7 - 0 dpl .[7:0] this is the low byte of the standard 8052 16 - bit data pointer. data pointer high initial= 0000 0 000b 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 bit name function 7 - 0 dph.[7:0] this is the hi gh byte of the standard 8052 16 - bit data pointer. this is the high byte of the dptr 16 - bit data pointer. divider initial= 0000 0 000b bit: 7 6 5 4 3 2 1 0 ccdiv.1 ccdiv.0 pwmdiv. 1 pwmdiv. 0 t3div.1 t3div.0 t0div.1 t0div.0 mnemonic: div address: 86h bit name function 7~6 ccdiv.1~ 0 timer 2 clock select: ccdiv.1 ccdiv.0 0 0 timer 2 clock = fcpu 0 1 timer 2 clock = fcpu/4 1 0 timer 2 clock = fcpu/16 1 1 timer 2 clock = fcpu/32 5~4 pwmdiv. 1~0 pwm clock select: pwmdiv.1 pwmdiv.0 0 0 pwm clock = fcpu 0 1 pwm clock = fcpu/2 1 0 pwm clock = fcpu/4 1 1 pwm clock = fcpu/16 3~2 t3div.1~ 0 timer 3 clock select: t3div.1 t3div.0 0 0 timer 3 clock = fcpu/4 0 1 timer 3 clock = fcpu/16 1 0 timer 3 clock = fcpu/32 preliminary N79E875 data s heet - 22 - 1 1 timer 3 clock = fcpu/128 1~0 t0d iv.1~ 0 timer 2 clock select: t0div.1 t0div.0 0 0 timer 0 clock = fcpu/4 0 1 timer 0 clock = fcpu/16 1 0 timer 0 clock = fcpu/32 1 1 timer 0 clock = fcpu/128 power control initial= 00xx 0 000b bit: 7 6 5 4 3 2 1 0 smod smod0 bof por gf1 gf0 pd idl mnemonic: pcon address: 87h bit name function 7 smod 1: this bit doubles the serial port baud rate in mode 1, 2, and 3. 6 smod0 0: framing error detection disable. scon.7 (sm0/fe) bit is used as sm0 (standard 8052 function). 1: framing error detection e nable. scon.7 (sm0/fe) bit is used to reflect as frame error (fe) status flag. 5 bof 0: cleared by software. 1: set automatically when a brownout reset or interrupt has occurred. also set at power on. 4 por 0: cleared by software. 1: set automatically wh en a power - on reset has occurred. 3 gf1 general purpose user flags. 2 gf0 general purpose user flags. 1 pd 1: the cpu goes into the power down mode. in this mode, all the clocks are stopped and program execution is frozen. 0 idl 1: the cpu goes into th e idle mode. in this mode, the clocks cpu clock stopped, so program execution is frozen. but the clock to the serial, timer and interrupt blocks is not stopped, and these blocks continue operating. timer control initial= 0000 0 000b 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 preliminary N79E875 data s heet publication release date: april 13, 2009 - 23 - revision a02 automatically when the program does a timer 1 interrupt service routine. software can also s et 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 int errupt 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 edg e/ 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 trig gered. 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. timer mode control initial= 0000 0 000b 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/counter 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 control bit is set. 6 t c/ timer or counter select: when clear, timer 1 is incremented by the internal clock. when set, the timer counts fal ling 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/counter 0 is enabled only while the int0 pin is high and the t r0 control bit is set. when cleared, the int0 pin has no effect, and timer 0 is enabled whenever tr0 control bit is set. preliminary N79E875 data s heet - 24 - 2 t c/ timer or counter select: when clear, timer 0 is incremented by the internal clock. when set, the t imer 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 controlled by the standard timer0 control bits. th0 is an 8 - bit timer only controlled by timer1 control bit s. (timer 1) timer/counter 1 is stopped. timer 0 lsb initial= 0000 0 000b 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 bit name function 7 - 0 tl0.[7:0] timer 0 lsb. timer 1 lsb initial= 0000 0 000b 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 bit name function 7 - 0 tl1.[7:0] timer 1 lsb. timer 0 msb initial= 0000 0 000b 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 bit name function 7 - 0 th0.[7:0] timer 0 msb. timer 1 msb initial= 0000 0 000b preliminary N79E875 data s heet publication release date: april 13, 2009 - 25 - revision a02 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 bit name function 7 - 0 th1.[7:0] timer 1 msb. clock control initial=xxx 0 0xxxb bit: 7 6 5 4 3 2 1 0 - - - t1m t0m - - - mnemonic: ckcon address: 8eh bit name function 7 - 5 - reserved. 4 t1m timer 1 clock select: 0: timer 1 uses a divide by 12 clocks. 1: timer 1 uses a divide by 4clocks. 3 t0m timer 0 clock select: 0: timer 0 uses a divide by 12 clocks. 1: timer 0 uses a divide by 4 clocks. 4/16/32/128 clocks. the divider selection bits are located in sfr div.t0div[1:0]. 2~0 - reserved. port 1 initial=1111_1111b/0000_0000b 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 p1.7 - 0: general purpose input/output port. most instructions will read the port pins in case of a port read access, however in case of read - modify - write instructions, the port latch is read. if conf ig0.prhi=1, the initial value is ffh at reset. if config0.prhi=0, the initial value is 00h at reset. these alternate functions are described below . bit name function 7 p1.7 bkp1 or stadc or i/o pin by alternative. 6 p1.6 (1) int 0 interrupt or sda or i/o pin by alternative. 5 p1.5 (1) bkp0 or t0 or scl or input pin by alternative. 4 p1.4 rst pin or digital input pin by alternative. preliminary N79E875 data s heet - 26 - 3 p1.3 rxd or i/o pin by alternative. 2 p1.2 txd or i/o pin by alternative. 1 p1.1 xtal1 or i/o pin by alternative. 0 p1.0 xtal2 or clkout or i/o pin by alternative. note : (1) p1.5 and p1.6 are permanently in open - drain type. timer 3 lsb initial= 0000 0 000b bit: 7 6 5 4 3 2 1 0 t3.7 t3.6 t3.5 t3.4 t3.3 t3.2 t3.1 t3.0 mnemonic: t3l address: 91h bit name function 7 - 0 t3.[7:0] timer 3 lsb bits register. timer 3 reload/compare lsb initial= 0000 0 000b bit: 7 6 5 4 3 2 1 0 rcap3.7 rcap3.6 rcap3.5 rcap3.4 rcap3.3 rcap3.2 rcap3.1 rcap3.0 mnemonic: rcap3l address: 92h bit name function 7 - 0 rcap3l t imer 3 reload/compare lsb: this register is lsb of a 12 - bit reload value when timer 3 is configured in reload/compare mode. during compare mode, this register is a compare register. see sfr t3con for reload/compare mode. timer 3 reload/compare msb initia l= 0000 0 000b bit: 7 6 5 4 3 2 1 0 rcap3.1 1 rcap3.1 0 rcap3.9 rcap3.8 t3.11 t3.10 t3.9 t3.8 mnemonic: rcap3ht3h address: 93h bit name function 7 - 4 rcap3.11~8 timer 3 reload/compare msb: this register is msb of a 12 - bit reload value when timer 3 is confi gured in reload/compare mode. during compare mode, this register is a compare register. see sfr t3con for reload/compare mode. 3 - 0 t3.11~8 timer 3 msb bits register. pwm 4 low bits register initial= 0000 0 000b bit: 7 6 5 4 3 2 1 0 preliminary N79E875 data s heet publication release date: april 13, 2009 - 27 - revision a02 pwm4.7 pwm4.6 pwm4.5 pwm4.4 pwm4.3 pwm4.2 pwm4.1 pwm4.0 mnemonic: pwm4l address: 96h bit name function 7:0 pwm4 pwm 4 lsb bits register. pwm 4 high bits register initial=xxxx 0 000b bit: 7 6 5 4 3 2 1 0 - - - - pwm4.11 pwm4.10 pwm4.9 pwm4.8 mnemonic: pwm4h address: 97h bi t name function 7:4 - reserved. 3:0 pwm4 pwm 4 msb bits register. serial port control initial= 0000 0 000b 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 fr aming error flag: the smod0 bit in pcon sfr determines whether this bit acts as sm0 or as fe. the operation of sm0 is described below. when used as fe, this bit will be set to indicate an invalid stop bit. this bit must be manually cleared in software to c lear the fe condition. 6 sm1 serial port mode select bit 1. see table below. 5 sm2 multiple processors communication. setting this bit to 1 enables the multiprocessor communication feature in mode 2 and 3. in mode 2 or 3, if sm2 is set to 1, then ri will not be activated if the received 9th data bit (rb8) is 0. in mode 1, if sm2 = 1, then ri will not be activated if a valid stop bit was not received. in mode 0, the sm2 bit controls the serial port clock. if set to 0, then the serial port runs at a divide by 12 clock of the oscillator. this gives compatibility with the standard 8052. when set to 1, the serial clock become divide by 4 of the oscillator clock. this results in faster synchronous serial communication. 4 ren receive enable: 0: disable serial re ception. 1: enable serial reception. 3 tb8 this is the 9th bit to be transmitted in modes 2 and 3. this bit is set and cleared by software as desired. 2 rb8 in modes 2 and 3 this is the received 9th data bit. in mode 1, if sm2 = 0, rb8 is the stop bit th at was received. in mode 0 it has no function. preliminary N79E875 data s heet - 28 - 1 ti transmit interrupt flag: this flag is set by hardware at the end of the 8th bit time in mode 0, or at the beginning of the stop bit in all other modes during serial transmission. this bit must be cleared by software. 0 ri receive interrupt flag: this flag is set by hardware at the end of the 8th bit time in mode 0, or halfway through the stop bits time in the other modes during serial reception. however the restrictions of sm2 apply to this bit. this bit can be cleared only by software. sm1, sm0: mode select bits: mode sm0 sm1 description length baud rate 0 0 0 synchronous 8 tclk divided by 4 or 12 1 0 1 asynchronous 10 variable 2 1 0 asynchronous 11 tclk divided by 32 or 64 3 1 1 asynchronous 11 var iable serial data buffer initial=xxxx xxxxb 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.[7:0 ] serial data on the serial port is read from or written to this locati on. it actually consists of two separate internal 8 - bit registers. one is the receive resister, 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. interrupt prio rity 2 initial=x 0 xx 0 xx0b bit: 7 6 5 4 3 2 1 0 - pt2 - - pspi - - pet3 mnemonic: ip2 address: 9ah bit name function 7 - reserved. 6 pt2 1: to set interrupt priority of timer 2 is higher priority level. 5 - 4 - reserved. 3 pspi 1: to set interrupt prio rity of spi is higher priority level. 2~1 - reserved. 0 pet3 1: to set interrupt priority of timer 3 is higher priority level. preliminary N79E875 data s heet publication release date: april 13, 2009 - 29 - revision a02 pwm io register initial= 0000 0 000b bit: 7 6 5 4 3 2 1 0 pio7 pio6 pio5 pio4 pio3 pio2 pio1 pio0 mnemonic: pio address: 9bh bit name function 7~0 pion pwm or io function select bit: select pin output source from pwm or i/o register. 0: port pin output from port i/o bit register. 1: port pin output from pwm generator. (note: n = 0~7). adc compare reference low data/compare reg ister initial= 001 0 xx00b bit: 7 6 5 4 3 2 1 0 adcr.1 adcr.0 adcpo adcpi - - t3css enadcp mnemonic: adcrl address: 9ch bit name function 7 - 6 adcr.1 - 0 the 2 msb bits of adc compare reference data. note: these 2 bits are writable only when they are writte n with enadcp = 0. 5 adcpo adc compare output (read only). 0: the conversion result is less than reference value. 1: the conversion result is equal or larger than reference value. 4 adcpi adc compare change flag if the adc compare output status is change d, this bit will be set by hardware. this flag is cleared by software only. 3 - 2 - reserved. 1 t3css timer 3 external trigger source: 0: t3ex pin is the timer 3 trigger source. 1: adc compare result, adcpo, is timer 3 trigger source. 0 enadcp adc compare function enable bit: 0: disable adc compare function. 1: enable adc compare function. adc compare reference high data register initial=xxxx xxxxb bit: 7 6 5 4 3 2 1 0 adcr.9 adcr.8 adcr.7 adcr.6 adcr.5 adcr.4 adcr.3 adcr.2 mnemonic: adcrh address: 9dh preliminary N79E875 data s heet - 30 - bit name function 7 - 0 adcr.9 - 2 the 8 msb bits of adc compare reference data. note: these bits are writable only when adc compare function is disabled (enadcp=0) port 3 output mode 1 initial= 0000 0 000b bit: 7 6 5 4 3 2 1 0 p3m1.7 p3m1.6 p3m1.5 p3m1.4 p 3m1.3 p3m1.2 p3m1.1 p3m1.0 mnemonic: p3m1 address: 9eh bit name function 7 - 0 p3m1 to control the output configuration of p3 [7:0]. port 3 output mode 2 initial= 0000 0 000b bit: 7 6 5 4 3 2 1 0 p3m2.7 p3m2.6 p3m2.5 p3m2.4 p3m2.3 p3m1.2 p3m2.1 p3m2.0 mn emonic: p3m2 address: 9fh bit name function 7 - 0 p3m2 see as below table. port output configuration settings: pxm1.y pxm2.y port input/output mo de 0 0 quasi - bidirectional 0 1 push - pull 1 0 input only (high impedance) ports.pxs=0, ttl input ports.pxs=1 , schmitt input 1 1 open drain note: x = 0 - 4. y = 0 - 7 (for port0 - 3), y = 0 - 3 (for port4). port 2 initial=1111 111b/ 0000 0 000b 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 p2.7 - 0: general purpose input/output p ort. most instructions will read the port pins in case of a port read access, however in case of read - modify - write instructions, the port latch is read. if config0.prhi=1, the initial value is ffh at reset. if config0.prhi=0, the initial value is 00h at re set. preliminary N79E875 data s heet publication release date: april 13, 2009 - 31 - revision a02 these alternate functions are described below . bit name function 7 p2.7 t1 or i/o pin by alternative. 6 p2.6 ic2 or mosi or i/o pin by alternative. 5 p2.5 ic1 or miso or i/o pin by alternative. 4 p2.4 ic0 or ss pin or i/o pin by alt ernative. 3 p2.3 t3 or sclk or i/o pin by alternative. 2 p2.2 pwm4 or i/o pin by alternative. 1 p2.1 pwm2 or cp1o or i/o pin by alternative. 0 p2.0 pwm0 or cp2o or i/o pin by alternative. keyboard interrupt initial= 0000 0 000b bit: 7 6 5 4 3 2 1 0 kbi.7 kbi.6 kbi.5 kbi.4 kbi.3 kbi.2 kbi.1 kbi.0 mnemonic: kbi address: a1h bit name function 7 kbi.7 1: enable p0.7 as a cause of a keyboard interrupt. 6 kbi.6 1: enable p0.6 as a cause of a keyboard interrupt. 5 kbi.5 1: enable p0.5 as a cause of a keyb oard interrupt. 4 kbi.4 1: enable p0.4 as a cause of a keyboard interrupt. 3 kbi.3 1: enable p0.3 as a cause of a keyboard interrupt. 2 kbi.2 1: enable p0.2 as a cause of a keyboard interrupt. 1 kbi.1 1: enable p0.1 as a cause of a keyboard interrupt. 0 kbi.0 1: enable p0.0 as a cause of a keyboard interrupt. aux function register 1 initial= 0000 0 000b bit: 7 6 5 4 3 2 1 0 kbf bod boi lpbod srst adcen rcclk bos mnemonic: auxr1 address: a2h bit name function preliminary N79E875 data s heet - 32 - 7 kbf keyboard interrupt flag: 1: when an y pin of port 0 that is enabled for the keyboard interrupt function goes low. must be cleared by software. 6 bod brown out disable: 0: enable brownout detect function. 1: disable brownout detect function and save power. 5 boi brown out interrupt: 0: brow nout detection will cause chip brownout reset. 1: this prevents brownout detection from causing a chip reset and allows the brownout detect function to be used as an interrupt. 4 lpbod low power brown out detect control: 0: if bit bod=0, the brown out det ection is always active. 1: if bit bod=0, the brown out detection repeats to senses the voltage for 64/f brc then turn off detector for 960/fbrc, therefore, it saves 15/16 of the brownout circuit power. 3 srst software reset: 1: reset the chip as if a hard ware reset occurred. (user must specially take care of setting srst when a write access on auxr1) 2 adcen 0: disable adc circuit. 1: enable adc circuit. 1 rcclk 0: the cpu clock is used as adc clock source. 1: the internal rc 22.1184mhz/11.0592mhz (selec table by config1.fs1 bit) clock is used as adc clock source. note: this bit can only be set/cleared when adcen=0. the adc clock source will goes through pre - scalar of /1, /2, /4 or /8, selectable by adclk bits (sfr adccon1.6 - 7). 0 bos brownout status bit (read only) 0: v dd is above v bor+ 1: v dd is below v bor- capture control 0 register initial= 0000 0 000b bit: 7 6 5 4 3 2 1 0 cct2 cct1 cct0 ccld mnemonic: capcon0 address: a3h bit name function 7~6 cct2.1~0 capture 2 edge select: 00 : rising edge trigge r. 01 : falling edge trigger. 10 : both rising and falling edge trigger. preliminary N79E875 data s heet publication release date: april 13, 2009 - 33 - revision a02 11 : reserved. 5~4 cct1.1~0 capture 1 edge select: 00 : rising edge trigger. 01 : falling edge trigger. 10 : both rising and falling edge trigger. 11 : reserved. 3~2 cct0.1~0 captur e 0 edge select: 00 : rising edge trigger. 01 : falling edge trigger. 10 : both rising and falling edge trigger. 11 : reserved 1~0 ccld.1~0 reload trigger select: 00 : timer 2 overflow. 01 : reload by capture 0 block. 10 : reload by capture 1 block. 11 : reload by capture 2 block. capture control 1 register initial=x 000 0 000b bit: 7 6 5 4 3 2 1 0 - ic0ss enf2 enf1 enf0 cptf2 cptf1 cptf0 mnemonic: capcon1 address: a4h bit name function 7 - reserved. 6 ic0ss input capture 0 source select: 0 : p2.4 pin a s input capture 0 trigger source. 1 : adc compare result, adcpo, as input capture 0 trigger source. 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 external capture/r eload 2 interrupt flag. 1 cptf1 external capture/reload 1 interrupt flag. 0 cptf0 external/adcpo capture/reload 0 interrupt flag. preliminary N79E875 data s heet - 34 - port 4 initial=xxxx 1111b/xxxx 0 000b bit: 7 6 5 4 3 2 1 0 - - - - p4.3 p4.2 p4.1 p4.0 mnemonic: p4 address: a5h p4.3 - 0: general purpose input/output port. most instructions will read the port pins in case of a port read access, however in case of read - modify - write instructions, the port latch is read. if config0.prhi=1, the initial value is xxxx_1111b at reset. if config0.p rhi=0, the initial value is xxxx_0000b at reset. these alternate functions are described below . bit name function 7 - 4 - reserved. 3 p4.3 dedicated i/o pin. 2 p4.2 dedicated i/o pin. 1 p4.1 cp2pb or i/o pin by alternative. 0 p4.0 cp2nb or i/o pin by a lternative. input capture 2 low register initial=0 000 0 000b bit: 7 6 5 4 3 2 1 0 ccl2.7 ccl2.6 ccl2.5 ccl2.4 ccl2.3 ccl2.2 ccl2.1 ccl2.0 mnemonic: ccl2 address: a6h bit name function 7~0 ccl2.7~0 capture 2 lsb bits . input capture 2 high register init ial=0 000 0 000b bit: 7 6 5 4 3 2 1 0 cch2.7 cch2.6 cch2.5 cch2.4 cch2.3 cch2.2 cch2.1 cch2.0 mnemonic: cch2 address: a7h bit name function 7~0 cch2.7~0 capture 2 msb bits . interrupt enable initial=0 000 0 000b bit: 7 6 5 4 3 2 1 0 ea eadc ebo es et1 ex 1 et0 ex0 mnemonic: ie address: a8h bit name function preliminary N79E875 data s heet publication release date: april 13, 2009 - 35 - revision a02 7 ea global enable. enable/disable all interrupts. 6 eadc enable adc interrupt. 5 ebo enable brown out interrupt. 4 es enable serial port 0 interrupt. 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 initial=0 000 0 000b 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 fun ction 7~0 saddr the saddr should be programmed to the given or broadcast address for serial port 0 to which the slave processor is designated. pwm dead - time connter register initial=0 000 0 000b bit: 7 6 5 4 3 2 1 0 dtcnt.7 dtcnt.6 dtcnt.5 dtcnt.4 dtcnt. 3 dtcnt.2 dtcnt.1 dtcnt.0 mnemonic: dtcnt address: abh bit name function 7~0 dtcnt.7~ 0 dead - time counter. unsigned 8 - bit dead time value bits for dead time unit. dead - time = f cpu * (dtcnt. [7:0] +1) note : this sfr is ta protected. comparator 1 control reg ister initial=x 00 x 0 000b bit: 7 6 5 4 3 2 1 0 - hysen1 cmpen1 - cn1 coe1 co1 cmf1 mnemonic: cmp1 address: ach bit name function 7 - reserved. preliminary N79E875 data s heet - 36 - 6 hysen1 hysterisis function enable (comparator 1): 0: without hysterisis at comparator 1 inputs. (default). 1: enable hysterisis function at comparator 1 that the typical range is about 20mv. 5 cmpen1 comparator enable: 0: disable comparator. 1: enabled comparator. comparator output need wait stable 10 us after cmpen1 is first set. 4 - reserved. 3 cn1 compara tor negative input select: 0: the comparator reference pin cng1 is selected as the negative comparator input. 1: the internal comparator reference vref is selected as the negative comparator input. 2 coe1 output enable: 1: the comparator output is connec ted to the cmp1 pin if the comparator is enabled (cmpen1 = 1). this output is asynchronous to the cpu clock. 1 co1 comparator output: synchronized to the cpu clock to allow reading by software. cleared when the comparator is disabled (cmpen1 = 0). 0 cmf1 comparator interrupt flag: this bit is set by hardware whenever the comparator output changes state. this bit will cause a hardware interrupt if enabled and of sufficient priority. cleared by software and when the comparator is disabled (cmpen1 = 0). com parator 2 control register initial=x 000 0 000b bit: 7 6 5 4 3 2 1 0 - hysen2 cmpen2 cp2 cn2 coe2 co2 cmf2 mnemonic: cmp2 address: adh bit name function 7 - reserved. 6 hysen2 hysterisis function enable (comparator 2): 0: without hysterisis at comparato r 2 inputs. (default). 1: enable hysterisis function at comparator 2 that the typical range is about 20mv. preliminary N79E875 data s heet publication release date: april 13, 2009 - 37 - revision a02 5 cmpen2 comparator enable: 0: disable comparator. 1: enabled comparator. comparator output need wait stable 10 us after cmpen2 is first set. 4 cp2 comparator 2 inputs select: 0: (cp2pa, cp2na) pair comparator 2 input pair is selected. 1: (cp2pb, cp2nb) pair comparator 2 input pair is selected. 3 cn2 comparator negative input select: 0: the comparator reference pin cng2 is selected as the negative c omparator input. 1: the internal comparator reference vref is selected as the negative comparator input. 2 coe2 output enable: 1: the comparator output is connected to the cmp2 pin if the comparator is enabled (cmpen2 = 1). this output is asynchronous t o the cpu clock. 1 co2 comparator output: synchronized to the cpu clock to allow reading by software. cleared when the comparator is disabled (cmpen2 = 0). 0 cmf2 comparator interrupt flag: this bit is set by hardware whenever the comparator output chan ges state. this bit will cause a hardware interrupt if enabled and of sufficient priority. cleared by software and when the comparator is disabled (cmpen2 = 0). pwm dead - time control 0 register initial=xxxx x000b bit: 7 6 5 4 3 2 1 0 - - - - - dtenb4 dt enb2 dtenb0 mnemonic: pdtc0 address: aeh bit name function 7 - 3 - reserved. 2 dtenb4 enable dead - time insertion for pwm pair (pwm4, pwm5): dead - time insertion is only active when this pair of complementary pwm is enabled. if dead - time insertion is inacti ve, the outputs of pin pair are complementary without any delay. 0 : disable dead - time insertion on the pin pair (pwm4, pwm5). 1: enable dead - time insertion on the pin pair (pwm4, pwm5). preliminary N79E875 data s heet - 38 - 1 dtenb2 enable dead - time insertion for pwm pair (pwm2, pwm3): dead - t ime insertion is only active when this pair of complementary pwm is enabled. if dead - time insertion is inactive, the outputs of pin pair are complementary without any delay. 0 : disable dead - time insertion on the pin pair (pwm2, pwm3). 1 : enable dead - time i nsertion on the pin pair (pwm2, pwm3). 0 dtenb0 enable dead - time insertion for pwm pair (pwm0, pwm1): dead - time insertion is only active when this pair of complementary pwm is enabled. if dead - time insertion is inactive, the outputs of pin pair are comple mentary without any delay. 0 : disable dead - time insertion on the pin pair (pwm0, pwm1). 1 : enable dead - time insertion on the pin pair (pwm0, pwm1). note : this sfr is ta protected. adc delay start register initial=0 000 0 000b bit: 7 6 5 4 3 2 1 0 adcdly .7 adcdly .6 adcdly .5 adcdly .4 adcdly .3 adcdly .2 adcdly .1 adcdly .0 mnemonic: adcdly address: afh bit name function 7~0 adcdly these are 8 bits start register to delay start of adc conversion after detection of adc start conversion edge by pwm trigger source (controllable through sfr adccon1.pwmsrc.1~0) and trigger type (controllable through sfr adccon1.stadct.1~0). an internal 8 bits delay counter will run on pwm clock. when the internal counter matches adcdly value, adc will start conversion. pmu trigger d elay time = (adcdly+1)/(fcpu/(4*divider)). divider is defined in sfr adccon1.3. note: user required to clear adcen (adcen = 0) when re - configure this sfr. port 3 initial=1111 1111b/0 000 0 000b 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 p3.7 - 0: general purpose input/output port. most instructions will read the port pins in case of a port read access, however in case of read - modify - write instructions, the port latch is read. if config0.prhi=1, the initial value i s 1111_1111b at reset. if config0.prhi=0, the initial value is 0000_0000b at reset. these alternate functions are described below . bit name function preliminary N79E875 data s heet publication release date: april 13, 2009 - 39 - revision a02 7 p3.7 opn or i/o pin by alternative. 6 p3.6 opp or i/o pin by alternative. 5 p3.5 dedicated i/o pin. 4 p3.4 dedicated i/o pin. 3 p3.3 pwm7 or i/o pin by alternative. 2 p3.2 pwm5 or i/o pin by alternative. 1 p3.1 pwm3 or i/o pin by alternative. 0 p3.0 pwm1 or i/o pin by alternative. port 0 output mode 1 initial=0 000 0 000b bit: 7 6 5 4 3 2 1 0 p0m1.7 p0m1.6 p0m1.5 p0m1.4 p0m1.3 p0m1.2 p0m1.1 p0m1.0 mnemonic: p0m1 address: b1h bi t name function 7 - 0 p0m1 to control the output configuration of p0 bits [7:0] port 0 output mode 2 initial=0 000 0 000b bit: 7 6 5 4 3 2 1 0 p0m2.7 p0m2.6 p0m2.5 p0m2.4 p0m 2.3 p0m2.2 p0m2.1 p0m2.0 mnemonic: p0m2 address: b2h bi t name function 7 - 0 p0m2 to control the output configuration of p0 bits [7:0] port 1 output mode 1 initial=0xxx 0 000b bit: 7 6 5 4 3 2 1 0 p1m1.7 - - - p1m1.3 p1m1.2 p1m1.1 p1m1.0 mnemonic: p1m 1 address: b3h bi t name function 7 p1m1.7 to control the output configuration of p1 bit [7]. 6 - 4 - reserved. 3 - 0 p1m1.3 - 0 to control the output configuration of p1 bits [3:0]. port 1 output mode 2 initial=0xxx 0 000b preliminary N79E875 data s heet - 40 - bit: 7 6 5 4 3 2 1 0 p1m2.7 - - - p1m2.3 p1m2.2 p1m2.1 p1m2.0 mnemonic: p1m2 address: b4h bi t name function 7 p1m2 to control the output configuration of p1 bits [7]. 6 - 4 - reserved. 3 - 0 p1m2.3 - 0 to control the output configuration of p1 bits [3:0]. port 2 output mode 1 initial=0 000 0 000b bit: 7 6 5 4 3 2 1 0 p2m1.7 p2m1.6 p2m1.5 p2m1.4 p2m1.3 p2m1.2 p2m1.1 p2m1.0 mnemonic: p2m1 address: b5h bi t name function 7 - 0 p2m1 to control the output configuration of p2 bits [7:0] port 2 output mode 2 initial=0 000 0 000b bit: 7 6 5 4 3 2 1 0 p2m2.7 p2m2.6 p2m2.5 p2m2.4 p2m2.3 p2m2.2 p2m2.1 p2m2.0 mnemonic: p2m2 address: b6h bi t name function 7 - 0 p2m2 to control the output configuration of p2 bits [7:0] interrupt high priority initial=x 000 0 000b bit: 7 6 5 4 3 2 1 0 - padch pboh psh pt1h px1h pt0h px0h mnemonic: ip0h address: b7h bit name function 7 - reserved 6 padch 1: to set interrupt high priority of adc is highest priority level. 5 pboh 1: to set interrupt high priority of brown out detector is highest priority level. 4 psh 1: t o set interrupt high priority of serial port 0 is highest priority level. 3 pt1h 1: ro set interrupt high priority of timer 1 is highest priority level. preliminary N79E875 data s heet publication release date: april 13, 2009 - 41 - revision a02 2 px1h 1: to set interrupt high priority of external interrupt 1 is highest priority level. 1 pt0h 1 : to set interrupt high priority of timer 0 is highest priority level. 0 px0h 1: to set interrupt high priority of external interrupt 0 is highest priority level. interrupt priority 0 initial=x 000 0 000b bit: 7 6 5 4 3 2 1 0 - padc pbo ps pt1 px1 pt0 px 0 mnemonic: ip0 address: b8h bit name function 7 - reserved 6 padc 1: to set interrupt priority of adc is higher priority level. 5 pbo 1: to set interrupt priority of brown out detector is higher priority level. 4 ps 1: to set interrupt priority of se rial port 0 is higher priority level. 3 pt1 1: to set interrupt priority of timer 1 is higher priority level. 2 px1 1: to set interrupt priority of external interrupt 1 is higher priority level. 1 pt0 1: to set interrupt priority of timer 0 is higher pr iority level. 0 px0 1: to set interrupt priority of external interrupt 0 is higher priority level. slave address mask enable initial=0 000 0 000b bit: 7 6 5 4 3 2 1 0 saden.7 saden.6 saden.5 saden.4 saden.3 saden.2 saden.1 saden.0 mnemonic: sade n address: b9h bit name function 7~0 saden this register enables the automatic address 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 data. when saden i s 0, then the bit becomes a "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. i2c data register initial=xxxx xxxxb bit: 7 6 5 4 3 2 1 0 i2dat.7 i2dat.6 i2dat.5 i2dat.4 i2dat.3 i2dat.2 i2dat.1 i2dat.0 mnemonic: i2dat address: bch bi name function preliminary N79E875 data s heet - 42 - t 7 - 0 i2dat.[7:0 ] the data register of i2c. i2c status register initial= 1111 1 000b bit: 7 6 5 4 3 2 1 0 b it7 bit 6 b it5 b it4 b it3 b it2 b it1 b it0 mnemonic: i2status address: bdh bi t name function 7 - 0 i2status.[7:0 ] the status register of i2c: the three least significant bits are always 0. the five most significant bits contain the status code. there are 26 possible status codes. when i2status contains f8h, no serial interrupt is requested. all other i2status values correspond to defined i2c states. when each of these states is entered, a status interrupt is requested (si = 1). a valid status code is present in i2stat us one machine cycle after si is set by hardware and is still present one machine cycle after si has been reset by software. in addition, states 00h stands for a bus error. a bus error occurs when a start or stop condition is present at an illegal position in the formation frame. example of illegal position are during the serial transfer of an address byte, a data byte or an acknowledge bit. i2c baud rate control register initial=0 000 0 000b bit: 7 6 5 4 3 2 1 0 i2clk.7 i2clk.6 i2clk.5 i2clk.4 i2clk.3 i2c lk.2 i2clk.1 i2clk.0 mnemonic: i2clk address: beh bi t name function 7 - 0 i2clk.[7:0 ] the i2c clock rate bits. i2c timer - out counter register initial=xxxx x000b bit: 7 6 5 4 3 2 1 0 - - - - - enti div4 tif mnemonic: i2toc address: bfh bi t name function 7~3 - reserved. 2 enti enable i2c 14 - bits timer counter: 0: disable 14 - bits timer counter count. 1: enable 14 - bits timer counter count. after enable enti and ensi, the 14 - bit preliminary N79E875 data s heet publication release date: april 13, 2009 - 43 - revision a02 counter will be counted. when si flag of i2c is set, the counter will stop to count and 14 - bits timer counter will be cleared. 1 div4 i2c timer counter clock source divide function: 0: the 14 - bits timer counter source clock is fcpu clock. 1: the 14 - bits timer counter source clock is divided by 4. 0 tif the i2c timer counter count flag: 0: the 14 - bits timer counter is not overflow. 1: the 14 - bits timer counter is overflow and i2c interrupt is requested if the i2c interrupt is enabled. before enable i2c timer (enti, ensi = [1,1]) the si must be cleared. this bit is cleared by softwar e. i2c control register initial=x 000 0 0xxb bit: 7 6 5 4 3 2 1 0 - ensi sta sto si aa - - mnemonic: i2con address: c0h bi t nam e function 7 - reserved. 6 ens i 0: disable i2c serial function. the sda and scl output are in a high impedance state. sda and scl input signals are ignored, i2c is not in the addressed slave mode or it is not addressable, and sto bit in i2con is forced to ?0?. no other bits are affected. note that p1.5 (scl) and p1.6 (sda) are open drain i/o ports. 1: enable i2c serial function. the p1.2 and p1.3 port latches must be to logic 1. 5 sta the start flag. 0: the sta bit is reset, no start condition or repeated start condition will be generated. 1: the sta bit is set to enter a master mode. the i2c hardware checks the status of i2c bu s and generates a start condition if the bus is free. if bus is not free, then i2c waits for a stop condition and generates a start condition after a delay. if sta is set while i2c is already in a master mode and one or more bytes are transmitted or receiv ed, i2c transmits a repeated start condition. sta may be set any time. sta may also be set when i2c interface is an addressed slave mode. 4 sto in master mode, setting sto to transmit a stop condition to bus then i2c hardware will check the bus condition if a stop condition is detected this flag will be cleared by hardware automatically. in a slave mode, setting sto resets i2c hardware to the defined ? not addressed ? slave mode. this means it is no longer in the slave receiver mode to receive data from th e master transmit device. when i2c is in master mode and if the sta and sto bits are both set, a stop and a start condition will be transmitted to the i2c bus when i2c is in slave mode and if the sta and sto bits are both set, i2c generates an internal sto p condition which is not transmitted to the i2c bus. preliminary N79E875 data s heet - 44 - 3 si i2c serial port interrupt flag 0: when the si flag is reset, no serial interrupt is requested, and there is no stretching on the serial clock on the scl line. 1: when a new sio state is present in the i2status register, the si flag is set by hardware, and, if the ea and ei2c ( eie1.0 ) bits are both set, a n i2c interrupt is requested when si is set. only one state that does not cause si is set is i2status= f8h, which indicates that no relevant state inf ormation is available. when si is set, the low level cycle of the serial clock on the scl line is stretched, and the serial transfer is suspended. the high level cycle on the scl line is unaffected by the serial interrupt flag. si must be cleared by softwa re. 2 aa the assert acknowledge flag 0: a not acknowledge (high level to sda) will be returned during the acknowledge clock pulse on scl when: 1) a data has been received while sio is in the master receiver mode. 2) a data byte has been received while sio is in the addressed slave receiver mode. 1: an acknowledge (low level to sda) will be returned during the acknowledge clock pulse on the scl line when: 1) the own slave address has been received. 2) a data byte has been received while sio is in the master receiver mode. 3) a data byte has been received while sio is in the addressed slave receiver mode. 4) the general call address has been received while the general call bit (gc) in i2addr is set. 1~0 - reserved. preliminary N79E875 data s heet publication release date: april 13, 2009 - 45 - revision a02 i2c address register initial=xxxx xxx0b b it: 7 6 5 4 3 2 1 0 i2addr.7 i2addr.6 i2addr.5 i2addr.4 i2addr.3 i2addr.2 i2addr.1 gc mnemonic: i2addr address: c1h bit name function 7~1 i2addr.[7:1] i2c address register: the content of this register is irrelevant when i2c is in master mode. in the s lave mode, the seven most significant bits must be loaded with the mcu?s own address. the i2c hardware will react if either of the address is matched. 0 gc general call function. 0: disable general call function. 1: enable general call function. timer 3 control register initial=0 000 0 000b bit: 7 6 5 4 3 2 1 0 tf3 exf3 t3cnte t3oe t3rst tr3 t3mod. 1 t3mod. 0 mnemonic: t3con address: c2h bi t name function 7 tf3 timer 3 overflow interrupt flag: this bit is set when timer 3 overflows. it is cleared only by software. software can also set this bit. 6 exf3 timer 3 capture and compare match interrupt flag: it is set when there is a capture event in capture mode or the count is equal to the capture register in compare mode. it is cleared only by software. soft ware can also set this bit. 5 t3cnte timer or counter select: when clear, timer 3 is incremented by the internal clock. when set, the timer counts falling edges on the t3 pin. 4 t3oe timer 3 output enable: 1: the t3 pin is toggled whenever timer 3 overf lows. the output frequency is therefore one half of the timer 3 overflow rate. 3 t3rst timer 3 capture/compare match reset: in the timer 3 capture/compare modes, this bit enables/disables hardware automatically reset timer 3 while the value in tl3 and th3 have been transferred into the capture register, or compare matched occur. 2 tr3 timer 3 run control: preliminary N79E875 data s heet - 46 - this bit enables/disables the operation of timer 3. halting this will preserve the current count in th3 and tl3. 1~0 t3mod.1~0 timer 3 mode selection b its: 00: timer mode 01: capture mode 10: auto - reload mode 11: compare mode pwm negative polarity initial=xx 00 0 000b bit: 7 6 5 4 3 2 1 0 - - pnp.5 pnp.4 pnp.3 pnp.2 pnp.1 pnp.0 mnemonic: pnp address: c3h bi t name function 7 - 6 - reserved. 5~0 pnp.n pw m negative polarity bit: the register bit control the initial state as well as polarity/active state of pwm output. 0 = pwmx output is active high (initial state = 0). 1 = pwmx output is active low (initial state = 1). nvm high byte address initial=xxxx x xx0b bit: 7 6 5 4 3 2 1 0 - - - - - - - nvmaddr.8 mnemonic: nvmaddrh address: c5h bi t name function 7 - 1 - reserved. 0 nvmaddr.[8] the nvm high address: the register indicates nvm data memory of high byte address on on - chip code memory space . nvm low byte address initial=0 000 0 000b bit: 7 6 5 4 3 2 1 0 nvmadd r.7 nvmadd r.6 nvmadd r.5 nvmadd r.4 nvmadd r.3 nvmadd r.2 nvmadd r.1 nvmadd r.0 mnemonic: nvmaddrl address: c6h bi t name function 7~0 nvmaddr.[7:0 the nvm low byte address: preliminary N79E875 data s heet publication release date: april 13, 2009 - 47 - revision a02 ] the register indicates nv m data memory of low byte address on on - chip code memory space. timed access initial=0 000 0 000b 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 bi t name function 7 - 0 ta.[7:0] the timed access register: the timed access register controls the access to protected bits. to access protected bits, the user must first write aah to the ta. this must be immediately followed by a write of 55h to ta. now a window is opened in the protected bits for three machine cycles, duri ng which the user can write to these bits. timer 2 control initial=0xxx x0x0 b bit: 7 6 5 4 3 2 1 0 tf2 - - - - tr2 - cmp/ rl2 mnemonic: t2con address: c8h bit name function 7 tf2 timer 2 overflow flag: this bit is set when timer 2 overflows. it is al so set when the count is equal to the capture register in compare mode. it is cleared only by software. software can also set this bit. 6~3 - reserved. 2 tr2 timer 2 run control: this bit enables/disables the operation of timer 2. halting this will prese rve the current count in th2, tl2. 1 - reserved. 0 cmp/ rl2 compare/reload select. this bit determines whether the compare or reload function will be used for timer 2. 0: auto reload will occur when timer 2 overflows. and reload will be from rcap register if enld = 1. 1: when timer 2 value matches rcap value, timer 2 will reset to 0. timer 2 mode control initial=0 000 0 0xxb bit: 7 6 5 4 3 2 1 0 enld icen2 icen1 icen0 t2cr cmpcr - - mnemonic: t2mod address: c9h preliminary N79E875 data s heet - 48 - bit name function 7 enld enable reload fro m rcap2 registers to timer 2 counters. 6 icen2 capture 2 external enable: this bit enables the capture/reload function on the t2 pin. an edge trigger (programmable by capcon0.cct2[1:0] bits) detected on the t2 pin will result in capture from free running timer 2 counters to input capture 2 registers, and reload from rcap2 registers to timer 2 counters if enld = 1 and cmp/rl2 = 0. 5 icen1 capture 1 external enable: this bit enables the capture/reload function on the t1 pin. an edge trigger (programmable by capcon0.cct1[1:0] bits) detected on the t1 pin will result in capture from free running timer 2 counters to input capture 1 registers, and reload from rcap2 registers to timer 2 counters if enld = 1 and cmp/rl2 = 0. 4 icen0 capture 0 external enable: thi s bit enables the capture/reload function on the t0 pin. an edge trigger (programmable by capcon0.cct0[1:0] bits) detected on the t0 pin will result in capture from free running timer 2 counters to input capture 0 registers, and reload from rcap2 registers to timer 2 counters if enld = 1 and cmp/rl2 = 0. 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 c mpcr compare counter reset: enable counter reset when a match occurs. 0: disable counter auto - reset in compare mode. 1: enable counter auto - reset in compare mode. 1~0 - reserved. timer 2 reload lsb initial=0 000 0 000b bit: 7 6 5 4 3 2 1 0 rcap2l. 7 rcap2 l. 6 rcap2l. 5 rcap2l. 4 rcap2l. 3 rcap2l. 2 rcap2l. 1 rcap2l. 0 mnemonic: rcap2l address: cah bi t name function 7 - 0 rcap2l timer 2 reload lsb: this register is lsb of a 16 - bit reload value when timer 2 is configured in reload mode. during compare mode, this r egister is a compare register. see cmp/rl2 for reload/compare mode. timer 2 reload msb initial=0 000 0 000b bit: 7 6 5 4 3 2 1 0 preliminary N79E875 data s heet publication release date: april 13, 2009 - 49 - revision a02 rcap2h .7 rcap2h .6 rcap2h .5 rcap2h .4 rcap2h .3 rcap2h .2 rcap2h .1 rcap2h .0 mnemonic: rcap2h address: cbh bi t name function 7 - 0 rcap2h timer 2 reload msb: this register is msb of a 16 - bit reload value when timer 2 is configured in reload mode. during compare mode, this register is a compare register. see cmp/rl2 for reload/compare mode. timer 2 lsb initial=0 000 0 000b 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 bi t name function 7 - 0 tl2 timer 2 lsb. timer 2 msb initial=0 000 0 000b 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 bi t name function 7 - 0 tl2 timer 2 lsb. nvm control initial=0 0 xx xxxxb bit: 7 6 5 4 3 2 1 0 eer ewr - - - - - - mnemonic: nvmcon address: ceh bi t name function 7 eer nvm page(n) erase bit: 0: without erase nvm page(n). 1: set this bit to erase page(n ) of nvm. the nvm has 8 pages and each page have 16 bytes data memory. initiate page selected by writing nvmaddrh and nvmaddl registers, which will automatically enable page area. when user set this bit, the page erase process will begin and program counte r will halt at this instruction. after the erase process is completed, program counter will continue executing next instruction. 6 ewr nvm data write bit: preliminary N79E875 data s heet - 50 - 0: without write nvm data. 1: set this bit to write nvm bytes and program counter will halt at this instruction. after write is finished, program counter will kept next instruction then executed. 5 - 0 - reserved nvm data initial=0 000 0 000b 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: nvmdata ad dress: cfh bi t name function 7~0 nvmdat.[7:0 ] the nvm data write register. the read nvm data is by movc instruction. program status word initial=0 000 0 000b bit: 7 6 5 4 3 2 1 0 cy ac f0 rs1 rs0 ov f1 p mnemonic: psw address: d0h bit name function 7 c y 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 from the high order nibble. 5 f0 user flag 0: the general purpose flag that can be set or cleared by the user. 4~ 3 rs1~rs 0 register bank select bits. 2 ov overflow flag: set when a carry was generated from the seventh bit but not from the 8th bit as a result of the previo us operation, or vice - versa. 1 f1 user flag 1: the general purpose flag that can be set or cleared by the user software. 0 p parity flag: set/cleared by hardware to indicate odd/even number of 1's in the accumulator. preliminary N79E875 data s heet publication release date: april 13, 2009 - 51 - revision a02 rs.1 - 0: register bank selection bits: rs1 rs0 register bank address 0 0 0 00- 07h 0 1 1 08- 0fh 1 0 2 10- 17h 1 1 3 18- 1fh pwm counter high bits register initial=xxxx 0 000b bit: 7 6 5 4 3 2 1 0 - - - - pwmp.11 pwmp.10 pwmp.9 pwmp.8 mnemonic: pwmph address: d1h bi t name function 7 - 4 - reserved. 3 - 0 pwmp.[11:8 ] the pwm counter register bits 11~8. pwm 0 high bits register initial=xxxx 0 000b 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~ 8 the pwm 0 register bit 11~8. extended interrupt enable 2 register initial=x0xx 0 x00b bit: 7 6 5 4 3 2 1 0 - et2 - - espi - eadcp et3 mnemonic: eie2 address: d4h bit name function 7 - reserved. 6 et2 timer 2 interrupt enable: 0: disable timer 2 interrupt. 1: enable timer 2 interrupt. preliminary N79E875 data s heet - 52 - 5 - 4 - reserved. 3 espi spi interrupt enable: 0: disable spi interrupt. 1: enable spi interrupt. 2 - reserved. 1 eadcp enable adc compare interrupt. 0: disable adc compare interrupt source. 1: enable adc compare interrupt s ource. 0 et3 timer 3 interrupt enable: 0: disable timer 3 interrupt. 1: enable timer 3 interrupt. pwm 2 high bits register initial=xxxx xx00b bit: 7 6 5 4 3 2 1 0 - - - - - - pwm2.9 pwm2.8 mnemonic: pwm2h address: d5h bit name function 7~2 - reserved . 1~0 pwm2.9~8 the pwm2 register bit 9~8. pwm control register 3 initial=xx 00 xx00b bit: 7 6 5 4 3 2 1 0 hz_even hz_odd grp pwmtyp e - - p6ctrl int_typ e mnemonic: pwmcon3 address: d7h bit name function 7 hz_even control the even pwm ports driving mode : 0: the driving mode of even pwm pins is controlled by output mode registers (pxmy). 1: the driving mode of even pwm pins is forced in hi - z mode all the time. the initial value is loaded from config - bit pwm_even after any reset. 6 hz_odd control the odd pwm ports driving mode. 0: the driving mode of odd pwm pins is controlled by output mode registers (pxmy). 1: the driving mode of odd pwm pins is forced in hi - z mode all the time. the initial value is loaded from config - bit pwm_odd after any reset. preliminary N79E875 data s heet publication release date: april 13, 2009 - 53 - revision a02 5 grp group bit 1: unify the signals timing of pwm0, pwm2 and pwm4 in the same phase which is controlled by pwm0. 0: the signals timing of pwm0, pwm2 and pwm4 are independent. 4 pwmtype pwm mode select bit: 0: edge - aligned mode. 1: centre - aligned mode. 3~2 re served 1 p6ctrl pg6 output selection bit: 0: pwm6 output comes from pwm6 frequency/duty generator (if pio.6 = 1). 1: pwm6 output comes from pwm2 frequency/duty generator (if pio.6 = 1). 0 int_type pwm interrupt type select bit: 0: pwmf will be set if pw m counter underflow. 1: pwmf will be set if pwm counter overflow. note: this bit is effective when pwm in central align mode only. watchdog control initial= refer to the table below bit: 7 6 5 4 3 2 1 0 wdrun - wd1 wd0 wdif wtrf ewrst wdclr mnemonic: w dcon address: d8h bit name function 7 wdrun 0: the watchdog is stopped. 1: the watchdog is running. 6 - reserved. 5~4 wd1~wd0 watchdog timer time - out values selected. wd1 wd0 watchdog interval 0 0 2 12 0 1 2 16 1 0 2 18 1 1 2 20 3 wdif watchdog timer interrupt flag: 0: if the interrupt is not enabled, then this bit indicates that the time - out period has elapsed. this bit must be cleared by software. 1: if the watchdog interrupt is enabled, hardware will set this bit to indicate that the watchdog inter rupt has occurred. preliminary N79E875 data s heet - 54 - 2 wtrf watchdog timer reset flag: 1: hardware will set this bit when the watchdog timer causes a reset. software can read it but must clear it manually. a power - fail reset will also clear the bit. this bit helps software in determining the cause of a reset. if ewrst = 0, the watchdog timer will have no affect on this bit. 1 ewrst 0: disable watchdog timer reset. 1: enable watchdog timer reset. 0 wdclr reset watchdog timer: this bit helps in putting the watchdog timer into a know state. it also helps in resetting the watchdog timer before a time - out occurs. failing to set the ewrst before time - out will cause an interrupt (if ewdi (ie.4) is set), and 512 clocks after that a watchdog timer reset will be generated (if ewrst is set). this bi t is self - clearing by hardware. the wdcon sfr is set to a 0x000000b on a power - on- reset. wtrf (wdcon.2) is set to a 1 on a watchdog timer reset, but to a 0 on power on/down resets. wtrf (wdcon.2) is not altered by an external reset. ewrst (wdcon.1) is set to 0 on all resets. reset type by external reset by watchdog reset by power on reset value after the reset 0x00 0x00b 0x00 0100b 0x00 000b all the bits in this sfr have unrestricted read access. wdrun, wd0, wd1, ewrst, wdif and wdclr require timed acce ss procedure to write. the remaining bits have unrestricted write accesses. please refer ta register description. ta reg c7h wdcon reg d8h mov ta, #aah ; to access protected bits mov ta, #55h setb wdcon.0 ; reset watchdog timer orl wdcon, #001 10000b ; select 2 0 bits watchdog timer mov ta, #aah mov ta, #55h orl wdcon, #00000010b ; enable watchdog pwm counter low bits register initial=0000 0000b bit: 7 6 5 4 3 2 1 0 pwmp.7 pwmp.6 pwmp.5 pwp.4 pwmp.3 pwmp.2 pwmp.1 pwmp.1 mnemonic: pwmpl address: d9h bit name function 7~0 pwmp pwm counter low bits register. preliminary N79E875 data s heet publication release date: april 13, 2009 - 55 - revision a02 pwm 0 low bits register initial=0000 0000b bit: 7 6 5 4 3 2 1 0 pwm0.7 pwm0.6 pwm0.5 pwm0.4 pwm0.3 pwm0.2 pwm0.1 pwm0.1 mnemonic: pwm0l address: dah bit name function 7~0 pwm0 pwm 0 low bits register. pwm control register 1 initial=0000 0000b bit: 7 6 5 4 3 2 1 0 pwmrun load pwmf clrpwm fbk1 fbk0 pmod.1 pmod.0 mnemonic: pwmcon1 address: dch bit name function 7 pwmrun 0: the pwm is not running. 1: the pwm counter is running. 6 load 0: the registers value of pwmp and comparators are never loaded to counter and comparator registers. 1: the pwmp register will be load value to counter register after counter underflow, and hardware will clear by next clock cycle. 5 pwmf pwm underfl ow/match pwmp flag. 0: no underflow. 1: the flag is set depending on pwm edge or central align mode as follow; pwmcon3.int_typ e bit pwm counter edge align mode x match pwmp. central align mode 0 underflow 1 match pwmp. pwm interrupt is requested if pwm interrupt is enabled. 4 clrpwm 1: clear 12 - bit pwm counter to 000h. it is automatically cleared by hardware. 3 fbk1 the external brake bkp1 pin flag. 0: the pwm is not brake by bkp1 pin. 1: the pwm is brake by external brake bkp1 pin. it will be cle ared by software. 2 fbk0 the external brake bkp0 pin flag. 0: the pwm is not brake by bkp0 pin. 1: the pwm is brake by external brake bkp0 pin. it will be cleared by software. preliminary N79E875 data s heet - 56 - 1 - 0 pmod.1 - 0 pwm mode selection bits: 00: independent mode. 01: pair/complemen tary mode. 10: synchronized mode 11: reserved. pwm 2 low bits register initial=0000 0000b 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 pwm 2 low bits register. pw m brake output initial=xx00 0000b bit: 7 6 5 4 3 2 1 0 - - pwm5b pwm4b pwm3b pwm2b pwm1b pwm0b mnemonic: pwmb address: dfh bi t name function 7 - 6 - reserved. 5~0 pwmnb 0 = the pwmn output is low, when brake is asserted. 1 = the pwmn output is high, whe n brake is asserted. (note: n = 0~5). accumulator initial=0000 0000b 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 bi t name function 7 - 0 acc the a or acc register is the standard 8052 accumulator. adc control register initial=xx00 0000b bit: 7 6 5 4 3 2 1 0 adc.1 adc.0 adcex adci adcs addr2 aadr1 aadr0 mnemonic: adccon address: e1h bit name function preliminary N79E875 data s heet publication release date: april 13, 2009 - 57 - revision a02 7~6 adc.1~0 2 lsb bits of t he 10- bit adc conversion result. 5 adcex enable stadc and pwm - trigge red conversion: 0: conversion can only be started by software (i.e., by setting adcs). 1: conversion can be started by software or by a rising edge on stadc (pin p1.7) or rising/falling edge on pwm. note : pwm trigger will be enabled if adccon1.stadct.1 = 1 and adcex = 1. this product supports 4 pwm channels for adc start conversion triggers. user may also select the trigger type of rising or falling edge. user may also control the delay timing of pwm?s adc start trigger. see adc section for descriptions. 4 adci adc interrupt flag: this flag is set when the result of an a/d conversion is ready. this generates an adc interrupt, if it is enabled. while this flag is 1, the adc cannot start a new conversion. this bit will be cleared by software. 3 adcs adc st art and status: set this bit to start 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. if adc is not in continuous mode, it cannot start a new conversion while adcs or adci is hi gh. 2~0 aadr2~0 the adc input select. 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. addr2, aadr1, aadr0: adc analog input channel select bits: (note : these bits should only be changed when adci and adcs are both zero.) aadr2 aadr1 aad r0 selected analog channel 0 0 0 adc0 (p0.0) 0 0 1 adc1 (p0.1) 0 1 0 adc2 (p0.2) preliminary N79E875 data s heet - 58 - 0 1 1 adc3 (p0.3) 1 0 0 adc4 (p0.4) 1 0 1 adc5 (p0.5) 1 1 0 adc6 (p0.6) 1 1 1 adc7 (p0.7) adc converter result register initial=xxxx xxxxb 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 bits of t he 10- bit adc conversion result. adc control register 1 initial=0100 0000b bit: 7 6 5 4 3 2 1 0 adclk.1 adclk.0 stadct. 1 stadct. 0 dly div adccm pwmsrc .1 pwmsrc .0 mnemonic: adccon1 address: e3h bit name function 7~6 adclk.1~0 adc clock prescaler: the 10 - bit adc needs a clock to drive the converting and the clock frequency need to be within 200khz to 20 mhz. adclk[1:0] controls the freque ncy of the clock to adc block as below table; adclk.1 adclk.0 adc clock frequency 0 0 adcclk/1 0 1 adcclk/2 (default) 1 0 adcclk/4 1 1 adcclk/8 5~4 stadct.1~0 stadc trigger type selection bits: these bits select rising or falling edge for adc start trigger type. 00: triggered by p1.7 rising edge (default). 01: trigger by pwm rising edge. 10: trigger by pwm falling edge. 11: trigger by pwm centre - align (at centre point). 3 dlydiv adc delay clock divider select bit: 0: divider = 1. preliminary N79E875 data s heet publication release date: april 13, 2009 - 59 - revision a02 1: divider = 2. th e internal counter for pmu trigger delay is clocked by machine clock, fcpu/4. this bit is meant for dividing the machine clock (fcpu/4) clock source as per pmu trigger delay time equation below; pmu trigger delay time = (adcdly+1)/(fcpu/(4*dlydiv)). 2 a dccm adc continuous mode 0: disable adc continuous mode. 1: enable adc continuous mode. 1 - 0 pwmsrc.1~ 0 pwm source selection bits: these bits select pwm channel to cause adc start conversion. 00: pwm channel 0. 01: pwm channel 2. 10: pwm channel 4. 11: pwm channel 6. note: user required to clear adcen (adcen = 0) when re - configure this sfr. for pwm trigger adc start conversion in centre align mode, adc start conversion point will be at the same, regardless of which pwm channel is selected. input capture 0 low register initial=0000 0000b bit: 7 6 5 4 3 2 1 0 ccl0.7 ccl0.6 ccl0.5 ccl0.4 ccl0.3 ccl0.2 ccl0.1 ccl0.0 mnemonic: ccl0 address: e4h bit name function 7~0 ccl0 capture 0 low byte. input capture 0 high register initial=0000 0000b bit: 7 6 5 4 3 2 1 0 cch0.7 cch0.6 cch0.5 cch0.4 cch0.3 cch0.2 cch0.1 cch0.0 mnemonic: cch0 address: e5h bit name function 7~0 cch0 capture 0 high byte. input capture 1 low register initial=0000 0000b bit: 7 6 5 4 3 2 1 0 ccl1.7 ccl1.6 ccl1.5 ccl1.4 ccl1.3 ccl1.2 ccl1.1 ccl1.0 mnemonic: ccl1 address: e6h bit name function preliminary N79E875 data s heet - 60 - 7~0 ccl1 capture 1 low byte. input capture 1 high register initial=0000 0000b bit: 7 6 5 4 3 2 1 0 cch1.7 cch1.6 cch1.5 cch1.4 cch1.3 cch1.2 cch1.1 cch1.0 mnemonic: cch1 address: e7h bit nam e function 7~0 cch1 capture 1 high byte. interrupt enable register 1 initial=0000 x000b bit: 7 6 5 4 3 2 1 0 ecptf epwm ebrk ewdi - eci ekb ei2c mnemonic: eie 1 address: e8h bit name function 7 ecptf 0: disable capture interrupts. 1: enable capture i nterrupts. 6 epwm 0: disable pwm interrupt when pwm counter match/underflow. 1: enable pwm interrupt when pwm counter match/underflow. 5 ebrk 0: disable pwm brake interrupt. 1: enable pwm brake interrupt. 4 ewdi 0: disable watchdog timer interrupt. 1: e nable watchdog timer interrupt. 3 - reserved. 2 eci 0: disable comparator 1 and 2 interrupt. 1: enable comparator 1 and 2 interrupt. 1 ekb 0: disable keypad interrupt. 1: enable keypad interrupt. 0 ei2c 0: disable i2c interrupt. 1: enable i2c interrupt . ports shmitt register initial=xxx0 0000b bit: 7 6 5 4 3 2 1 0 - - - p4s p3s p2s p1s p0s preliminary N79E875 data s heet publication release date: april 13, 2009 - 61 - revision a02 mnemonic: ports address: ech bit name function 7~5 - reserved. 4 p4s 1: enables schmitt trigger inputs on port 4. 3 p3s 1: enables schmitt trigger inputs o n port 3. 2 p2s 1: enables schmitt trigger inputs on port 2. 1 p1s 1: enables schmitt trigger inputs on port 1. 0 p0s 1: enables schmitt trigger inputs on port 0. pwm mask enable register initial=xx00 0000b bit: 7 6 5 4 3 2 1 0 - - pme.5 pme.4 pme.3 pme.2 pme.1 pme.0 mnemonic: pme address: edh bit name function 7~6 - reserved. 5~0 pme.n pwm mask enable bit: the pwm generator signal will be masked when this bit is enabled. the corresponding pwmn channel will be output with pmd.n data. 0: pwm genera tor signal is output to next stage. 1: pwm generator signal is masked and pmd.n is output to next stage. (note: n = 0~5). pwm mask data register initial=xx00 0000b bit: 7 6 5 4 3 2 1 0 - - pmd.5 pmd.4 pmd.3 pmd.2 pmd.1 pmd.0 mnemonic: pmd address: eeh bit name function 7~6 - reserved. 5~0 pmd.n pwm mask data bit: this data bit control the state of pwmn output pin, if corresponding pme.n = 1. 0: output logic low to pwmn. 1: output logic high to pwmn. (note: n = 0~5). interrupt high priority 2 initial =x0xx 0xx0b bit: 7 6 5 4 3 2 1 0 preliminary N79E875 data s heet - 62 - - pt2h - - pspih - - pet3h mnemonic: ip2h address: efh bit name function 7 - reserved. 6 pt2h 1: to set interrupt high priority of timer 2 is highest priority level. 5~4 - reserved. 3 pspih 1: to set interrupt high p riority of spi is highest priority level. 2~1 - reserved. 0 pet3h 1: to set interrupt high priority of timer 3 is highest priority level. b register initial=0000 0000b bit: 7 6 5 4 3 2 1 0 b.7 b.6 b.5 b.4 b.3 b.2 b.1 b.0 mnemonic: b address: f0h bi t name function 7 - 0 b the b register is the standard 8052 register that serves as a second accumulator. serial peripheral control register initial=0000 0100b bit: 7 6 5 4 3 2 1 0 ssoe spe lsbfe mstr cpol cpha spr1 spr0 mnemonic: spcr address: f3h bit na me function preliminary N79E875 data s heet publication release date: april 13, 2009 - 63 - revision a02 7 ssoe slave select output enable bit. the ss output feature is enabled only in master mode by asserting the ssoe bit. ss input not effected by ssoe when the device in slave mode. 0: ss input (with m ode fault). 1: ss output (no mode fault). drs s sso e master mode slave mode 0 0 ss input ( with mode fault ) ss input ( not affected by ssoe ) 0 1 reserved ss input ( not affected by ssoe ) 1 0 ss general purpose i/o ( no mode fault ) ss input ( not affected by ssoe ) 1 1 ss output ( no mode fault ) ss input ( not affected by ssoe ) 6 spe serial peripheral system enable bit: when the spe bit is set, spi block functions is enable. when modf is set, spe always reads 0. 0: spi system disabled. 1: spi system enabled. 5 lsbfe lsb - first enable: this bit does not affect the position of the msb and lsb in the data register. reads and writes of the data register always have the msb in bit 7. in master mode, a change of this bit will abort a transmission in progress and force the spi system into idle state. 0: data is transferred most significant bit first. 1: data is transferred least signifi cant bit first. 4 mstr master mode select bit: it is customary to have an external pull - up resistor on lines that are driven by open- drain devices. 0: slave mode. 1: master mode 3 cpol clock polarity bit: when the clock polarity bit is cleared and data i s not being transferred, the sck pin of the master device has a steady state low value. when cpol is set, sck idles high. preliminary N79E875 data s heet - 64 - 2 cpha clock phase bit: the clock phase bit, in conjunction with the cpol bit, controls the clock - data relationship between master an d slave. the cpha bit selects one of two different clocking protocols. 1~0 spr1~0 spi baud rate selection bits: these bits specify the spi baud rates. spr1 spr0 divider 0 0 16 0 1 32 1 0 64 1 1 128 note : in master mode, a change of lsbfe, mstr, cpo l, cpha and spr [1:0] will abort a transmission in progress and force the spi system into idle state. serial peripheral status register initial=0000 0xxxb bit: 7 6 5 4 3 2 1 0 spif wcol spovf modf drss - - - mnemonic: spsr address: f4h bit name function 7 spif spi interrupt complete flag: spif is set upon completion of data transfer between this device and external device or when new data has been received and copied to the spdr. if spif goes high, and if espi (located at eie2.3) is set, a serial periph eral interrupt is generated. spif is clear by software, by writing a 0. 6 wcol write collision bit: clearing the wcol bit is accomplished by software writing a 0. 0: no write collision. 1: write collision. 5 spovf spi overrun flag: spiovf is set if a new character is received before a previously received character is read from spdr. once this bit is set, it will prevent spdr register from accepting new data. it must be cleared before any new data can be written. this flag is cleared by software, by writin g a 0. 0: no overrun. 1: overrun detected. 4 modf spi mode error interrupt status flag: clearing this bit is by software writing a 0. 0: no mode fault. 1: mode fault. preliminary N79E875 data s heet publication release date: april 13, 2009 - 65 - revision a02 3 drss data register slave select: refer to above table in spcr register. 2~0 - reserv ed. serial peripheral data i/o register initial=xxxx xxxxb bit: 7 6 5 4 3 2 1 0 spd.7 spd.6 spd.5 spd.4 spd.3 spd.2 spd.1 spd.0 mnemonic: spdr address: f5h bi t name function 7 - 0 spdr spdr is used when transmitting or receiving data on serial bus. por t adc digital input disable initial=0000 0000b bit: 7 6 5 4 3 2 1 0 padids. 7 padids. 6 padids. 5 padids. 4 padids. 3 padids. 2 padids. 1 padids. 0 mnemonic: padids address: f6h bit name function 7 padids.7 p0.7 digital input disable bit. 0: default (wi th digital/analog input). 1: disable digital input of adc input channel 7. 6 padids.6 p0.6 digital input disable bit. 0: default (with digital/analog input). 1: disable digital input of adc input channel 6. 5 padids.5 p0.5 digital input disable bit. 0: d efault (with digital/analog input). 1: disable digital input of adc input channel 5. 4 padids.4 p0.4 digital input disable bit. 0: default (with digital/analog input). 1: disable digital input of adc input channel 4/comparator 1 (cp1n) input. 3 padids.3 p0.3 digital input disable bit. 0: default (with digital/analog input). 1: disable digital input of adc input channel 3/comparator 1 (cp1p) input. 2 padids.2 p0.2 digital input disable bit. 0: default (with digital/analog input). 1: disable digital input of adc input channel 2/comparator 2 (cp2n) input. preliminary N79E875 data s heet - 66 - 1 padids.1 p0.1 digital input disable bit. 0: default (with digital/analog input). 1: disable digital input of adc input channel 1/comparator 2 (cp2p) input. 0 padids.0 p0.0 digital input disable bit. 0: default (with digital/analog input). 1: disable digital input of adc input channel 0. interrupt high priority 1 initial=0000 x000b bit: 7 6 5 4 3 2 1 0 pcaph ppwmh pbrkh pwdih - pcih pkbh pi2h mnemonic: ip1h address: f7h bit name function 7 pcaph 1: t o set interrupt high priority of capture 0/1/2 as highest priority level. 6 ppwmh 1: to set interrupt high priority of pwm?s counter match/underflow is highest priority level. 5 pbrkh 1: to set interrupt high priority of pwm?s brake is highest priority l evel. 4 pwdih 1: to set interrupt high priority of watchdog is highest priority level. 3 - reserved. 2 pcih 1: to set interrupt high priority of comparator 1 and 2, is highest priority level. 1 pkbh 1: to set interrupt high priority of keypad is highes t priority level. 0 pi2h 1: to set interrupt high priority of i2c is highest priority level. interrupt priority 1 initial=0000 x000b bit: 7 6 5 4 3 2 1 0 pcap ppwm pbrk pwdi - pci pkb pi2 mnemonic: ip1 address: f8h bit name function 7 pcap 1: to set interrupt priority of capture 0/1/2 as higher priority level. 6 ppwm 1: to set interrupt priority of pwm?s counter match/underflow is higher priority level. 5 pbrk 1: to set interrupt priority of pwm?s brake is higher priority level. 4 pwdi 1: to set in terrupt priority of watchdog is higher priority level. 3 - reserved. 2 pc1 1: to set interrupt priority of comparator 1 and 2, is higher priority level. preliminary N79E875 data s heet publication release date: april 13, 2009 - 67 - revision a02 1 pkb 1: to set interrupt priority of keypad is higher priority level. 0 pi2 1: to set interrupt pr iority of i2c is higher priority level. port 4 output mode 1 initial= xxxx 0 000b bit: 7 6 5 4 3 2 1 0 - - - - p4m1.3 p4m1.2 p4m1.1 p4m1.0 mnemonic: p4m1 address: fah bi t name function 3 - 0 p4m1 to control the output configuration of p4 bits [3:0] port 4 output mode 2 initial= xxxx 0 000b bit: 7 6 5 4 3 2 1 0 - - - - p4m2.3 p4m2.2 p4m2.1 p4m2.0 mnemonic: p4m2 address: fbh bi t name function 3 - 0 p4m2 to control the output configuration of p4 bits [3:0] pwm control register 4 initial= 0000 0x 00b bit: 7 6 5 4 3 2 1 0 bk1filt. 1 bk1filt. 0 bk0filt. 1 bk0filt. 0 autobk1 - bken1 bken0 mnemonic: pwmcon4 address: fch bit name function 7 - 6 bk1filt.1 - 0 brake 1 (bkp1 pin) edge detector filter type bits: 00: filter clock = f cpu . 01: filter clock = f cpu /2. 10: filter clock = f cpu /4. 11: filter clock = f cpu /8. 5 - 4 bk0filt.1 - 0 brake 0 (bkp0 pin) edge detector filter type bits: 00: filter clock = f cpu . 01: filter clock = f cpu /2. 10: filter clock = f cpu /4. 11: filter clock = f cpu /8. preliminary N79E875 data s heet - 68 - 3 autobk1 auto - clear brake condition: 0: no change in pwm0 - 5 output. pwm0 - 5 output will remain following pwm generators, if brake is caused by brk1 pin. 1: this will cause pwm0 - 5 output to follow pwmnb bits (see note), when low level is detected at bkp1 pin. note: pnp bits are also able to co ntrol the polarity of pwmnb. if pnp.n=0, pwmn output = pwmnb. if pnp.n=1, pwmn output = invert(pwmnb). 2 - reserved. 1 bken1 enable brake 1 (bkp1 pin) falling edge detection : 0: disable brake 1, bkp1 pin, falling edge detect function (default) . 1: enable brake 1, bkp1 pin, falling edge detection . fbk1 flag will set if this brake occurs. 0 bken0 enable brake 0 (bkp0 pin) falling edge detection : 0: disable brake 0, bkp0 pin, edge detect function (default) . 1: enable brake 0, bkp0 pin, falling edge detectio n . fbk0 flag will set if this brake occurs. pwm 6 low bits register initial= 0000 0 000b 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: fdh bit name function 7:0 pwm6 pwm 6 low bits register. pwm 6 high bits register initial= xxxx 0 000b bit: 7 6 5 4 3 2 1 0 - - - - pwm6.11 pwm6.10 pwm6.9 pwm6.8 mnemonic: pwm6h address: feh bit name function 7:4 - reserved. 3:0 pwm6 pwm 6 high bits register. aux function register 2 initial= 0000 0 000b bit: 7 6 5 4 3 2 1 0 t1oe t0oe pcmp 2 d ids.1 pcmp 2 d ids.0 popdids enclk adc1sel enop mnemonic: auxr2 address: ffh bit name function preliminary N79E875 data s heet publication release date: april 13, 2009 - 69 - revision a02 7 t1oe 1: the p2.7 pin is toggled whenever timer 1 overflows. the output frequency is therefore one half of the timer 1 overflow rate. 6 t0oe 1: the p1.5 pin is toggled whenever timer 0 overflows. the output frequency is therefore one half of the timer 0 overflow rate. 5 pcmp2did s.1 p4.0 digital input disable bit. 0: default (with digital/analog input). 1: disable digital input of comp arator 2 (cp2nb) input. 4 pcmp2did s.0 p4.1 digital input disable bit. 0: default (with digital/analog input). 1: disable digital input of comparator 2 (cp2pb) input. 3 popdids p3.6 and p3.7 digital input disable bit. 0: default (with digital/analog input ). 1: disable digital input of opamp opp and opn inputs. 2 enclk 1: to use the on - chip rc oscillator, a clock output is enabled on the xtal2 pin. 1 adc1sel adc 1 source select bit: 0: from p0.1 input. 1: from brownout 1.2v output, vbf. 0 enop op amp ena ble: 0: op amp disabled. 1: op amp enabled. preliminary N79E875 data s heet - 70 - 8 instruction the N79E875 series execute all the instructions of the standard 8052 family. the operations of these instructions, as well as their effects on flag and status bits, are exactly same. however, the t iming of these instructions is different in two ways. firstly, the machine cycle is four clock periods, while the standard - 8051/52 machine cycle is twelve clock periods. secondly, it can fetch only once per machine cycle (i.e., four clocks per fetch), whil e the standard 8051/52 can fetch twice per machine cycle (i.e., six clocks per fetch). the timing differences create an advantage for the N79E875 series. there is only one fetch per machine cycle, so the number of machine cycles is usually equal to the nu mber of operands in the instruction. (jumps and calls do require an additional cycle to calculate the new address.) as a result, the N79E875 series reduces the number of dummy fetches and wasted cycles, and therefore improves overall efficiency, compared t o the standard 8051/52. op - code hex code bytes N79E875 series machine cycle N79E875 series clock cycles 8032 clock cycles N79E875 series vs. 8032 speed ratio nop 00 1 1 4 12 3 add a, r0 28 1 1 4 12 3 add a, r1 29 1 1 4 12 3 add a, r2 2a 1 1 4 12 3 ad d a, r3 2b 1 1 4 12 3 add a, r4 2c 1 1 4 12 3 add a, r5 2d 1 1 4 12 3 add a, r6 2e 1 1 4 12 3 add a, r7 2f 1 1 4 12 3 add a, @r0 26 1 1 4 12 3 add a, @r1 27 1 1 4 12 3 add a, direct 25 2 2 8 12 1.5 add a, #data 24 2 2 8 12 1.5 addc a, r0 38 1 1 4 12 3 addc a, r1 39 1 1 4 12 3 addc a, r2 3a 1 1 4 12 3 addc a, r3 3b 1 1 4 12 3 addc a, r4 3c 1 1 4 12 3 preliminary N79E875 data s heet publication release date: april 13, 2009 - 71 - revision a02 op - code hex code bytes N79E875 series machine cycle N79E875 series clock cycles 8032 clock cycles N79E875 series vs. 8032 speed ratio addc a, r5 3d 1 1 4 12 3 addc a, r6 3e 1 1 4 12 3 addc a, r7 3f 1 1 4 12 3 addc a, @r0 36 1 1 4 12 3 addc a, @r1 37 1 1 4 12 3 addc a, direct 35 2 2 8 12 1.5 addc a, #data 34 2 2 8 12 1.5 subb a, r0 98 1 1 4 12 3 subb a, r1 99 1 1 4 12 3 subb a, r2 9a 1 1 4 12 3 subb a, r3 9b 1 1 4 12 3 subb a, r4 9c 1 1 4 12 3 subb a, r5 9d 1 1 4 12 3 subb a, r6 9e 1 1 4 12 3 subb a, r7 9f 1 1 4 12 3 subb a, @r0 96 1 1 4 12 3 subb a, @r1 97 1 1 4 12 3 subb a, direct 95 2 2 8 12 1.5 subb a, #data 94 2 2 8 12 1.5 inc a 04 1 1 4 12 3 inc r0 08 1 1 4 12 3 inc r1 09 1 1 4 12 3 inc r2 0a 1 1 4 12 3 inc r3 0b 1 1 4 12 3 inc r4 0c 1 1 4 12 3 inc r5 0d 1 1 4 12 3 inc r6 0e 1 1 4 12 3 preliminary N79E875 data s heet - 72 - op - code hex code bytes N79E875 series machine cycle N79E875 series clock cycles 8032 clock cycles N79E875 series vs. 8032 speed ratio inc r7 0f 1 1 4 12 3 inc @r0 06 1 1 4 12 3 inc @r1 07 1 1 4 12 3 inc direct 05 2 2 8 12 1.5 inc dptr a3 1 2 8 24 3 dec a 14 1 1 4 12 3 dec r0 18 1 1 4 12 3 dec r1 19 1 1 4 12 3 dec r2 1a 1 1 4 12 3 dec r3 1b 1 1 4 12 3 dec r4 1c 1 1 4 12 3 dec r5 1d 1 1 4 12 3 dec r6 1e 1 1 4 12 3 dec r7 1f 1 1 4 12 3 dec @r0 16 1 1 4 12 3 dec @r1 17 1 1 4 12 3 dec direct 15 2 2 8 12 1.5 mul ab a4 1 5 20 48 2.4 div ab 84 1 5 20 48 2.4 da a d4 1 1 4 12 3 anl a, r0 58 1 1 4 12 3 anl a, r1 59 1 1 4 12 3 anl a, r2 5a 1 1 4 12 3 anl a, r3 5b 1 1 4 12 3 anl a, r4 5c 1 1 4 12 3 anl a, r5 5d 1 1 4 12 3 anl a, r6 5e 1 1 4 12 3 preliminary N79E875 data s heet publication release date: april 13, 2009 - 73 - revision a02 op - code hex code bytes N79E875 series machine cycle N79E875 series clock cycles 8032 clock cycles N79E875 series vs. 8032 speed ratio anl a, r7 5f 1 1 4 12 3 anl a, @r0 56 1 1 4 12 3 anl a, @r1 57 1 1 4 12 3 anl a, direct 55 2 2 8 12 1.5 anl a, #data 54 2 2 8 12 1.5 anl direct, a 52 2 2 8 12 1.5 anl direct, #data 53 3 3 12 24 2 orl a, r0 48 1 1 4 12 3 orl a, r1 49 1 1 4 12 3 orl a, r2 4a 1 1 4 12 3 orl a, r3 4b 1 1 4 12 3 orl a, r4 4c 1 1 4 12 3 orl a, r5 4d 1 1 4 12 3 orl a, r6 4e 1 1 4 12 3 orl a, r7 4f 1 1 4 12 3 orl a, @r0 46 1 1 4 12 3 orl a, @r1 47 1 1 4 12 3 orl a, direct 45 2 2 8 12 1.5 orl a, #data 44 2 2 8 12 1.5 orl direct, a 42 2 2 8 12 1.5 orl direct, #data 43 3 3 12 24 2 xrl a, r0 68 1 1 4 12 3 x rl a, r1 69 1 1 4 12 3 xrl a, r2 6a 1 1 4 12 3 xrl a, r3 6b 1 1 4 12 3 xrl a, r4 6c 1 1 4 12 3 xrl a, r5 6d 1 1 4 12 3 preliminary N79E875 data s heet - 74 - op - code hex code bytes N79E875 series machine cycle N79E875 series clock cycles 8032 clock cycles N79E875 series vs. 8032 speed ratio xrl a, r6 6e 1 1 4 12 3 xrl a, r7 6f 1 1 4 12 3 xrl a, @r0 66 1 1 4 12 3 xrl a, @r1 67 1 1 4 12 3 xrl a, direct 65 2 2 8 12 1.5 xrl a, #data 64 2 2 8 12 1.5 xrl direct, a 62 2 2 8 12 1.5 xrl direct, #data 63 3 3 12 24 2 clr a e4 1 1 4 12 3 cpl a f4 1 1 4 12 3 rl a 23 1 1 4 12 3 rlc a 33 1 1 4 12 3 rr a 03 1 1 4 12 3 rrc a 13 1 1 4 12 3 swap a c4 1 1 4 12 3 mov a, r0 e8 1 1 4 12 3 mov a, r1 e9 1 1 4 12 3 mov a, r2 ea 1 1 4 12 3 mov a, r3 eb 1 1 4 12 3 mov a, r4 ec 1 1 4 12 3 mov a, r5 ed 1 1 4 12 3 mov a, r6 ee 1 1 4 12 3 mov a, r7 ef 1 1 4 12 3 mov a, @r0 e6 1 1 4 12 3 mov a, @r1 e7 1 1 4 12 3 mov a, direct e5 2 2 8 12 1.5 mov a, #data 74 2 2 8 12 1.5 preliminary N79E875 data s heet publication release date: april 13, 2009 - 75 - revision a02 op - code hex code bytes N79E875 series machine cycle N79E875 series clock cycles 8032 clock cycles N79E875 series vs. 8032 speed ratio mov r0, a f8 1 1 4 12 3 mov r1, a f9 1 1 4 12 3 mov r2, a fa 1 1 4 12 3 mov r3, a fb 1 1 4 12 3 mov r4, a fc 1 1 4 12 3 mov r5, a fd 1 1 4 12 3 mov r6, a fe 1 1 4 12 3 mov r7, a ff 1 1 4 12 3 mov r0, dire ct a8 2 2 8 12 1.5 mov r1, direct a9 2 2 8 12 1.5 mov r2, direct aa 2 2 8 12 1.5 mov r3, direct ab 2 2 8 12 1.5 mov r4, direct ac 2 2 8 12 1.5 mov r5, direct ad 2 2 8 12 1.5 mov r6, direct ae 2 2 8 12 1.5 mov r7, direct af 2 2 8 12 1.5 mov r0, #dat a 78 2 2 8 12 1.5 mov r1, #data 79 2 2 8 12 1.5 mov r2, #data 7a 2 2 8 12 1.5 mov r3, #data 7b 2 2 8 12 1.5 mov r4, #data 7c 2 2 8 12 1.5 mov r5, #data 7d 2 2 8 12 1.5 mov r6, #data 7e 2 2 8 12 1.5 mov r7, #data 7f 2 2 8 12 1.5 mov @r0, a f6 1 1 4 12 3 mov @r1, a f7 1 1 4 12 3 mov @r0, direct a6 2 2 8 12 1.5 preliminary N79E875 data s heet - 76 - op - code hex code bytes N79E875 series machine cycle N79E875 series clock cycles 8032 clock cycles N79E875 series vs. 8032 speed ratio mov @r1, direct a7 2 2 8 12 1.5 mov @r0, #data 76 2 2 8 12 1.5 mov @r1, #data 77 2 2 8 12 1.5 mov direct, a f5 2 2 8 12 1.5 mov direct, r0 88 2 2 8 12 1.5 mov direct, r1 89 2 2 8 12 1.5 mov direct, r2 8a 2 2 8 12 1.5 mov direct, r3 8b 2 2 8 12 1.5 mov direct, r4 8c 2 2 8 12 1.5 mov direct, r5 8d 2 2 8 12 1.5 mov direct, r6 8e 2 2 8 12 1.5 mov direct, r7 8f 2 2 8 12 1.5 mov direct, @r0 86 2 2 8 12 1.5 mov direct, @r1 87 2 2 8 12 1. 5 mov direct, direct 85 3 3 12 24 2 mov direct, #data 75 3 3 12 24 2 mov dptr, #data 16 90 3 3 12 24 2 movc a, @a+dptr 93 1 2 8 24 3 movc a, @a+pc 83 1 2 8 24 3 movx a, @r0 e2 1 2 - 9 8 - 36 24 3 - 0.66 movx a, @r1 e3 1 2 - 9 8 - 36 24 3 - 0.66 mov x a, @dptr e0 1 2 - 9 8 - 36 24 3 - 0.66 movx @r0, a f2 1 2 - 9 8 - 36 24 3 - 0.66 movx @r1, a f3 1 2 - 9 8 - 36 24 3 - 0.66 movx @dptr, a f0 1 2 - 9 8 - 36 24 3 - 0.66 push direct c0 2 2 8 24 3 pop direct d0 2 2 8 24 3 preliminary N79E875 data s heet publication release date: april 13, 2009 - 77 - revision a02 op - code hex code bytes N79E875 series machine cycle N79E875 series clock cycles 8032 clock cycles N79E875 series vs. 8032 speed ratio xch a, r0 c8 1 1 4 12 3 xch a , r1 c9 1 1 4 12 3 xch a, r2 ca 1 1 4 12 3 xch a, r3 cb 1 1 4 12 3 xch a, r4 cc 1 1 4 12 3 xch a, r5 cd 1 1 4 12 3 xch a, r6 ce 1 1 4 12 3 xch a, r7 cf 1 1 4 12 3 xch a, @r0 c6 1 1 4 12 3 xch a, @r1 c7 1 1 4 12 3 xchd a, @r0 d6 1 1 4 12 3 xchd a, @r1 d7 1 1 4 12 3 xch a, direct c5 2 2 8 12 1.5 clr c c3 1 1 4 12 3 clr bit c2 2 2 8 12 1.5 setb c d3 1 1 4 12 3 setb bit d2 2 2 8 12 1.5 cpl c b3 1 1 4 12 3 cpl bit b2 2 2 8 12 1.5 anl c, bit 82 2 2 8 24 3 anl c, /bit b0 2 2 6 24 3 orl c, bit 7 2 2 2 8 24 3 orl c, /bit a0 2 2 6 24 3 mov c, bit a2 2 2 8 12 1.5 mov bit, c 92 2 2 8 24 3 acall addr11 71, 91, b1, 11, 31, 51, d1, f1 2 3 12 24 2 preliminary N79E875 data s heet - 78 - op - code hex code bytes N79E875 series machine cycle N79E875 series clock cycles 8032 clock cycles N79E875 series vs. 8032 speed ratio lcall addr16 12 3 4 16 24 1.5 ret 22 1 2 8 24 3 reti 32 1 2 8 24 3 ajmp addr11 01, 21, 41, 61, 81, a1 , c1, e1 2 3 12 24 2 ljmp addr16 02 3 4 16 24 1.5 jmp @a+dptr 73 1 2 6 24 3 sjmp rel 80 2 3 12 24 2 jz rel 60 2 3 12 24 2 jnz rel 70 2 3 12 24 2 jc rel 40 2 3 12 24 2 jnc rel 50 2 3 12 24 2 jb bit, rel 20 3 4 16 24 1.5 jnb bit, rel 30 3 4 16 24 1. 5 jbc bit, rel 10 3 4 16 24 1.5 cjne a, direct, rel b5 3 4 16 24 1.5 cjne a, #data, rel b4 3 4 16 24 1.5 cjne @r0, #data, rel b6 3 4 16 24 1.5 cjne @r1, #data, rel b7 3 4 16 24 1.5 cjne r0, #data, rel b8 3 4 16 24 1.5 cjne r1, #data, rel b9 3 4 16 2 4 1.5 cjne r2, #data, rel ba 3 4 16 24 1.5 cjne r3, #data, rel bb 3 4 16 24 1.5 cjne r4, #data, rel bc 3 4 16 24 1.5 cjne r5, #data, rel bd 3 4 16 24 1.5 cjne r6, #data, rel be 3 4 16 24 1.5 cjne r7, #data, rel bf 3 4 16 24 1.5 preliminary N79E875 data s heet publication release date: april 13, 2009 - 79 - revision a02 op - code hex code bytes N79E875 series machine cycle N79E875 series clock cycles 8032 clock cycles N79E875 series vs. 8032 speed ratio djnz r0, rel d8 2 3 1 2 24 2 djnz r1, rel d9 2 3 12 24 2 djnz r5, rel dd 2 3 12 24 2 djnz r2, rel da 2 3 12 24 2 djnz r3, rel db 2 3 12 24 2 djnz r4, rel dc 2 3 12 24 2 djnz r6, rel de 2 3 12 24 2 djnz r7, rel df 2 3 12 24 2 djnz direct, rel d5 3 4 16 24 1.5 table 8 - 1 : instruction set for N79E875 preliminary N79E875 data s heet - 80 - 9 power management N79E875 series are provided with idle mode and power - down mode to control power consumption. these modes are discussed in the next two sections, followed by a di scussion of resets. 9.1 idle mode the user can put the device into idle mode by writing 1 to the bit pcon.0. the instruction that sets the idle bit is the last instruction that will be executed before the device goes into idle mode. in the idle mode, the clock to the cpu is halted, but not to the peripheral blocks. this forces the cpu state to be frozen; the program counter, the stack pointer, the program status word, the accumulator and the other registers hold their contents. the port pins hold the logical st ates they had at the time idle was activated. the idle mode can be terminated in two ways. since the interrupt controller is still active, the activation of any enabled interrupt can wake up the processor. this will automatically clear the idle bit, termin ate the idle mode, and the interrupt service routine (isr) will be executed. after the isr is completed, the program execution returns to the instruction after one which put the device into idle mode and continues from there. the idle mode can also be exit ed by activating the reset. the device can put into reset either by applying a low on the external /rst pin, a power on reset condition or a watchdog timer reset. the external reset pin has to be held low for at least two machine cycles i.e. 8 clock period s to be recognized as a valid reset. in the reset condition the program counter is reset to 0000h and all the sfrs are set to the reset condition. since the clock is already running there is no delay and execution starts immediately. in the idle mode, the watchdog timer continues to run, and if enabled, a time - out will cause a watchdog timer interrupt which will wake up the device. the software must reset the watchdog timer in order to preempt the reset which will occur after 512 clock periods of the time - o ut. when N79E875series are exiting from idle mode with a reset, the instruction following the one which put the device into idle mode is not executed. so there is no danger of unexpected writes. 9.2 power down mode the device can be put into power down mode by writing 1 to bit pcon.1. the instruction that does this will be the last instruction to be executed before the device goes into power down mode. in the power down mode, all the clocks are stopped and the device comes to a halt. all activity , except the fu nctions of brownout reset, kbi, 1 int , 0 int , watchdog timer(config0.wdtck=0), adc(rcclk=1) and analog comparator(if enabled), is completely stopped and the power consumption is reduced to the lowest possible value. the port pins hold at the states of the values held by their respective sfrs. the interrupt sources that can wake up cpu from the power down mode are external interrupts, keyboard interrupt (kbi), brownout reset (bor), comparators interrupt (cmf1/cmf2) , adc int errupt (if adc clock is from internal rc) and watchdog timer interrupt (if wd t ck = 0 ). the device will then execute the interrupt service routine for the corresponding external interrupt. after the interrupt service routine is completed, the program executi on returns to the instruction after one which put the device into power down mode and continues from there. besides, the /rst pin trigger by a low pulse of at least two machine cycle terminates the power down mode and restarts the clock. the program execut ion will restart from 0000h. note : 1. e ither a low - level or a falling - edge at external interrupt pin s /int0 and int1 will re - start the oscillator if the global interrupt is enabled(ea=1) and the corresponding interrupt is enabled. 2. the /int0 pin is permanentl y in open - drain type therefore it is recommended with an external pull - up resistor on pin in application preliminary N79E875 data s heet publication release date: april 13, 2009 - 81 - revision a02 10 reset conditions the user has several hardware related options for placing N79E875 series into reset condition. in general, most register bits go to their reset value irrespective of the reset condition, but there are a few flags whose state depends on the source of reset. the user can use these flags to determine the cause of reset using software. the sources of resets are external reset, power - on- res et, watchdog timer reset and software reset (brownout is also able to reset the device if enabled). 10.1 external reset the device continuously samples the /rst pin at state c4 of every machine cycle. therefore the /rst pin must be held low for at least 2 machi ne cycles to ensure detection of a valid /rst low. the reset circuitry then synchronously applies the internal reset signal. thus the reset is a synchronous operation and requires the clock to be running to cause an external reset. once the device is in re set condition, it will remain so as long as /rst is 0. even after /rst is deactivated, the device will continue to be in reset state for up to two machine cycles, and then begin program execution from 0000h. there is no flag associated with the external re set condition. however since the other two reset sources have flags, the external reset can be considered as the default reset if those two flags are cleared. 10.2 power - on reset (por) when power up, the device perform s a power - on reset and set s the por flag. t he software should clear the por flag , or it will be difficult to determine the source of future reset s . during power - on- reset, all port pins will be tri - stated. after power - on - reset, the port pins state will determined by prhi value. 10.3 watchdog timer reset the watchdog timer is a free running timer with programmable time - out intervals. the user can clear the watchdog timer at any time, causing it to restart the count. when the time - out interval is reached an interrupt flag ( wdif at wdcon.3 ) will be set by ha rdware . if the watchdog reset is enabled ( wdrun at wdcon.7 ) and the watchdog timer is not cleared before the time - out of 512 clock period since wintf is set, the watchdog timer will set watchdog reset flag ( wtrf at wdcon.2 ) and generate a reset . this place s the device into the reset condition. the reset condition is maintained by hardware for two machine cycles. once the reset is removed the device will begin execution from 0000h. the watchdog reset flag w tr f keeps high after watchdog reset , it must be clea red by software. 10.4 software r eset user can software reset the device by setting srst bit in sfr auxr1. the reset condition is maintained by hardware for two machine cycles. once the reset is removed the device will begin execution from 0000h. user must speci ally take care of setting srst when a write access on auxr1. 10.5 brownout reset when the power voltage(v dd ) is lower than brownout voltage(v bod ), the brownout detector will set brownout interrupt flag(bof at pcon . 5 ), if brownout reset function is enabled( bod =1 and boi=0 at auxr1 ) a hardware brownout reset will be triggered and the device keeps in reset state until the v dd raises above brownout voltage. note that bof won ? t be cleared by brownout reset, it must be cleared by software 10.6 reset state preliminary N79E875 data s heet - 82 - most of the sfrs and registers on the device will go to the same condition in the reset state. the program counter is forced to 0000h and is held there as long as the reset condition is applied. however, the reset state does not affect the on - chip ram. the data in the ram will be preserved during the reset. however, the stack pointer is reset to 07h, and therefore the stack contents will be lost. the ram contents will be lost if the v dd falls below approximately 2v, as this is the minimum voltage level required for the ram data retention . therefore after a first time power on reset the ram contents will be indeterminate. during a power fail condition, if the power falls below 2v, the ram contents are lost. the wdcon sfr bits are set/cleared in reset condition depending on th e source of the reset. the wdcon sfr is set to a 0x00 0000b on the reset. wtrf (wdcon.2) is set to a 1 on a watchdog timer reset, but to a 0 on power on/down resets. wtrf (wdcon.2) is not altered by external reset. ewrst (wdcon.1) is cleared by any reset. software or any reset will clear wdif (wdcon.3) bit. some of the bits in the wdcon sfr (wdrun, wdclr, ewrst, wdif, wd0 and wd1) have unrestricted read access which required timed access procedure to write. the remaining bits have unrestricted write accesse s. please refer ta register description. the wdcon sfr bits are set or cleared in reset condition depending on the source of the reset. wdcon watch - dog control d8h (df) wdrun (de) - (dd) wd1 (dc) wd0 (db) wdif (da) wtrf (d9) ewrst (d8) wdclr external reset : 0x00 0x00 b watchdog reset: 0x00 0100 b power on reset 0x00 0000 b preliminary N79E875 data s heet publication release date: april 13, 2009 - 83 - revision a02 11 interrupts N79E875 series have four priority level interrupts structure with 17 interrupt sources. each of the interrupt sources has an individual priority bit, flag, interrupt vector an d enable bit. in addition, the interrupts can be globally enabled or disabled. 11.1 interrupt sources the external interrupts int0 and int1 can be either edge triggered or level triggered, programmable through bits it0 and it1 (sfr tc on). the bits ie0 and ie1 in tcon register are the flags which are checked to generate the interrupt. in the edge triggered mode, the intx inputs are sampled in every machine cycle. if the sample is high in one cycle and low in the next, then a high to low transition is detected and the interrupts request flag iex in tcon is set. the flag bit requests the interrupt. since the external interrupts are sampled every machine cycle, they have to be held high or low for at least one complete machine cycle. the ie x flag is automatically cleared when the service routine is called. if the level triggered mode is selected, then the requesting source has to hold the pin low till the interrupt is serviced. the iex flag will not be cleared by the hardware on entering the service routine. if the interrupt continues to be held low even after the service routine is completed, then the processor may acknowledge another interrupt request from the same source. the timer 0 and 1 interrupts are generated by the tf0 and tf1 flags. these flags are set by the overflow in the timer 0 and timer 1. the tf0 and tf1 flags are automatically cleared by the hardware when the timer interrupt is serviced. the watchdog timer can be used as a system monitor or a simple timer. in either case, whe n the time - out count is reached, the watchdog timer interrupt flag wdif (wdcon.3) is set. if the interrupt is enabled by the enable bit eie14, then an interrupt will occur. the timer 2 interrupt is generated through tf2 (due timer 2 overflows or compare ma tch events). the flag must be software cleared. the timer 3 interrupt is generated through tf3 (due to timer 3 overflows, compare match or capture events). the flag must be software cleared. the watchdog timer can be used as a system monitor or a simple t imer. in either case, when the time - out count is reached, the watchdog timer interrupt flag wdif (wdcon.3) is set. if the interrupt is enabled by the enable bit eie14, then an interrupt will occur. the capture interrupt is generated through logical or cptf 0 - 2 flags. cptf0 - 2 flags are set by capture/reload events. software has to resolve the cause of the interrupt among cptf0 - 2. the flags must be software cleared. the serial block can generate interrupt on reception or transmission. there are two interrupt s ources from the serial block, which are obtained by the ri and ti bits in the scon sfr. the flag must be software cleared. i2c will generate an interrupt due to a new sio state present in i2status register, if both ea and es bits (in ie register) are both enabled. spi asserts interrupt flag, spif, upon completion of data transfer with an external device. if spi interrupt is enabled (espi at eie2.3), a serial peripheral interrupt is generated. spif flag is software clear, by writing a 0. modf and spiovf als o will generate interrupt if occur. they share the same vector address as spif. keyboard interrupt is generated when any of the keypad connected to p0 pins is pressed. each keypad interrupt can be individually enabled or disabled. the flag must be cleared by software. comparators 1 and 2 can generate interrupts when detected change in any of the comparator output. cmf1 or cmf2 flag will be asserted, accordingly. the flags must be cleared by software. pwm period interrupt flag pwmf is set by hardware when it s? 12 - bit counter underflows/match and is preliminary N79E875 data s heet - 84 - only be cleared by software. the pwm brake interrupt flag0 fbk0 is set when the external brake pin0(bkp0) detect s a falling edge if bken 0 is enabled. alternatively, the brake interrupt flag1 fbk1 is set by the ext ernal brake pin1(b kp1) detecting a falling change if bken1 is enabled. the adc can generate interrupt after finished adc converter. there are two adc interrupt sources; one is obtained by the adci bit in the adccon sfr and another from adcpi bit in adcrl s fr. the flags must be software cleared. brownout detect can cause brownout flag, bof, to be asserted if power voltage drop below brownout voltage level. interrupt will occur if boi (auxr1.5), ebo (ie.5) and global interrupt enable are set. espi es ri + ti et1 tf1 et0 tf0 ea epwm pwmf ie0 ie1 bof kbf wdif adci eadc ewdi ekb ebo ex1 ex0 interrupt to cpu wakeup (if in power down) et2 tf2 ecptf spif modf spiovf cptf0 cptf1 cptf2 ebrk cmf1 cmf2 eci fbk0 fbk1 ei2 si et3 tf3 figure 11- 1 interrupt source preliminary N79E875 data s heet publication release date: april 13, 2009 - 85 - revision a02 11.2 priority level structure there are four priority levels for the interrupts, highest, high, low and lowest. the interrupt sources can be individually set to either h igh or low levels. naturally, a higher priority interrupt cannot be interrupted by a lower priority interrupt. however there exists a pre - defined hierarchy amongst the interrupts themselves. this hierarchy comes into play when the interrupt controller has to resolve simultaneous requests having the same priority level. this hierarchy is defined as shown on table 11- 1 four - level interrupts priority . the interrupt flags are sampled every machine cycle. in the same machine cycle, the sampled interrupts are polled and their priority is resolved. if certain conditions are met then the hardware will execute an internally generated lcall instruction which will vector the process to the appropriate interrupt vector address. the conditions for generating the lcall are; 1. an interrupt of equal or higher priority is not currently being serviced. 2. the current polling cycle is the last machine cycle of the instruction currently being execute. 3. the current instruction does not involve a writ e to ie, eie, eie2, ip0, ip0h, ip1, iph1, ip2 or ip2h registers and is not a reti. if any of these conditions are not met, then the lcall will not be generated. the polling cycle is repeated every machine cycle, with the interrupts sampled in the same mach ine cycle. if an interrupt flag is active in one cycle but not responded to, and is not active when the above conditions are met, the denied interrupt will not be serviced. this means that active interrupts are not remembered; every polling cycle is new. t he processor responds to a valid interrupt by executing an lcall instruction to the appropriate service routine. this may or may not clear the flag which caused the interrupt. in case of timer interrupts, the tf0 or tf1 flags are cleared by hardware whenev er the processor vectors to the appropriate timer service routine. in case of external interrupt, /int0 and /int1, the flags are cleared only if they are edge triggered. in case of serial interrupts, the flags are not cleared by hardware. in the case of ti mer 2 interrupt, the flags are not cleared by hardware. the watchdog timer interrupt flag wdif has to be cleared by software. the hardware lcall behaves exactly like the software lcall instruction. this instruction saves the program counter contents onto t he stack, but does not save the program status word psw. the pc is reloaded with the vector address of that interrupt which caused the lcall. these address of vector for the different sources are as shown on table 11 - 2 summary of i nterrupt sources . the vector table is not evenly spaced; this is to accommodate future expansions to the device family. execution continues from the vectored address till an reti instruction is executed. on execution of the reti instruction the processor pops the stack and loads the pc with the contents at the top of the stack. the user must take care that the status of the stack is restored to what it was after the hardware lcall, if the execution is to return to the interrupted program. the processor doe s not notice anything if the stack contents are modified and will proceed with execution from the address put back into pc. note that a ret instruction would perform exactly the same process as a reti instruction, but it would not inform the interrupt cont roller that the interrupt service routine is completed, and would leave the controller still thinking that the service routine is underway. N79E875 series use a four priority level interrupt structure. this allows great flexibility in controlling the handl ing of the interrupt sources. priority bits interrupt priority l evel ip x h ip x 0 0 level 0 (lowest priority) preliminary N79E875 data s heet - 86 - 0 1 level 1 1 0 level 2 1 1 level 3 (highest priority) table 11- 1 four - level interrupts prior ity each interrupt source can be individually enabled or disabled by setting or clearing a bit in registers ie, eie or eie2. the ie register also contains a global disable bit, ea, which disables all interrupts at once. each interrupt source can be indi vidually programmed to one of four priority levels by setting or clearing bits in the ip0, ip0h, ip1, ip1h, ip2 and ip2h registers. an interrupt service routine in progress can be interrupted by a higher priority interrupt, but not by another interrupt of the same or lower priority. the highest priority interrupt service cannot be interrupted by any other interrupt source. so, if two requests of different priority levels are received simultaneously, the request of higher priority level is serviced. if reque sts of the same priority level are received simultaneously, an internal polling sequence determines which request is serviced. this is called the arbitration ranking. note that the arbitration ranking is only used to resolve simultaneous requests of the sa me priority level. table below summarizes the interrupt sources, flag bits, vector address, enable bits, priority bits, arbitration ranking, and whether each interrupt may wake up the cpu from power down mode. source flag vector addres s enable bit flag cle ared by priority bit arbitration ranking power - down wakeup external interrupt 0 ie0 0003h ex0 (ie.0) hardware, software ip0h.0, ip0.0 1(highest) yes brownout detect bof 002bh ebo (ie.5) hardware ip0h.5, ip0.5 2 yes watchdog timer wdif 0053h ewdi (eie14 ) software ip1h.4, ip1.4 3 yes [1] timer 0 overflow tf0 000bh et0 (ie.1) hardware, software ip0h.1, ip0.1 4 no spi spif + modf + spiovf 004bh espi (eie2.3) software ip2h.3, ip2.3 5 no i2c si 0033h ei2c (eie1 . 0) software ip1h.0, ip1.0 6 no a/d converter adci+ adcpi 005bh eadc (ie.6) + eadcp (eie2.1) software ip0h.6, ip0.6 7 yes [2] external ie1 0013h ex1 hardware, ip0h.2, 8 yes preliminary N79E875 data s heet publication release date: april 13, 2009 - 87 - revision a02 interrupt 1 (ie.2) software ip0.2 kbi kbf 003bh ekb (eie1 . 1) software ip1h.1, ip1.1 9 yes comparator 1 & 2 cmf1+ cmf2 0063h eci (eie1 . 2) software ip1h.2, ip1.2 10 yes timer 1 overflow tf1 001bh et1 (ie.3) hardware, software ip0h.3, ip0.3 11 no serial port ri + ti 0023h es (ie.4) software ip0h.4, ip0.4 12 no timer 2 overflow/ match tf2 007bh et2 (eie2.6) software ip2h.6, ip2.6 1 3 no pwm brake fbk0, fbk1 0083h ebrk (eie1 . 5) software ip1h.2, ip1.2 14 no capture cptf0 - 2 006bh ecptf (eie1 . 7) software ip1h.7, ip1.7 15 no timer 3 overflow/ match/ capture tf3 008bh et3 (eie2.0) software ip2h.0, ip2.0 16 no pwm match/ underflow pw mf 0073h epwm (eie1 . 6) software ip1h.5, ip1.5 17 (lowest) no table 11- 2 summary of interrupt sources note: the watchdog timer can wake up power down mode when its clock source is used internal rc. adc conver ter interrupt source, adci, can wake up power down mode when its clock source is used internal rc. however, adc compare inter rupt source, adcpi, is not able to wake up from power down mode. 11.3 interrupt response time the response time for each interrupt sour ce depends on several factors, such as the nature of the interrupt and the instruction underway. in the case of external interrupts int0 and int1 , they are sampled at c3 of every machine cycle and then their corresponding interrup t flags iex will be set or reset. the timer 0 and 1 overflow flags are set at c3 of the machine cycle in which overflow has occurred. these flag values are polled only in the next machine cycle. if a request is active and all three conditions are met, then the hardware generated lcall is executed. this lcall itself takes four machine cycles to be completed. thus there is a minimum time of five machine cycles between the interrupt flag being set and the interrupt service routine being executed. preliminary N79E875 data s heet - 88 - a longer resp onse time should be anticipated if any of the three conditions are not met. if a higher or equal priority is being serviced, then the interrupt latency time obviously depends on the nature of the service routine currently being executed. if the polling cyc le is not the last machine cycle of the instruction being executed, then an additional delay is introduced. the maximum response time (if no other interrupt is in service) occurs if the device is performing a write to ie, eie 1 , eie2, ip0, ip0h, ip1, ip1h, ip2 or ip2h and then executes a mul or div instruction. from the time an interrupt source is activated, the longest reaction time is 12 machine cycles. this includes 1 machine cycle to detect the interrupt, 2 machine cycles to complete the ie, eie 1 , eie2, ip0, ip0h, ip1, ip1h, ip2 or ip2h access, 5 machine cycles to complete the mul or div instruction and 4 machine cycles to complete the hardware lcall to the interrupt vector location. thus in a single - interrupt system the interrupt response time will alway s be more than 5 machine cycles and not more than 12 machine cycles. the maximum latency of 12 machine cycle is 48 clock cycles. note that in the standard 8051 the maximum latency is 8 machine cycles which equals 96 machine cycles. this is a 50% reduction in terms of clock periods. preliminary N79E875 data s heet publication release date: april 13, 2009 - 89 - revision a02 12 nvm memory the N79E875 series have nvm data memory of 128 bytes for customer?s data store used. the nvm data memory has 8 pages area and each page has 16 bytes. the page addresses are shown on figure 12- 1 . the nvm memory can be read/write by customer program to access. read nvm data is by movc a,@a+dptr instruction, and write data is by sfr of nvmaddrl, nvmdat and nvmcon. before write data to nvm memory, the page must be erased by providing page address on nvmaddrl, which high and low byte address of on - chip code memory space will decode, then set eer of nvmcon.7. this will automatically hold fetch program code and pc counter, and execute page erase. after finished, this bit will be cleared by hardware. t he erase time is ~ 5ms . for writing data to nvm memory, user must set address and data to nvmaddrl and nvmdat, then set ewr of nvmcon.6 to initiate nvm data write. the uc will hold program code and pc counter, and then write data to mapping address. upon write completion, the ewr bit will be cleared by hardware, the uc will continue execute next instruction. the program time is ~50us . 0000 h 16 k bytes on - chip code memory unused code memory unused code memory 3 fffh ffffh fc 00 h fc 7 fh 128 bytes nvm data memory data flash memory area fc 1 fh fc 10h fc 0 fh fc 00h page 0 page 1 page 7 page 2 page 3 page 4 page 5 page 6 128 bytes nvm 16 bytes / page fc 3 fh fc 30h fc 2 fh fc 20h fc 5 fh fc 50h fc 4 fh fc 40h fc 7 fh fc 70h fc 6 fh fc 60h program flash memory area figure 12- 1 N79E875 on - chip flash m emory spa ce preliminary N79E875 data s heet - 90 - 13 programmable timers/ counters the N79E875 series ha ve two 16 - bit programmable timer/counters which have additional timer 0 or timer 1 overflow toggle output enable feature as compare to conventional timer/counters. this timer overflow toggle output ca n be configured to automatically toggle t0 or t1 pin output whenever a timer overflow occurs. 13.1 timer/counters 0 & 1 N79E875 series have two 16 - bit timer/counters. each of these timer/counters has two 8 bit registers which form the 16 bit counting register. for timer/counter 0 they are th0, the upper 8 bits register, and tl0, the lower 8 bit register. similarly timer/counter 1 has two 8 bit registers, th1 and tl1. the two can be configured to operate either as timers, counting machine cycles or as counters c ounting external inputs. when configured as a "timer", the timer counts clock cycles. for timer 0, the timer clock c an be programmed to be thought of as 1/12 of the system clock or 1/4, 1/16, 1/32, 1/128 (selectable through sfr div.t0div bits) of the syste m clock. as for timer 1, the timer clock c an be programmed to be thought of as 1/12 of the system clock or 1/4 of the system clock. in the "counter" mode, the register is incremented on the falling edge of the external input pin, t0 in case of timer 0, and t1 for timer 1. the t0 and t1 inputs are sampled in every machine cycle at c4. if the sampled value is high in one machine cycle and low in the next, then a valid high to low transition on the pin is recognized and the count register is incremented. since it takes two machine cycles to recognize a negative transition on the pin, the maximum rate at which counting will take place is 1/24 of the master clock frequency. in either the "timer" or "counter" mode, the count register will be updated at c3. therefo re, in the "timer" mode, the recognized negative transition on pin t0 and t1 can cause the count register value to be updated only in the machine cycle following the one in which the negative edge was detected. the "timer" or "counter" function is selected by the " t c/ " bit in the tmod special function register. each timer/counter has one selection bit for its own; bit 2 of tmod selects the function for timer/counter 0 and bit 6 of tmod selects the function for timer/counter 1. in addition each timer/counter can be set to operate in any one of four possible modes. the mode selection is done by bits m0 and m1 in the tmod sfr. 13.2 time - base selection N79E875 series provide users with two modes of operation for the timer. the timers can be programmed t o operate like the standard 8051 family, counting at the rate of 1/12 of the clock speed. this will ensure that timing loops on N79E875 series and the standard 8051 can be matched. this is the default mode of operation of the N79E875 series timers. the use r also has the option to count in the turbo mode, where the timers will increment at the rate of 1/4 clock speed (timer 1) or rate of 1/4,1/16,1/32,1/128 clock speed (timer 0). this will straight - away increase the counting speed up to three times. this sel ection is done by the t0m and t1m bit in ckcon sfr, and t0div bits in div sfr. a reset sets these bits to 0, and the timers then operate in the standard 8051 mode. the user should set these bits accordingly if the timers are to operate in turbo mode. 13.3 mode 0 in mode 0, the timer/counters act as an 8 - bit counter with a 5 - bit, divide by 32 pre - scale. in this mode we have a 13 - bit timer/counter. the 13 - bit counter consists of 8 bits of thx and 5 lower bits of tlx. the upper 3 bits of tlx are ignored. the negati ve edge of the clock is increments count in the tlx register. when the fifth bit in tlx moves from 1 to 0, then the count in the thx register is incremented. when count in thx moves from ffh to 00h, then the overflow flag tfx in tcon sfr is set. the counte d input is enabled only if trx is set and either gate = 0 or intx = 1. when t c/ is set to 0, then it will count clock cycles, and if t c/ is preliminary N79E875 data s heet publication release date: april 13, 2009 - 91 - revision a02 set to 1, then it will count 1 to 0 transitions on t0 (p1.5) for timer 0 an d t1 (p2.7) for timer 1. when the 13- bit count reaches 1fffh the next count will cause it to roll - over to 0000h. the timer overflow flag tfx of the relevant timer is set and if enabled an interrupts will occur. 0 1 0 4 7 0 7 th 0 tl 0 t 0 =( p 1 . 5 ) c / t = tmod . 2 gate = tmod . 3 / int 0 =( p 1 . 6 ) tr 0 = tcon . 4 t 0 m = ckcon . 3 0 1 fcpu / 4 fcpu / 16 fcpu / 32 fcpu / 128 t 0 div [ 1 : 0 ] 00 01 10 11 fcpu / 12 tf0 interrupt 0 1 1 t 0 oe p 1 . 5 ( t 0 ) sfr t 0 oe en p 1 . 5 port figure 13- 1 timer 0 mode 0 fcpu 1 / 12 0 1 0 4 7 0 7 th 1 tl 1 c / t = tmod . 6 gate = tmod . 7 / int 1 =( p 0 . 6 ) t 1 =( p 2 . 7 ) tr 1 = tcon . 6 t 1 m = ckcon . 4 0 1 1 / 4 tf1 interrupt 0 1 1 t 1 oe p 2 . 7 ( t 1 ) sfr t 1 oe en p 2 . 7 port figure 13- 2 timer 1 mode 0 13.4 mode 1 mode 1 is similar to mode 0 except that the counting register forms a 16 - bit coun ter, rather than a 13 - bit counter. this means that all the bits of thx and tlx are used. roll - over occurs when the timer moves from a count of ffffh to 0000h. the timer overflow flag tfx of the relevant timer is set and if enabled an interrupt will occur. the selection of the time - base in the timer mode is similar to that in mode 0. the gate function operates similarly to that in mode 0. preliminary N79E875 data s heet - 92 - 0 1 0 4 7 0 7 th 0 tl 0 c / t = tmod . 2 0 1 t 0 m = ckcon . 3 t 0 =( p 1 . 5 ) gate = tmod . 3 / int 0 =( p 1 . 6 ) tr 0 = tcon . 4 fcpu / 4 fcpu / 16 fcpu / 32 fcpu / 128 t 0 div [ 1 : 0 ] 00 01 10 11 fcpu / 12 tf0 interrupt 0 1 1 t 0 oe p 1 . 5 ( t 0 ) sfr t 0 oe en p 1 . 5 port figure 13- 3 timer 0 mode 1 fcpu 1 / 12 0 1 0 4 7 0 7 th 1 tl 1 c / t = tmod . 6 1 / 4 0 1 t 1 m = ckcon . 4 gate = tmod . 7 / int 1 =( p 0 . 6 ) t 1 =( p 2 . 7 ) tr 1 = tcon . 6 tf 1 interrupt 0 1 1 t 1 oe p 2 . 7 ( t 1 ) sfr t 1 oe en p 2 . 7 port figure 13- 4 timer 1 mode 1 13.5 mode 2 in mode 2, the timer/counter is in the auto reload mode. in this mode, tlx acts as an 8 - bit count register, while thx holds the reload value. when the tlx re gister overflows from ffh to 00h, the tfx bit in tcon is set and tlx is reloaded with the contents of thx, and the counting process continues from here. the reload operation leaves the contents of the thx register unchanged. counting is enabled by the trx bit and proper setting of gate and intx pins. as in the other two modes 0 and 1, mode 2 allows counting of either clock cycles or pulses on pin tn. preliminary N79E875 data s heet publication release date: april 13, 2009 - 93 - revision a02 0 1 0 7 0 7 th 0 tl 0 c / t = tmod . 2 0 0 1 t 0 m = ckcon . 3 fcpu / 4 fcpu / 16 fcpu / 32 fcpu / 128 t 0 div [ 1 : 0 ] 00 01 10 11 fcpu / 12 t 0 =( p 1 . 5 ) gate = tmod . 3 / int 0 =( p 1 . 6 ) tr 0 = tcon . 4 tf0 interrupt 0 1 1 t 0 oe t 0 oe en sfr p 1 . 5 p 1 . 5 ( t 0 ) port figure 13- 5 time r 0 mode 2 (8 - bit auto - reload mode) 0 1 0 7 0 7 th 1 tl 1 c / t = tmod . 6 fcpu 1 / 12 0 1 / 4 0 1 t 1 m = ckcon . 4 gate = tmod . 7 / int 1 =( p 0 . 6 ) t 1 =( p 2 . 7 ) tr 1 = tcon . 6 tf 1 interrupt 0 1 1 t 1 oe t 1 oe en sfr p 2 . 7 p 2 . 7 ( t 1 ) port figure 13- 6 timer 1 mode 2 (8 - bit auto - reload mode) 13.6 mode 3 mode 3 has different operating methods for the two timer/counters. for timer/count er 1, mode 3 simply freezes the counter. timer/counter 0, however, configures tl0 and th0 as two separate 8 bit count registers in this mode. tl0 uses the timer/counter 0 control bits t c/ , gate, tr0, int0 and tf0. when timer 0 co nfigure to mode 3, the tl0 can be used to count clock cycles (clock/12 or clock/4,16,32,128) or 1 - to - 0 transitions on pin t0 as determined by c/t (tmod.2). th0 is forced as a clock cycle counter (clock/12 or clock/4,16,32,128) and takes over the use of tr1 and tf1 from timer/counter 1. mode 3 is used in cases where an extra 8 bit timer is needed. with timer 0 in mode 3, timer 1 can still be used in modes 0 - 2, but its flexibility is somewhat limited. while its basic functionality is maintained, it no longer has control over its overflow flag tf1 and the enable bit tr1. preliminary N79E875 data s heet - 94 - timer 1 can still be used as a timer/counter and retains the use of gate and int1 pin. in this condition it can be turned on and off by switching it out of and into its own mode 3. it can also be used as a baud rate generator for the serial port. 0 1 0 7 0 7 th 0 tl 0 t 0 ( p 1 . 5 ) c / t = tmod . 2 gate = tmod . 3 / int 0 ( p 1 . 6 ) tr 0 = tcon . 4 tr 1 = tcon . 6 0 0 1 t 0 m = ckcon . 3 fcpu / 4 fcpu / 16 fcpu / 32 fcpu / 128 t 0 div [ 1 : 0 ] 00 01 10 11 fcpu / 12 tf0 interrupt tf1 interrupt toggle ( refer to mode 0 ) t 0 oe p 1 . 5 sfr toggle ( refer to mode 0 ) t 1 oe p 2 . 7 ( t 1 ) port p 2 . 7 sfr p 1 . 5 ( t 0 ) port figure 13- 7 timer 0 mode 3 (two 8 - bit counters) preliminary N79E875 data s heet publication release date: april 13, 2009 - 95 - revision a02 14 watchdog timer the watchdog timer is a free - running timer which can be p rogrammed by the user to serve as a system monitor, a time - base generator or an event timer. it is basically a set of dividers that divide the system clock. the divider output is selectable and determines the time - out interval. when the time - out occurs a f lag is set and wdt i nterrupt is requested if wdt interrupt is enabled ( e ie.ewdi=1) and global interrupt is enabled(ea=1) ,and a system reset can also be caused if it is enabled. the interrupt and reset functions are independent of each other and may be used separately or together depending on the user?s software. wdif 512 clock delay mux 500 khz rc oscillator uc clock wdtck wdrun wd 1 , wd 0 wdclr ewdi ewrst reset interrupt 00 01 10 11 wtrf 20- bits counter time - out selector 11 0 12 15 16 17 18 19 ( reset watchdog ) ( wdcon . 1 ) ( wdcon . 3 ) ( eie . 4 ) ( wdcon . 2 ) ( wdcon . 0 ) ( wdcon . 7 ) ( security bit ) ( wdcon . 5 / 4 ) / enable figure 14- 1 watchdog timer the watchdog timer should first be restarted by using wdclr. this ensures that the timer star ts from a known state. the wdclr bit is used to restart the watchdog timer. this bit is self clearing, i.e. after writing a 1 to this bit the hardware will automatically clear it. the watchdog timer will now count clock cycles. the time - out interval is sel ected by the two bits wd1 and wd0 (wdcon.5 and wdcon.4). when the selected time - out occurs, the watchdog interrupt flag wdif (wdcon.3) is set. after the time - out has occurred, the watchdog timer waits for an additional 512 clock cycles. if the watchdog res et ewrst (wdcon.1) is enabled, then 512 clocks after the time - out, if there is no wdclr, a system reset due to watchdog timer will occur. this will last for two machine cycles, and the watchdog timer reset flag wtrf (wdcon.2) will be set. this indicates to the software that the watchdog was the cause of the reset. when used as a simple timer, the reset and interrupt functions are disabled. the timer will set the wdif flag each time the timer completes the selected time interval. the wdif flag is polled to d etect a time - out and the wdclr allows software to restart the timer. the watchdog timer can also be used as a very long timer. the interrupt feature is enabled in this case. every time the time - out occurs an interrupt will occur if the global interrupt ena ble ea is set. the main use of the watchdog timer is as a system monitor. this is important in real - time control applications. in case of some power glitches or electro - magnetic interference, the processor may begin to execute errant code. if this is left unchecked the entire system may crash. using the watchdog timer interrupt during software development will allow the user to select ideal watchdog reset locations. the code is first written without the watchdog interrupt or reset. then the watchdog interru pt is enabled to identify code locations where interrupt occurs. the user can now insert instructions to reset the watchdog timer, which will allow the code to run without any watchdog timer interrupts. now the watchdog timer reset is enabled and the watch dog interrupt may be disabled. if any errant code is executed now, then the reset watchdog timer instructions will not be executed at the required instants and watchdog reset will occur. the watchdog timer time - out selection will result in different time - out values depending on the clock preliminary N79E875 data s heet - 96 - speed. the reset will occur, when enabled, 512 clocks after the time - out has occurred. wd1 wd0 watchdog interval number of clocks time @ 10 mhz 0 0 2 12 4096 0.4096 ms 0 1 2 16 65536 6.5536 ms 1 0 2 18 262144 26.2144 ms 1 1 2 20 1048576 104.8576 ms table 14- 1 time - out values for the watchdog timer. the watchdog timer will be disabled by a power - on/fail reset. the watchdog timer reset does not disable the watchdog timer, but will restart it. in general, software should restart the timer to put it into a known state. the control bits that support the watchdog timer are discussed on the following section. 14.1 watchdog control bit: 7 6 5 4 3 2 1 0 wdrun - wd1 wd0 wdif wtrf ewrst wd clr wdif: wdcon.3 - watchdog timer interrupt flag. this bit is set whenever the time - out occurs in the watchdog timer. if the watchdog interrupt is enabled (eie14), then an interrupt will occur (if the global interrupt enable is set and other interrupt re quirements are met). software or any reset can clear this bit. wtrf: wdcon.2 - watchdog timer reset flag. this bit is set whenever a watchdog reset occurs. this bit is useful for determined the cause of a reset. software must read it, and clear it manually . a power - fail reset will clear this bit. if ewrst = 0, then this bit will not be affected by the watchdog timer. ewrst: wdcon.1 - enable watchdog timer reset. this bit when set to 1 will enable the watchdog timer reset function. setting this bit to 0 will disable the watchdog timer reset function, but will leave the timer running. wdclr: wdcon.0 - reset watchdog timer. this bit is used to clear the watchdog timer and to restart it. this bit is self - clearing, so after the software writes 1 to it the hardwar e will automatically clear it. if the watchdog timer reset is enabled, then the wdclr has to be set by the user within 512 clocks of the time - out. if this is not done then a watchdog timer reset will occur. the wdcon sfr is set to a 0x000000b on a power - on- reset. wtrf (wdcon.2) is set to a 1 on a watchdog timer reset, but to a 0 on power on/down resets. wtrf (wdcon.2) is not altered by an external reset. ewrst (wdcon.1) is set to 0 on all resets. reset type by external reset by watchdog reset by power on re set value after the reset 0x00 0x00b 0x00 0100b 0x00 000b 14.2 clock control of watchdog wd1, wd0: wdcon.5, wdcon.4 - watchdog timer mode select bits. these two bits select the time - out interval for the watchdog timer. the reset time is 512 clocks longer than the interrupt time - out value. preliminary N79E875 data s heet publication release date: april 13, 2009 - 97 - revision a02 the default watchdog time - out is 2 12 clocks, which is the shortest time - out period. the wdrun, wd0, wd1, ewrst, wdif and wdclr bits are protected by the timed access procedure. this prevents software from accidentally enablin g or disabling the watchdog timer. more importantly, it makes it highly improbable that errant code can enable or disable the watchdog timer. the security bit wdtck is located at bit 7 of config0 register. this bit is for user to configure the clock source of watchdog timer either from the internal rc or from the uc clock. preliminary N79E875 data s heet - 98 - 15 timer2/input capture modules timer/counter 2 is a 16 bit up counter which is configured by the t2mod register and controlled by the t2con register. timer/counter 2 is also equipped with 3 input captures and reloads capability. as with the timer 0 and timer 1 counters, there exists considerable flexibility in selecting and controlling the clock, and in defining the operating mode. the clock source for timer/counter 2 crystal oscillator i s divided by 1,4,16 or 32 (selectable with ccdiv.1~0 in div sfr). the clock is then enabled when tr2 is a 1, and disabled when tr2 is a 0. 15.1 capture mode the capture modules are function to detect and measure pulse width and period of a square wave. it suppo rts 3 capture inputs and digital noise rejection filter. the modules are configured by capcon0 and capcon1 sfr registers. input capture 0, 1 & 2 have their own edge detector but share with one timer i.e. timer 2. if the schmitt trigger enable bits at sfr p orts are set, t he input capture pins are in the structure with schmitt trigger. for this operation it basically consists of; ? 3 capture module function blocks ? timer 2 block each capture module block consists of 2 bytes capture registers, noise filter and p rogrammable edge triggers. noise filter is used to filter the unwanted glitch or pulse on the trigger input pin. the noise filter can be enabled through capcon1.enfx bit. if enabled, the capture logic required to sample 4 consecutive same capture input va lue in order to recognize an edge as a capture event. a possible implementation of digital noise filter is as follow; q q set clr d q q set clr d q q set clr d q q set clr d j q q k set clr tx filtered clk tx figure 15- 1 noise filter the interval between pulses require ment for input capture is 1 machine cycle width, which is the same as the pulse width required to guarantee a trigger for all trigger edge mode. for less than 3 system clocks, anything less than 3 clocks will not have any trigger and pulse width of 3 or mo re but less than 4 clocks will trigger but will not guarantee 100% because input sampling is at stage c3 of the machine cycle. the trigger option is programmable through capcon0.cctx.1~0 bits. it supports positive edge, negative edge and both edge triggers . each capture module consists of an enable, icen0 - 2. [note: x=0/1/2, for capture 0/1/2 block]. timer/counter 2 serves as a 16 bit up counter. it supports reload and compared modes. more details are described in next sections. preliminary N79E875 data s heet publication release date: april 13, 2009 - 99 - revision a02 capture blocks can be trigge red by the following pins/bit; ? ic0 (p2.4) or adc compare result bit, adcpo. ? ic1 (p2.5) ? ic2 (p2.6) if icenx is enabled, each time the external pin trigger, the content of the free running 16 bits counter, tl2 & th2 (from timer 2 block) will be captured/tra nsferred into the capture registers, cclx and cchx, depending which external pin trigger. this action also causes the cptfx flag bit in capcon1 to be set, which will also generate an interrupt (if enabled by ecptf bit in sfr eie1 . 7). the cptf0 - 2 flags are logical ?or? to the interrupt module. flag is set by hardware and clear by software. software will have to resolve on the priority of the interrupt flags. setting the t2cr bit (t2mod.3), will allow hardware to reset timer 2 automatically after the value of tl2 and th2 have been captured. priority is given to t2cr to reset counter after capture the timer value into the capture register. preliminary N79E875 data s heet - 100 - noise filter cptf 0 ccl 0 cch 0 input capture 0 block [00 ] [01 ] [10 ] icen 0 cct 0[1 :0] enf 0 input capture 1 block input capture 2 block p 2.6 ( ic 2) cptf 1 cptf 2 f cpu div by 1 ,4,16 ,32 tl 2 th 2 rcap 2l rcap 2h 00 01 10 11 tr 2 ccdiv [1:0 ] cptf 0 cptf 1 cptf 2 ccld [1: 0] cmp / rl2 enld timer 2 block = tf2 cmp / rl2 tmf 2 tovf 2 reset pulse tmf 2 cmpcr cptf 0 t 2cr cptf 1 cptf 2 0 1 cmp /rl 2 16- bit up counter ic 2 cptf 0 ic 0 p 2 . 4 ( ic 0 ) p 2 .5 ( ic1) ic 1 adcpo ic 0 ss ( sfr ) 0 1 tr 2 cmp /rl2 ports . p 2 s ports . p 2 s or ports . p 2 s note : tovf2 = timer 2 overflow tmf 2 = internal timer 2 flag signal. figure 15- 2 timer2/capture modules preliminary N79E875 data s heet publication release date: april 13, 2009 - 101 - revision a02 xx 00 01 02 10 0 00 01 02 1 m/c 100h unknown 0000h keeps 0000h ic0 cptf0 tm2 counter capture 0 register rcap2 ex1: falling edge detection, reload mode read capture counter to get period width reload reload xx 00 01 02 10 0 00 01 02 1 m/c 100h unknown 0000h keeps 0000h ic0 cptf0 tm2 counter capture 0 register rcap2 ex2: rising edge detection, reload mode read capture counter to get period width reload reload xx 00 01 02 fc 00 01 02 1 m/c fch 0000h keeps 0000h ic0 cptf0 tm2 counter capture 0 register rcap2 ex3: rising and falling edge detection, reload mode read capture counter to get pulse width reload reload 01 reload 00 02 legend: m/c = machine cycle 02h figure 15- 3 timing diagram for input capture, ic0 preliminary N79E875 data s heet - 102 - start initialize sfr / acc rcap 2 l = rcap 2 h = 0 ; acc = 0 ; configure sfr div = 0000 0000 b; //< default > timer 2 clk = fcpu / 1 capcon 0 = 0000 0101 b; // falling edge and reload by capture 0 block capcon 1 = 0000 1000 b; // enable digital filter for input capture 0 t 2 mod = 1001 0000 b; // icen 0 = enld = 1 ie = 1000 0000 b; // enable ea eie 1 = 1000 0000 b; // enable capture interrupt start timer 2 t 2 con = 0000 0100 b; // tr = 1 acc = 2 ? user read the capture register , and calculate the period base on frequency selected . end no figure 15- 4 program flow for measurement with ic0 between pulses with falling edge detection (acc is incremented in interrupt service routine). preliminary N79E875 data s heet publication release date: april 13, 2009 - 103 - revision a02 start initialize sfr / acc rcap 2 l = rcap 2 h = 0 ; acc = 0 ; configure sfr div = 0000 0000 b; //< default > timer 2 clk = fcpu / 1 capcon 0 = 0000 0 0 01b; // rising edge reload by capture 0 block capcon 1 = 0000 1000 b; // enable digital filter for input capture 0 t 2 mod = 1001 0000 b; // icen 0 = enld = 1 ie = 1000 0000 b; // enable ea eie 1 = 1000 0000 b; // enable capture interrupt start timer 2 t 2 con = 0000 0100 b; // tr = 1 acc = 2 ? user read the capture register and calculate the period base on frequency selected end no figure 15- 5 program flow for measurement with ic0 between pulses with rising edge detection (acc is incremented in interrupt service routine). preliminary N79E875 data s heet - 104 - start initialize sfr / acc rcap 2 l = rcap 2 h = 0 ; acc = 0 ; configure sfr div = 0000 0000 b; //< default > timer 2 clk = fcpu / 1 capcon 0 = 0000 1001b; // rising / falling edge and reload by capture 0 block capcon 1 = 0000 1000 b; // enable digital filter for input capture 0 t 2 mod = 1001 0000 b; // icen 0 = enld = 1 ie = 1000 0000 b; // enable ea eie 1 = 1000 0000 b; // enable capture interrupt start timer 2 t 2 con = 0000 0100 b; // tr = 1 acc = 2 ? user read the capture register and calculate the period base on frequency selected end no figure 15- 6 program flow for measurement with ic0 pu lse width with rising and falling edge detection (acc is incremented in interrupt service routine). preliminary N79E875 data s heet publication release date: april 13, 2009 - 105 - revision a02 0000 h 16 - bit overflow 16 - bit rcap 2 1 6 - b i t u p - c o u n t i n g c o u n t e r reload function , cmp / rl 2 = 0 , enld = 1 set tf2 set tf2 set tf2 16 - bit up counter value 0000 h 16 - bit overflow 16 - bit rcap 2 1 6 - b i t u p - c o u n t i n g c o u n t e r compare function , cmp / rl 2 = 1 set tmf 2 16 - bit up counter value cmpcr = 0 set tmf 2 set tmf 2 cmpcr = 1 figure 15- 7 timer 2 - compare/reload function preliminary N79E875 data s heet - 106 - tl2/th2 value timer 2 0000h ffffh icen0 = 1 cptr0 flag set external input capture 0 ccl/cch 0 regs input capture 0 trigger figure 15- 8 capture module - input capture 0 triggers 15.2 compare mode timer 2 can be configured for compare mode. the compare mode is enabled by setting the cmp/rl2 bit to 1 in the t2con register. rcap2 will serves as a compare register. as timer 2 counting up, upon matching with rcap2 value, tf2 will be set (which will generate an interrupt request if enable timer 2 interrupt et2 is enabled) and the timer reload from 0 and starts c ounting again. setting the cmpcr bit (t2mod.2), will allow hardware to reset timer 2 automatically after a match has occur r ed. 15.3 reload mode timer 2 can be also be configured for reload mode. the reload mode is enabled by clearing the cmp/rl2 bit to 0 in t he t2con register. in this mode, rcap serves as a reload register. when timer 2 overflows, a reload is generated that causes the contents of the rcap2l and rcap2h registers to be reloaded into the tl2 and th2 registers, if enld is set. tf2 flag is set, and interrupt request is generated if enable timer 2 interrupt et 2 is enabled . however, if enld = 0, timer 2 will be reload with 0, and count up again. alternatively, other reload source is also possible by the input capture pins by configuring the ccld.1~0 b its. if the icen x bit is set, then a trigger of external ic 0 , ic 1 or ic 2 pin (respectively) will also cause a reload. this action also sets the cptf0, cptf1 or cptf2 flag bit in sfr capcon1, respectively. preliminary N79E875 data s heet publication release date: april 13, 2009 - 107 - revision a02 16 timer3 this device consists of an additional time r; timer 3. timer 3 is a 12 - bit up counter which supports operation in any one of four possible modes: timer/counter mode, capture mode, auto - reload mode and compare mode. sfr t3con.1~0 t3 mode t3rst = 0 t3rst = 1 00b timer/counter mode timer 3 counts fr om 000h to fffh. 01b capture mode rcap3l, rcap3ht3h.7 - 4 capture content of timer 3. timer 3 counts from 000h to fffh. rcap3l, rcap3ht3h.7 - 4 capture content of timer 3. timer 3 reset after capture occurs. 10b auto - reload mode rcap3l, rcap3ht3h.7 - 4 serve a s reload registers. timer 3 counts from reload registers content to fffh. 11b compare mode rcap3l, rcap3ht3h.7 - 4 serve as compare registers. timer 3 counts from 000h to fffh. rcap3l, rcap3ht3h.7 - 4 serve as compare registers. timer 3 counts from 000h to co mpare value. preliminary N79E875 data s heet - 108 - the following figure shows the timer 3 block diagram. t 3 h t 3 l capture mode or pin t 3 ex auto - reload mode tf 3 timer 3 interrupt 12 - bit up counter exf 3 (sfr ) (sfr) (sfr ) et 3 set t 3 to 000 h t 3 rst (sfr) rcap 3 h rcap 3 l (sfr ) counter overflow fcpu / 4 fcpu / 16 fcpu /32 fcpu / 128 t 3 div [ 1 : 0 ] tr 3 (sfr) (sfr ) (sfr ) 00 01 10 11 - + compare mode compare matched event captured event toggle t 3ex t3oe (sfr ) compare matched event pin t 3ex 0 1 t3 cnte ( sfr) (sfr ) t3 oe note : t3 h ( 4 bits ) = sfr rcap 3ht 3 h. 3- 0 ( lower nibble ) rcap 3 h ( 4 bits ) = sfr rcap 3ht 3h.7 - 4 ( upper nibble ) capture mode 0 1 adcpo ( sfr) t 3css (sfr ) a a (b) (b) (sfr ) figure 16- 1 : timer 3 block diagram note: timer 3 counter is writable only when tr3 = 0. the timer clock can be programmed to be of 1/4, 1/16, 1/32 and 1/128 of the fcpu clock. 16.1 timer/counter mode timer 3 has one 8 bits register and 4 bits register forming the 12 bits counting registers. there bits are located at sfr t3l (lsb bits) and rcap3ht3h.3 - 0 (msb bits). th e timer can be configured to operate either as timer or as counter counting external input. the "timer" or "counter" function is selected by the t3cnte bit in the t3con special function register. when configured as a "timer", the timer counts clock cycles . in the "counter" mode, the register is incremented on the falling edge of the external input pin, t3. the t3 input is sampled in every machine cycle at c4. if the sampled value is high in one machine cycle and low in the next, then a valid high to low tr ansition on the pin is recognized and the count register is incremented. when enable t3oe, t3 pin is toggled whenever timer 3 overflow (or compare matched occurs). 16.2 capture mode in this mode, each time external pin t3 triggers (either rising or falling edg e), the content of timer 3 will be captured/transferred into capture registers, rcap3l.7 - 0 and rcap 3 ht3h.7 - 4. this event will caused exf3 flag bit in sfr t3con.6 to be set, which will also generate an interrupt if enabled by et3 bit (eie2.0). the flag is s et by hardware and clear by software. setting t3rst bit (t3con.3), will allow hardware to reset timer 3 automatically after the values of timer 3 has been captured. otherwise, the timer 3 continues counting. adc compare result, adcpo, is another alternativ e source for capture mode. it is selected by t3css bit. preliminary N79E875 data s heet publication release date: april 13, 2009 - 109 - revision a02 tl3 / th 3 value timer 3 000 h fffh { rcap 3 ht 3 h .7 -4 , rcap 3 l .7 -0} t 3 trigger t3 rst= 1 t3 rst= 0 figure 16- 2 : timer 3 ? capture function 16.3 compare mode in this mode, rcap3l and rcap3ht3h.7 - 4 serve as compare registers. as timer 3 counting up, upon matching the compare registers, exf3 flag will also be set. similarly, an interrupt will be generated if enabled by et3 bit (eie2.0). if t3rst = 0, the timer 3 will continue count up, until overflow follow by count up again fro m zero. setting t3rst bit, will allow hardware to reset timer 3 automatically after there is compare matched. when enable t3oe, t3 pin is toggled whenever compare matched occurs (or timer 3 overflows). exf 3 set when compare matched . compare value timer 3 000 h fffh t3 rst = 1 t3 rst = 0 { rcap 3ht 3 h. 7 -4, rcap 3 l .7 -0 } figure 16- 3 : timer 3 ? compare function preliminary N79E875 data s heet - 110 - 16.4 auto - reload mode in this mode, rcap3l and rcap3ht3h.7 - 4 serve as reload registers. when timer 3 ove r flows, a reload is generated that causes the content of rcap3l and rcap3ht3h.7 - 4 reloaded to t3l and rcap3ht3h.3 - 0. tf3 flag is set, and interrupt request is generated if et3 bit is enabled. preliminary N79E875 data s heet publication release date: april 13, 2009 - 111 - revision a02 17 serial port (uart) serial port in the N79E875 series is a full duplex port. it provides the user with additional features such as the frame error detect ion and the automatic address recognition. the serial ports are capable of synchronous as well as asynchronous communication. in synchronous mode, N79E875 series generate the clock and operates in a half duplex mode. in the asynchronous mode, full duplex o peration is available. this means that it can simultaneously transmit and receive data. the transmit register and the receive buffer are both addressed as sbuf special function register. however any write to sbuf will be to the transmit register, while a r ead from sbuf will be from the receiver buffer register. the serial port can operate in four different modes as described below. 17.1 mode 0 this mode provides synchronous communication with external devices. in this mode serial data is transmitted and received on the rxd line. txd is used to transmit the shift clock. the txd clock is provided whether the device is transmitting or receiving. this mode is therefore a half duplex mode of serial communication. in this mode, 8 bits are transmitted or received per fr ame. the lsb is transmitted/received first. the baud rate is fixed at 1/12 or 1/4 of the oscillator frequency. this baud rate is determined by the sm2 bit (scon.5). when this bit is set to 0, then the serial port runs at 1/12 of the clock. when set to 1, t he serial port runs at 1/4 of the clock. this additional facility of programmable baud rate in mode 0 is the only difference between the standard 8051 and N79E875 series. the functional block diagram is shown below. data enters and leaves the serial port o n the rxd line. the txd line is used to output the shift clock. the shift clock is used to shift data into and out of the device. any instruction that causes a write to sbuf will start the transmission. the shift clock will be activated and data will be sh ifted out on the rxd pin till all 8 bits are transmitted. if sm2 = 1, then the data on rxd will appear 1 clock period before the falling edge of shift clock on txd. the clock on txd then remains low for 2 clock periods, and then goes high again. if sm2 = 0 , the data on rxd will appear 3 clock periods before the falling edge of shift clock on txd. the clock on txd then remains low for 6 clock periods, and then goes high again. this ensures that at the receiving end the data on rxd line can either be clocked on the rising edge of the shift clock on txd or latched when the txd clock is low. preliminary N79E875 data s heet - 112 - 1/12 fcpu 0 tx clock rx clock ti ri tx shift rx start rx shift load sbuf shift clock ri ren sm2 clock sin parout sbuf read sbuf internal data bus serial controllor clock load parin tx start internal data bus sbuf write to sout transmit shift register serial interrupt rxd txd rxd p1.3 alternate input function p1.3 alternate output function p1.2 alternate output function 1/4 1 figure 17- 1 : serial port mode 0 the ti flag is set high in c1 following the end of transmission of the last bit. the serial port will receive data when ren is 1 and ri is zero. the shift clock (txd) will be activated and the serial port will latch data on the rising edge of shift clock. the external device should therefore present data on the fallin g edge on the shift clock. this process continues till all the 8 bits have been received. the ri flag is set in c1 following the last rising edge of the shift clock on txd. this will stop reception, till the ri is cleared by software. 17.2 mode 1 in mode 1, the full duplex asynchronous mode is used. serial communication frames are made up of 10 bits transmitted on txd and received on rxd. the 10 bits consist of a start bit (0), 8 data bits (lsb first), and a stop bit (1). on received, the stop bit goes into rb8 in the sfr scon. the baud rate in this mode is variable. the serial baud can be programmed to be 1/16 or 1/32 of the timer 1 overflow. since the timer 1 can be set to different reload values, a wide variation in baud rates is possible. transmission begins with a write to sbuf. the serial data is brought out on to txd pin at c1 following the first roll - over of divide by 16 counter. the next bit is placed on txd pin at c1 following the next rollover of the divide by 16 counter. thus the transmission is synchr onized to the divide by 16 counters and not directly to the write to sbuf signal. after all 8 bits of data are transmitted, the stop bit is transmitted. the ti flag is set in the c1 state after the stop bit has been put out on txd pin. this will be at the 10th rollover of the divide by 16 counters after a write to sbuf. reception is enabled only if ren is high. the serial port actually starts the receiving of serial data, with the detection of a falling edge on the rxd pin. the 1 - to - 0 detector continuously monitors the rxd line, sampling it at the rate of 16 times the selected baud rate. when a falling edge is detected, the divide by 16 counters is immediately reset. this helps to align the bit boundaries with the rollovers of the divide by 16 counters. the 16 states of the counter effectively divide the bit time into 16 slices. the bit detection is done on a preliminary N79E875 data s heet publication release date: april 13, 2009 - 113 - revision a02 best of three bases. the bit detector samples the rxd pin, at the 8th, 9th and 10th counter states. by using a majority 2 of 3 voting system, the bit va lue is selected. this is done to improve the noise rejection feature of the serial port. if the first bit detected after the falling edge of rxd pin is not 0, then this indicates an invalid start bit, and the reception is immediately aborted. the serial po rt again looks for a falling edge in the rxd line. if a valid start bit is detected, then the rest of the bits are also detected and shifted into the sbuf. after shifting in 8 data bits, there is one more shift to do, after which the sbuf and rb8 are load ed and ri is set. however certain conditions must be met before the loading and setting of ri can be done. 1. ri must be 0 and 2. either sm2 = 0, or the received stop bit = 1. if these conditions are met, then the stop bit goes to rb8, the 8 data bits go into sbuf and ri is set. otherwise the received frame may be lost. after the middle of the stop bit, the receiver goes back to looking for a 1 - to - 0 transition on the rxd pin. 1/2 1/16 tx clock rx clock ti ri tx shift rx start rx shift load sbuf smod clock sin d8 sbuf read sbuf internal data bus serial controllor clock load parin tx start internal data bus sbuf write to sout transmit shift register serial interrupt txd rxd parout rb8 start stop 0 1 bit detector 1-to-0 detector sample 1/16 0 timer 1 overflow 1 receive shift register figure 17- 2 : serial port mode 1 preliminary N79E875 data s heet - 114 - 17.3 mode 2 this mode uses a total of 11 bits in asynchronous full - duplex communication. the functional description is shown in the figure below. the frame consists of one start bit (0), 8 data bits (lsb first), a programmable 9th bit (tb8) and a stop bit (0). the 9th bit received is put into rb8. the baud rate is programmable to 1/32 or 1/64 of the oscillator frequency, which is determined by the smod bit in pcon sfr. transmission begins with a write to sbuf. the serial data is br ought out on to txd pin at c1 following the first roll - over of the divide by 16 counter. the next bit is placed on txd pin at c1 following the next rollover of the divide by 16 counter. thus the transmission is synchronized to the divide by 16 counters, an d not directly to the write to sbuf signal. after all 9 bits of data are transmitted, the stop bit is transmitted. the ti flag is set in the c1 state after the stop bit has been put out on txd pin. this will be at the 11th rollover of the divide by 16 coun ters after a write to sbuf. reception is enabled only if ren is high. the serial port actually starts the receiving of serial data, with the detection of a falling edge on the rxd pin. the 1 - to - 0 detector continuously monitors the rxd line, sampling it at the rate of 16 times the selected baud rate. when a falling edge is detected, the divide by 16 counters is immediately reset. this helps to align the bit boundaries with the rollovers of the divide by 16 counters. the 16 states of the counter effectively d ivide the bit time into 16 slices. the bit detection is done on a best of three bases. the bit detector samples the rxd pin, at the 8th, 9th and 10th counter states. by using a majority 2 of 3 voting system, the bit value is selected. this is done to impro ve the noise rejection feature of the serial port. 1/2 1/16 tx clock rx clock ti ri tx shift rx start rx shift load sbuf smod clock sin d8 sbuf read sbuf internal data bus serial controllor clock load parin tx start internal data bus sbuf write to sout transmit shift register serial interrupt txd rxd parout rb8 start stop 0 1 bit detector 1-to-0 detector sample 1/16 0 clock/2 1 d8 tb8 receive shift register figure 17- 3 : serial port mode 2 if the first bit detected after the falling edge of rxd pin, is not 0, then this indicates an i nvalid start bit, and the reception is immediately aborted. the serial port again looks for a falling edge in the rxd line. if a valid start bit is detected, then the rest of the bits are also detected and shifted into the sbuf. preliminary N79E875 data s heet publication release date: april 13, 2009 - 115 - revision a02 after shifting in 9 data bi ts, there is one more shift to do, after which the sbuf and rb8 are loaded and ri is set. however certain conditions must be met before the loading and setting of ri can be done. 1. ri must be 0 and 2. either sm2 = 0, or the received stop bit = 1. if these conditions are met, then the stop bit goes to rb8, the 8 data bits go into sbuf and ri is set. otherwise the received frame may be lost. after the middle of the stop bit, the receiver goes back to looking for a 1 - to - 0 transition on the rxd pin. 17.4 mode 3 thi s mode is similar to mode 2 in all respects, except that the baud rate is programmable. the user must first initialize the serial related sfr scon before any communication can take place. this involves selection of the mode and baud rate. the timer 1 shoul d also be initialized if modes 1 and 3 are used. in all four modes, transmission is started by any instruction that uses sbuf as a destination register. reception is initiated in mode 0 by the condition ri = 0 and ren = 1. this will generate a clock on the txd pin and shift in 8 bits on the rxd pin. reception is initiated in the other modes by the incoming start bit if ren = 1. the external device will start the communication by transmitting the start bit. 1/2 1/16 tx clock rx clock ti ri tx shift rx start rx shift load sbuf smod clock sin d8 sbuf read sbuf internal data bus serial controllor clock load parin tx start internal data bus sbuf write to sout transmit shift register serial interrupt txd rxd parout rb8 start stop 0 1 bit detector 1-to-0 detector sample 1/16 0 1 d8 tb8 timer 1 overflow receive shift register figure 17- 4 : serial port mode 3 preliminary N79E875 data s heet - 116 - sm0 sm1 mode type baud clock frame size start bit stop bit 9th bit function 0 0 0 synch. 4 or 12 tclks 8 bits no no none 0 1 1 asynch. timer 1 10 bits 1 1 none 1 0 2 asynch. 32 or 64 tclks 11 b its 1 1 0, 1 1 1 3 asynch. timer 1 11 bits 1 1 0, 1 figure 17- 5 : serial ports modes 17.5 framing error detection a frame error occurs when a valid stop bit is not detected. this could indicate incorrect serial d ata communication. typically the frame error is due to noise and contention on the serial communication line. N79E875 series have the capability to detect such framing errors and set a flag which can be checked by software. the frame error fe bit is locate d in scon.7. this bit is normally used as sm0 in the standard 8051 family. however, it serves a dual function and is called sm0/fe. there are actually two separate flags, one for sm0 and the other for fe. the flag that is actually accessed as scon.7 is det ermined by smod0 (pcon.6) bit. when smod0 is set to 1, then the fe flag is indicated in sm0/fe. when smod0 is set to 0, then the sm0 flag is indicated in sm0/fe. the fe bit is set to 1 by hardware but must be cleared by software. note that smod0 must be 1 while reading or writing to fe. if fe is set, then any following frames received without any error will not clear the fe flag. the clearing has to be done by software. 17.6 multiprocessor communications multiprocessor communications makes use of the 9th data bi t in modes 2 and 3. the ri flag is set only if the received byte corresponds to the given or broadcast address. this hardware feature eliminates the software overhead required in checking every received address, and greatly simplifies the software programm er task. in the multiprocessor communication mode, the address bytes are distinguished from the data bytes by transmitting the address with the 9th bit set high. when the master processor wants to transmit a block of data to one of the slaves, it first sen ds out the address of the targeted slave (or slaves). all the slave processors should have their sm2 bit set high when waiting for an address byte. this ensures that they will be interrupted only by the reception of an address byte. the automatic address r ecognition feature ensures that only the addressed slave will be interrupted. the address comparison is done in hardware not software. the addressed slave clears the sm2 bit, thereby clearing the way to receive data bytes. with sm2 = 0, the slave will be i nterrupted on the reception of every single complete frame of data. the unaddressed slaves will be unaffected, as they will be still waiting for their address. in mode 1, the 9th bit is the stop bit, which is 1 in case of a valid frame. if sm2 is 1, then r i is set only if a valid frame is received and the received byte matches the given or broadcast address. the master processor can selectively communicate with groups of slaves by using the given address. all the slaves can be addressed together using the b roadcast address. the addresses for each slave are defined by the saddr and saden sfrs. the slave address is an 8 - bit value specified in the saddr sfr. the saden sfr is actually a mask for the byte value in saddr. if a bit position in saden is 0, then the corresponding bit position in saddr is don't care. only those bit positions in saddr whose corresponding bits in saden are 1 are used to obtain the given address. this gives preliminary N79E875 data s heet publication release date: april 13, 2009 - 117 - revision a02 the user flexibility to address multiple slaves without changing the slave address in saddr. the following example shows how the user can define the given address to address different slaves. slave 1: saddr 1010 0100 saden 1111 1010 given: 1010 0x0x slave 2: saddr 1010 0111 saden 1111 1001 given : 1010 0xx1 the given address for slave 1 and 2 differ in the lsb. for slave 1, it is don't care, while for slave 2 it is 1. thus to communicate only with slave 1, the master must send an address with lsb = 0 (1010 0000). similarly the bit 1 position is 0 for slave 1 and don't care for sla ve 2. hence to communicate only with slave 2 the master has to transmit an address with bit 1 = 1 (1010 0011). if the master wishes to communicate with both slaves simultaneously, then the address must have bit 0 = 1 and bit 1 = 0. the bit 3 position is do n't care for both the slaves. this allows two different addresses to select both slaves (1010 0001 and 1010 0101). the master can communicate with all the slaves simultaneously with the broadcast address. this address is formed from the logical or of the s addr and saden sfrs. the zeros in the result are defined as don't cares. in most cases the broadcast address is ffh. in the previous case, the broadcast address is (1111111x) for slave 1 and (11111111) for slave 2. the saddr and saden sfrs are located at a ddress a9h and b9h respectively. on reset, these two sfrs are initialized to 00h. this results in given address and broadcast address being set as xxxx xxxxb (i.e. all bits don't care). this effectively removes the multiprocessor communications feature, si nce any selectivity is disabled. preliminary N79E875 data s heet - 118 - 18 i2c serial control the i2c bus uses two wires (sda and scl) to transfer information between devices connected to the bus. the main features of the bus are: ? bidirectional data transfer between masters and slaves ? multi - maste r bus (no central master) ? arbitration between simultaneously transmitting masters without corruption of serial data on the bus ? serial clock synchronization allows devices with different bit rates to communicate via one serial bus ? serial clock synchronizati on can be used as a handshake mechanism to suspend and resume serial transfer ? built - in a 14 - bit time - out counter will request the i2c interrupt if the i2c bus hangs up and timer - out counter overflows. ? the i2c port pins, sda and scl are permanently in open - drain type. external pull - up are needed for high output t buf stop sda scl start t hd ; sta t low t hd ; dat t high t f t su ; dat repeated start t su ; sta t su ; sto stop t r figure 18- 1 : i2c bus timing 18.1 i2c port the device?s on - chip i 2 c logic provides the serial interface that meets the i 2 c bus standard mode specification. the i2c port handles byte transfers autonomously. to enable this port, the bit ens i in i2con should be set to '1'. the i2c h/w interfaces to the i2c bus via two pins: sda (p1.6, serial data line) and scl (p1.5, serial clock li ne). pull up resistor s are needed on pin p1.5 and p1.6 for i2c operation as these are open drain pins. when the i/o pins are used as i2c port, user must set the pins to logic high in advance. preliminary N79E875 data s heet publication release date: april 13, 2009 - 119 - revision a02 18.2 sfr for i2c function the cpu interfaces to the sio port throug h the following six special function registers: i2con (control register, c0h), i2status (status register, bdh), i2dat (data register, bch), i2addr (address registers, c1h), i2clk (clock rate register beh) and i2toc (time - out counter register, bfh). when i2 c port is enabled by setting ens i to high, the internal states will be controlled by i2con and i2c logic hardware. once a new status code is generated and stored in i2status, the i2c interrupt flag (si) will be set automatically. if both ea and ei2c are al so in logic high, the i2c interrupt is requested. the 5 most significant bits of i2status stores the internal state code, the lowest 3 bits are always zero and the content keeps stable until si is cleared by software. 18.2.1 i2c address registers, i2addr i2c port is equipped with one slave address register. the contents of the register are irrelevant when i2c is in master mode. in the slave mode, the seven most significant bits must be loaded with the mcu?s own slave address. the i2c hardware will react if the con tents of i2addr are matched with the received slave address. the i2c ports support the ?general call? function. if the gc bit is set the i2c port1 hardware will respond to general call address (00h). clear gc bit to disable general call function. when gc b it is set, the i2c is in slave mode, it can be received the general call address by 00h after master send general call address to i2c bus, then it will follow status of gc mode. if it is in master mode, the aa bit must be cleared when it will send general call address of 00h to i2c bus. symbol definition address msb bit address, symbol lsb reset i2addr i2c address1 c1h addr.7 addr.6 addr.5 addr.4 addr.3 addr.2 addr.1 gc x xxx xxx0b 18.2.2 i2c data register, i2dat this register contains a byte of serial data to b e transmitted or a byte which has just been received. the cpu can read from or write to this 8 - bit directly addressable sfr while it is not in the process of shifting a byte. this occurs when sio is in a defined state and the serial interrupt flag (si) is set. data in i2 dat remains stable as long as si bit is set. while data is being shifted out, data on the bus is simultaneously being shifted in; i2 dat always contains the last data byte present on the bus. thus, in the event of arbitration lost , the transi tion from master transmitter to slave receiver is made with the correct data in i2 dat. i2dat and the acknowledge bit form a 9 - bit shift register, the acknowledge bit is controlled by the sio hardware and cannot be accessed by the cpu. serial data is shifte d through the acknowledge bit into i2dat on the rising edges of serial clock pulses on the scl line. when a byte has been shifted into i2dat, the serial data is available in i2dat, and the acknowledge bit (ack or nack) is returned by the control logic duri ng the ninth clock pulse. serial data is shifted out from i2dat on the falling edges of scl clock pulses, and is shifted into i2dat on the rising edges of scl clock pulses. i 2 dat . 7 i 2 dat . 6 i 2 dat . 5 i 2 dat . 4 i 2 dat . 3 i 2 dat . 2 i 2 dat . 1 i 2 dat . 0 i 2 c data register : shifting direction figure 18- 2 i2c data shifting direction preliminary N79E875 data s heet - 120 - symbol definition address msb bit address, symbol lsb reset i2dat i2c data register bch i2dat.7 i2dat.6 i2dat.5 i2dat.4 i2dat.3 i2dat.2 i2dat.1 i2dat.0 x xxx xxxxb 18.2.3 i2c control register, i2con the cpu can read from an d write to this 8 - bit, directly addressable sfr. two bits are affected by hardware: the si bit is set when the i2c hardware requests a serial interrupt, and the sto bit is cleared when a stop condition is present on the bus. the sto bit is also cleared whe n ens i = "0". ens i set to e nable i2c serial function block. when ens=1 the i2c serial function enables. the port latches of sda1 and scl1 must be set to logic high. st a i2c start flag. setting sta to logic 1 to enter master mode, the i2c hardware sends a s tart or r epeat start condition to bus when the bus is free. sto i2c stop flag. in master mode, setting sto to transmit a stop condition to bus then i2c hardware will check the bus condition if a stop condition is detected this flag will be cleared by hard ware automatically. in a slave mode, setting sto resets i2c hardware to the defined ? not addressed ? slave mode. this means it is no longer in the slave receiver mode to receive data from the master transmit device. si i2c interrupt flag. when a new sio sta te is present in the i2status register, the si flag is set by hardware, and if the ea and ei2c bits are both set, the i2c interrupt is requested. si must be cleared by software. aa assert acknowledge control bit . when aa=1 prior to address or data received , an acknowledge d ( low level to sda) will be returned during the acknowledge clock pulse on the scl line when 1.) a slave is acknowledging the address sent from master, 2.) the receiver devices are acknowledging the data sent by transmitter. when aa=0 prio r to address or data received, a not acknowledged (high level to sda) will be returned during the acknowledge clock pulse on the scl line. symbol definition address msb bit address, symbol lsb reset i2con i2c control register c0h (cf) - (ce) ens i (cd) sta (cc) sto (cb) si (ca) aa (c9) - (c8) - x000 00xxb 18.2.4 i2c status register, i2status i2status is an 8 - bit read - only register. the three least significant bits are always 0. the five most significant bits contain the status code. there are 26 possible statu s codes. when i2status contains f8h, no serial interrupt is requested. all other i2status values correspond to defined sio states. when each of these states is entered, a status interrupt is requested (si = 1). a valid status code is present in i2status on e machine cycle after si is set by hardware and is still present one machine cycle after si has been reset by software. in addition, state 00h stands for a bus error. a bus error occurs when a start or stop condition is present at an illegal position in th e format frame. examples of illegal positions are during the serial transfer of an address byte, a data byte or an acknowledge bit. to recover i2c from bus error, sto should be set and si should be clear to enter not address ed slave mode. then clear sto to release bus and to wait new communication. i2c bus can not recognize stop condition during this action when bus error occur s . symbol definition address msb bit address, symbol lsb reset i2status i2c status register bdh b 7 b 6 b 5 b 4 b 3 b 2 b 1 b 0 1111 1 000b preliminary N79E875 data s heet publication release date: april 13, 2009 - 121 - revision a02 18.2.5 i2c clock baud rate bits, i2clk the data baud rate of i2c is determines by i2clk register when sio is in a master mode. it is not important when sio is in a slave mode. in the slave modes, sio will automatically synchronize with any clock frequency up t o 400 khz from master i2c device. the data baud rate of i2c setting is data baud rate of i2c = fcpu / (4x (i2clk+1) ) . if fcpu=16mhz, the i2clk = 40(28h), so data baud rate of i2c = 16mhz/( 4 x (40 +1)) = 97.5k bits/sec. the block diagram is as below figure. sy mbol definition address msb bit address, symbol lsb reset i2clk i2c clock rate beh i2clk.7 i2clk.6 i2clk.5 i2clk.4 i2clk.3 i2clk.2 i2clk.1 i2clk.0 0000 0000b 18.2.6 i2c time - out counter register, i2toc there is a 14 - bit time - out counter which can be sued to de al with the i2c bus hang - up. i f the time - out counter is enabled, the counter starts up counting until it overflows(tif=1) and request s i2c interrupt from cpu or stops counting by clearing enti to 0. when time - out counter is enabled, setting flag si to high will reset counter and re - start up counting after si is cleared. if i2c bus hangs up, it causes the i2status and flag si are not updated for a period, the 14 - bit time - out counter may overflow and acknowledge cpu the i2c interrupt. refer to figure 18 - 3 for the 14 - bit time - out counter. 1 0 fcpu 1 / 4 14 - bits counter tif clear counter enti si div 4 ens 1 to i 2 c interrupt enable si figure 18- 3 : i2c time - out count block diagram symbol definition address msb bit address, symbol lsb res et i2toc i2c time - out counter register bfh - - - - - enti div4 tif 0000 0000b 18.3 modes of operation the on - chip i2c ports support five operation modes, master transmitter, master receiver, slave transmitter, slave receiver, and gc call. in a given applicat ion, i2c port may operate as a master or as a slave. in the slave mode, the i2c port hardware looks for its own slave address and the general call address. if one of these addresses is detected, and if the slave is willing to receive or transmit data from/ to master(by setting the aa bit), acknowledge pulse will be transmitted out on the 9th clock, hence an interrupt is requested on both master and slave devices if interrupt is enabled. when the microcontroller wishes to become the bus master, the hardware w aits until the bus is free before the master mode is entered so that a possible slave action is not interrupted. if bus arbitration is lost in the master mode, i2c port switches to the preliminary N79E875 data s heet - 122 - slave mode immediately and can detect its own slave address in the same serial transfer. 18.3.1 master transmitter mode serial data output through sda while scl outputs the serial clock. the first byte transmitted contains the slave address of the receiving device (7 bits) and the data direction bit. in this case the data direction bit (r/w) will be logic 0, and it is represented by ?w? in the flow diagrams. thus the first byte transmitted is sla+w. serial data is transmitted 8 bits at a time. after each byte is transmitted, an acknowledge bit is received. start and stop conditions a re output to indicate the beginning and the end of a serial transfer. 18.3.2 master receiver mode in this case the data direction bit (r/w) will be logic 1, and it is represented by ?r? in the flow diagrams. thus the first byte transmitted is sla+r. serial data i s received via sda while scl outputs the serial clock. serial data is received 8 bits at a time. after each byte is received, an acknowledge bit is transmitted. start and stop conditions are output to indicate the beginning and end of a serial transfer. 18.3.3 sl ave receiver mode serial data and the serial clock are received through sda and scl. after each byte is received, an acknowledge bit is transmitted. start and stop conditions are recognized as the beginning and end of a serial transfer. address recognition is performed by hardware after reception of the slave address and direction bit. 18.3.4 slave transmitter mode the first byte is received and handled as in the slave receiver mode. however, in this mode, the direction bit will indicate that the transfer directio n is reversed. serial data is transmitted via sda while the serial clock is input through scl. start and stop conditions are recognized as the beginning and end of a serial transfer. 18.4 data transfer flow in five operating modes the five operating modes are: master/transmitter, master/receiver, slave/transmitter, slave/receiver and gc call. bits sta, sto and aa in i2con register will determine the next state of the sio hardware after si flag is cleared. upon complexion of the new action, a new status code wil l be updated and the si flag will be set. if the i2c interrupt control bits (ea and ei2c) are enable, appropriate action or software branch of the new status code can be performed in the interrupt service routine. data transfers in each mode are shown in t he following figures. *** legend for the following five figures: preliminary N79E875 data s heet publication release date: april 13, 2009 - 123 - revision a02 08 h a start has been transmitted . (sta ,sto ,si, aa )=( 0,0 ,0 ,x ) sla + w will be transmitted ; ack bit will be received . 18 h sla + w has been transmitted ; ack has been received . last state last action is done next setting in i 2 con expected next action next action is done new state software ' s access to i 2 dat with respect to " expected next action ": software should load the data byte ( to be transmitted ) into i 2 dat before new i 2 con setting is done . ( 1 ) data byte will be transmitted : ( 2 ) sla + w ( r ) will be transmitted : software should load the sla + w / r ( to be transmitted ) into i 2 dat before new i 2 con setting is done . ( 3 ) data byte will be received : software can read the received data byte from i 2 dat while a new state is entered . figure 18- 4 legend for the following four figures preliminary N79E875 data s heet - 124 - 08h a start has been transmitted. (sta,sto,si,aa)=(0,0,0,x) sla+w will be transmitted; ack bit will be received. set sta to generate a start. 18h sla+w will be transmitted; ack bit will be received. or 20h sla+w will be transmitted; not ack bit will be received. (sta,sto,si,aa)=(1,0,0,x) a repeated start will be transmitted; (sta,sto ,si,aa )=(0,0,0,x) data byte will be transmitted; ack will be received. (sta,sto,si,aa)=(0,1,0,x) a stop will be transmitted; sto flag will be reset. send a stop (sta,sto,si,aa)=(1,1,0,x) a stop followed by a start will be transmitted; sto flag will be reset. send a stop followed by a start 28h data byte in s1dat has been transmitted; ack has been received. or 30h data byte in s1dat has been transmitted; not ack has been received. 10h a repeated start has been transmitted. (sta,sto,si,aa)=(0,0,0,x) sla+r will be transmitted; ack bit will be transmitted; sio1 will be switched to mst/rec mode. 38h arbitration lost in sla+r/w or data byte. (sta,sto,si,aa)=(0,0,0,x ) i2c bus will be release; not address slv mode will be entered. (sta,sto,si,aa)=(1,0,0,x) a start will be transmitted when the bus becomes free. send a start when bus becomes free enter naslave from slave mode (c) to master/receiver (a) from master/receiver (b) figure 18- 5 master transmitter mode preliminary N79E875 data s heet publication release date: april 13, 2009 - 125 - revision a02 08h a start has been transmitted. (sta ,sto ,si ,aa )=(0 ,0 ,0 ,x ) sla+r will be transmitted; ack bit will be received. set sta to generate a start. 40h sla+r has been transmitted; ack has been received. (sta,sto ,si, aa)=(0, 1,0, x) a stop will be transmitted; sto flag will be reset. (sta,sto,si, aa)=(1, 1,0, x) a stop followed by a start will be transmitted; sto flag will be reset. (sta,sto,si, aa)=(0,0,0 ,0) data byte will be received; not ack will be returned. send a stop (sta,sto ,si, aa)=(0 ,0, 0,1 ) data byte will be received; ack will be returned. 10h a repeated start has been transmitted. (sta,sto,si,aa)=(0, 0,0, x) sla+r will be transmitted; ack bit will be transmitted; sio1 will be switched to mst/rec mode. (sta,sto,si ,aa)=(1, 0,0,x ) a start will be transmitted; when the bus becomes free (sta,sto,si,aa)=(0,0 ,0,x) i2c bus will be release; not address slv mode will be entered. enter naslave from master/transmitter (a) to master/transmitter (b) from slave mode (c ) 48h sla+ r has been transmitted; not ack has been received. 58h data byte has been received; not ack has been returned. 50h data byte has been received; ack has been returned. send a stop followed by a start 38h arbitration lost in not ack bit. send a start when bus becomes free (sta,sto ,si,aa )=(1,0 ,0,x ) a repeated start will be transmitted; figure 18- 6 master receiver mode preliminary N79E875 data s heet - 126 - set aa a8h own sla+r has been received; ack has been return. or b0h arbitration lost sla+r/w as master; own sla+r has been received; ack has been return. (sta,sto,si,aa)=(1,0,0,1) switch to not address slv mode; own sla will be recognized; a start will be transmitted when the bus becomes free. (sta,sto,si,aa)=(0,0,0,0) last data will be transmitted; ack will be received. (sta,sto,si,aa)=(0,0,0,1) data byte will be transmitted; ack will be received. send a start when bus becomes free c8h last data byte in s1dat has been transmitted; ack has been received. (sta,sto,si,aa)=(1,0,0,0) switch to not addressed slv mode; no recognition of own sla; a start will be transmitted when the becomes free. (sta,sto,si,aa)=(0,0,0,1) switch to not addressed slv mode; own sla will be recognized. (sta,sto,si,aa)=(0,0,0,0) switch to not addressed slv mode; no recognition of own sla. enter naslave to master mode (c) (sta,sto,si,aa)=(0,0,0,0) last data byte will be transmitted; ack will be received. (sta,sto,si,aa)=(0,0,0,1) data byte will be transmitted; ack will be received. c0h data byte or last data byte in s1dat has been transmitted; not ack has been received. b8h data byte in s1dat has been transmitted; ack has been received. a0h a stop or repeated start has been received while still addressed as slv/trx. figure 18- 7 slave transmitter mode preliminary N79E875 data s heet publication release date: april 13, 2009 - 127 - revision a02 set aa 60h own sla+w has been received; ack has been return. or 68h arbitration lost sla+r/ w as master; own sla+w has been received; ack has been return. (sta,sto,si, aa)=(1,0,0, 1) switch to not address slv mode; own sla will be recognized; a start will be transmitted when the bus becomes free. (sta,sto ,si,aa )=(0,0, 0,0) data will be received; not ack will be returned. (sta,sto,si,aa )=(0,0 ,0,1) data will be received; ack will be returned. send a start when bus becomes free 88h previously addressed with own sla address; not ack has been returned. (sta,sto,si,aa )=(1,0,0,0 ) switch to not addressed slv mode; no recognition of own sla; a start will be transmitted when the becomes free. (sta,sto,si, aa)=(0,0,0, 1) switch to not addressed slv mode; own sla will be recognized. (sta,sto,si,aa )=(0,0,0,0 ) switch to not addressed slv mode; no recognition of own sla. enter naslave to master mode (c) (sta,sto,si ,aa)=(0 ,0,0, 0) data byte will be received; not ack will be returned. (sta,sto ,si,aa )=(0,0, 0,1) data byte will be received; ack will be returned. 80h previously addressed with own sla address; data has been received; ack has been returned. a0h a stop or repeated start has been received while still addressed as slv/rec. figure 18- 8 slave receiver mode preliminary N79E875 data s heet - 128 - set aa 70h reception of the general call address and one or more data bytes; ack has been return. or 78h arbitration lost sla+r/ w as master; and address as sla by general call; ack has been return. (sta,sto ,si,aa)=(1,0,0,1) switch to not address slv mode; own sla will be recognized; a start will be transmitted when the bus becomes free. (sta,sto,si,aa )=(x,0, 0,0) data will be received; not ack will be returned. (sta,sto,si,aa)=(x,0,0, 1) data will be received; ack will be returned. send a start when bus becomes free 98h previously addressed with general call; data byte has been received; not ack has been returned. (sta,sto,si,aa)=(1,0 ,0,0) switch to not addressed slv mode; no recognition of own sla; a start will be transmitted when the becomes free. (sta,sto,si ,aa)=(0 ,0,0, 1) switch to not addressed slv mode; own sla will be recognized. (sta,sto,si,aa)=(0,0,0 ,0) switch to not addressed slv mode; no recognition of own sla. enter naslave to master mode (c) (sta,sto ,si, aa)=(x ,0, 0,0 ) data byte will be received; not ack will be returned. (sta,sto,si,aa)=(x,0,0,1) data byte will be received; ack will be returned. 90h previously addressed with general call; data has been received; ack has been returned. a0h a stop or repeated start has been received while still addressed as slv/rec. figure 18- 9 gc mode preliminary N79E875 data s heet publication release date: april 13, 2009 - 129 - revision a02 19 serial pheripheral interface (spi) 19.1 general descriptions N79E875 series consist of spi block to support high speed serial communication. it?s capable of supporting data transfer rates of 2.5 mbit/s, for 40mhz bus frequency. this device?s spi support the following features; ? ma ster and slave mode. ? slave select output. ? programmable serial clock?s polarity and phase. ? receive double buffered data register. ? msb first(default) or lsb first selectable . ? write collision detection. ? transfer complete interrupt. 19.2 block descriptions the foll owing figure shows spi block diagram. it provides an overview of spi architecture in this device. the main blocks of spi are spi register blocks, control logics, baud rate control, and pin control logics; shift register and read data buffer . it is single buffered in the transmit direction and double buffered in the receive direction. transmit data cannot be written to the shifter until the previous transfer is complete. when the spif set, user will not be able to write to the shift register. user has to clear the spif before writing to the shift register. receive logics consist of parallel read data buffer so the shifter is free to accept a second data, as the first received data will be transferred to the read data buffer. spi control block . this provid e control functions to configure the device for spi enable, master or slave, clock phase and polarity, msb/lsb access first selection, and slave select output enable. baud rate control . this control logics divide cpu clock to 4 different selectable clocks (1/16, 1/32, 1/64 and 1/128). spr1 spr0 divider baud rate 0 0 16 2.5 mbit/s 0 1 32 1.25 mbit/s 1 0 64 625 kbit/s 1 1 128 312.5 kbit/s table 19- 1 spi baud rate selection (based on 40 mhz bus clock) spi registers . there are three spi registers to support its operations, they are; ? spi control registers (spcr) ? spi status registers (spsr) ? spi data register (spdr) preliminary N79E875 data s heet - 130 - these registers provide control, status, data storage functions and baud rate select ion control. detail bit descriptions are found at sfr section. pin control logic . controls behavior of spi interface pins. divider /16 /64 / 128 select spi control spi status register 8- bit shift register read data buffer clock logic spi control register s pif w col spi interrupt request clock s m m s s p r 1 s p r 0 msb lsb mstr spe internal data bus internal mcu clock l s b f e m s t r c p o l c p h a s p e s p r 1 e s p i s p r 1 ss o e m o d f s piov f drs s m s t r s p e s s o e miso mosi spclk __ ss dr ss p i n c o n t r o l l o g i c /32 figure 19- 1 spi block diagram preliminary N79E875 data s heet publication release date: april 13, 2009 - 131 - revision a02 19.3 functional description s 19.3.1 master mode the device can configure the spi to operate as a master or as a slave, through mstr bit. when the mstr bit is set, master mode is selected, when mstr bit is cleared, slave mode is selected. during master mode, only master spi device can initi ate transmission. a transmission begins by writing to the master spdr register. the bytes begin shifting out on mosi pin under the control of spclk. the master places data on mosi line a half - cycle before spclk edge that the slave device uses to latch the data bit. the /ss must stay low before data transactions and stay low for the duration of the transactions. spclk cycles spclk (output, cpol=0) mosi/miso /ss (output to slave) spif master writes to spdr: 1. /ss asserted. 2. during master transmit, data is shifting out through mosi. during master receive, data is shifting in through miso. 3. spif asserted at the end of transmission. 4. /ss negated. note: when cpha = 0, /ss output must go high between successive spi characters. when cpol = 0, spclk idle low. 1 2 3 4 5 6 7 8 msb 6 5 4 3 2 1 lsb 1 2 3 4 master transfer in progress figure 19- 2 master mode transmission (cpol = 0, cpha = 0) preliminary N79E875 data s heet - 132 - spclk cycles spclk (output, cpol=1) mosi/miso /ss (output to slave) spif master writes to spdr: 1. /ss asserted. 2. during master transmit, data is shifting out through mosi. during master receive, data is shifting in through miso. 3. spif asserted at the end of transmission. 4. /ss negated. note: when cpha = 0, /ss output must go high between successive spi characters. when cpol = 1, spclk idle high. 1 2 3 4 5 6 7 8 msb 6 5 4 3 2 1 lsb 1 2 3 4 master transfer in progress figure 19- 3 master mode transmission (cpol = 1, cpha = 0) preliminary N79E875 data s heet publication release date: april 13, 2009 - 133 - revision a02 spclk cycles spclk ( output , cpol = 0 ) mosi / miso / ss ( output to slave ) spif master writes to spdr : 1 . / ss asserted . 2 . during master transmit , data is shifting out through mosi . during master receive , data is shifting in through miso . 3 . spif asserted at the end of transmission . 4 . / ss negated . note : when cpha = 1 , / ss output can stay low between successive spi characters . when cpol = 0 , spclk idle low . 1 2 3 4 5 6 7 8 msb 6 5 4 3 2 1 lsb 1 master transfer in progress 2 4 3 figure 19- 4 master mode transmission (cpol = 0, cph a = 1) preliminary N79E875 data s heet - 134 - spclk cycles spclk ( output , cpol = 1 ) mosi / miso / ss ( output to slave ) spif master writes to spdr : 1 . / ss asserted . 2 . during master transmit , data is shifting out through mosi . during master receive , data is shifting in through miso . 3 . spif asserted at the end of transmission . 4 . / ss negated . note : when cpha = 1 , / ss output can stay low between successive spi characters . when cpol = 1 , spclk idle high . 1 2 3 4 5 6 7 8 6 5 4 3 2 1 lsb 1 master transfer in progress 4 3 msb 2 figure 19- 5 master mode transmission (cpol = 1, cpha = 1) 19.3.2 slave mode when in slave mode, the spclk pin becomes input and it will be clock by another master spi device. the /ss pin also becomes input. similarly, before data transmissions occurs, and remain low until the transmission completed. if /ss goes high, the spi is forced into idle state. data flows from master to slave on mosi pin and flows from slave to master on miso pin. the spdr is used when transmitting or receiving data on the serial bus. only a write to this register initiates transmission or reception of a byte, and this only occurs in the master device. at the completion of transferring a byte of data, t he spif status bit is set in both the master and slave devices. a read of the spdr is actually a read of a buffer. to prevent an overrun and the loss of the byte that caused the overrun, the first spif must be cleared by the time a second transfer of data from the shift register to the read buffer is initiated. preliminary N79E875 data s heet publication release date: april 13, 2009 - 135 - revision a02 spclk cycles spclk (input, cpol=0) mosi/miso /ss (input) spif slave writes to spdr: 1. /ss asserted. 2. during slave transmit, data is shifting out through miso. during slave receive, data is shifting in through mosi. 3. spif asserted at the end of transmission. 4. /ss negated. note: when cpha = 0, /ss input must go high between successive spi characters. when cpol = 0, spclk idle low. 1 2 3 4 5 6 7 8 msb 6 5 4 3 2 1 lsb 1 2 3 4 slave transfer in progress figure 19- 6 slave mode transmission (cpol = 0, cpha = 0) preliminary N79E875 data s heet - 136 - spclk cycles spclk (input, cpol=1) mosi/miso spif slave writes to spdr: 1. /ss asserted. 2. during slave transmit, data is shifting out through miso. during slave receive, data is shifting in through mosi. 3. spif asserted at the end of transmission. 4. /ss negated. note: when cpha = 0, /ss input must go high between successive spi characters. when cpol = 1, spclk idle high. 1 2 3 4 5 6 7 8 msb 6 5 4 3 2 1 lsb 1 2 3 4 slave transfer in progress figure 19- 7 slave mode transmission (cpol = 1, cpha = 0) preliminary N79E875 data s heet publication release date: april 13, 2009 - 137 - revision a02 spclk cycles spclk (input, cpol=0) mosi/miso /ss (input) spif slave writes to spdr: 1. /ss asserted. 2. during slave transmit, data is shifting out through miso. during slave receive, data is shifting in through mosi. 3. spif asserted at the end of transmission. 4. /ss negated. note: when cpha = 1, /ss input can stay low between successive spi characters. when cpol = 0, spclk idle low. 1 2 3 4 5 6 7 8 1 3 4 slave transfer in progress msb 6 5 4 3 2 1 lsb 2 figure 19- 8 slave mode transmission (cpol = 0, cpha = 1) preliminary N79E875 data s heet - 138 - spclk cycles spclk (input, cpol=1) mosi/miso /ss (input) spif slave writes to spdr: 1. /ss asserted. 2. during slave transmit, data is shifting out through miso. during slave receive, data is shifting in through mosi. 3. spif asserted at the end of transmission. 4. /ss negated. note: when cpha = 1, /ss input can stay low between successive spi characters. when cpol = 1, spclk idle high. 1 2 3 4 5 6 7 8 1 3 4 slave transfer in progress msb 6 5 4 3 2 1 lsb 2 figure 19- 9 slave mode transmission (cpol = 1, cpha = 1) 19.3.3 slave select the slave select (/ss) input of a slave device must be externally asserted before a master device can exchange data with the slave device. /ss must be low b efore data transactions and must stay low for the duration of the transaction. the /ss line of the master must be held high. the other three lines are dedicated to the spi whenever the serial peripheral interface is on. the state of the master and slave cpha bits affects the operation of /ss. cpha settings should be identical for master and slave. when cpha = 0, the shift clock is the or of /ss with sck. in this clock phase mode, /ss must go high between successive characters in an spi message. when cpha = 1, /ss can be left low between successive spi characters. in cases where there is only one spi slave mcu, its /ss line can be tied to vss as long as only cpha = 1 clock mode is used. 19.3.4 slave select output enable available in master mode only, the /ss outpu t is enabled with the ssoe bit in the spcr register. the /ss output pin is connected to the /ss input pin of the slave device. the /ss output automatically goes low for each transmission when selecting external device and it goes high during each idling st ate to deselect external devices. drss ssoe master mode slave mode 0 0 /ss input (w ith mode fault) . see section spi i/o mode section for detail. /ss input (not affected by ssoe) preliminary N79E875 data s heet publication release date: april 13, 2009 - 139 - revision a02 0 1 r eserved /ss input (not affected by ssoe) 1 0 /ss general purpose i/o ( no mode fault) /ss input (not affected by ssoe) 1 1 /ss output (no mode fault) /ss input (not affected by ssoe) table 19- 2 /ss output during master mode (with ssoe=drss= 0), mode fault will be set if /ss pi n is detected low. when mode fault is detected hardware will clear mstr bit and spe bit in the meantime it will also generated interrupt request, if espi is enabled. modf spif ssoe mstr ea espi spi interrupt request ss drss spiovf figure 19- 10 spi interrupt request 19.3.5 spi i/o pins mode when spi is disabled (spe = 0) the corresponding i/o is following the setting determined by port mode setting (sfr p2m1 & p2m2). when spi is enabled (spe = 1) the spi pins i/o mode follow the below table. for /ss p in it is always at quasi - bidirectional mode whether it is configured as master or slave. miso mosi clk /ss master input output output output [1] : drss= 1 ,ssoe= 1 input : drss= 0 , ssoe= 0 slave output [2] during /ss = low else input mode input input input tabl e 19- 3 spi i/o pins mode input = quasi - bidirectional mode; output = push - pull mode output [1] = this output mode in /ss is quasi - bidirectional output mode. master needs to detect mode fault during master outp uts /ss low. output [2 ] = in slave mode, miso is in output mode only during the time of /ss =low. otherwise it must keep in input mode (quasi - bidirectional). preliminary N79E875 data s heet - 140 - 19.3.6 programmable serial clock?s phase and polarity the clock polarity spcr.cpol control bit selects a ctive high or active low sck clock, and has no significant effect on the transfer format. the clock phase spcr.cpha control bit selects one of two different transfer protocols by sampling data on odd numbered sck edges or on even numbered sck edges. thus, both these bits enable selection of four possible clock formats to be used by spi system. the clock phase and polarity should be identical for the master spi device and the communicating slave device. when cpha equals 0, the /ss line must be negated and reasserted between each successive serial byte. also, if the slave writes data to the spi data register (spdr) while /ss is low, a write collision error results. when cpha equals 1, the /ss line can remain low between successive transfers. when cpha = 0, data is sample on the first edge of spclk and when cpha = 1 data is sample on the second edge of the spclk. prior to changing cpol setting, spe must be disabled first. 19.3.7 receive double buffered data register this device is single buffered in the transmit di rection and double buffered in the receive direction. this means that new data for transmission cannot be written to the shifter until the previous transfer is complete; however, received data is transferred into a parallel read data buffer so the shifter is free to accept a second serial byte. as long as the first byte is read out of the read data buffer before the next byte is ready to be transferred, no overrun condition occurs. if overrun occur, spiovf is set. second byte serial data cannot be transferr ed successfully into the data register during overrun condition and the data register will remains the value of the previous byte. the figure below shows the receive data timing waveform when overrun occur. data ( n ) progressing data ( n + 1) progressing spif data ( n) data ( n ) spi data register spi shift register data ( n + 2 ) progressing spiovf data ( n+ 2) data ( n) receiving data ( n+ 1) receiving data ( n+ 2) receiveing if spif is not clear , the spiovf will be set , data ( n) will be kept . the data ( n+ 1) will be lost . when data ( n ) is received , the spif will be set . to clear this bit by software . when data ( n+ 2) is received , the spif will be set . figure 19- 11 spi receive data timing waveform 19.3.8 lsb first enable by default, this device transfer the spi data most significant bit first. this device provides a control bit spcr.lsbfe to allow support of transfer of spi data in least significant bit first. preliminary N79E875 data s heet publication release date: april 13, 2009 - 141 - revision a02 19.3.9 write collision detection write collision indicates that an attempt was made to write data to the spdr while a transfer was in progress. spdr is not double buffered in the transmit direction, any writes to spdr cause data to be written directly into the spi shift register. this write corrupts any transfer in progress, a write collision error is generated (wcol will be set). the transfer continues undisturbed, and the write data that caused the error is not written to the shifter . a write collision is normally a slave error because a slave has no control over when a master initiates a transfer. a master knows when a transfer is in progress, so there is no reason for a master to generate a write - collision error, although the spi lo gic can detect write collisions in both master and slave devices. wcol flag is clear by software. 19.3.10 transfer complete interrupt this device consists of an interrupt flag at spsr.spif. this flag will be set upon completion of data transfer with external devi ce, or when a new data have been received and copied to spdr. if interrupt is enable (through espi located at eie2.3), the spi interrupt request will be generated, if global enable is also enabled. spif is a software clear interrupt. 19.3.11 mode fault error ari ses in a multiple - master system when more than one spi device simultaneously tries to be a master. this error is called a mode fault. when the spi system is configured as a master and the /ss input line goes to active low, a mode fault error has occurred ? usually because two devices have attempted to act as master at the same time. in cases where more than one device is concurrently configured as a master, there is a chance of contention between two pin drivers. for push - pull cmos drivers, this contention can cause permanent damage. the mode fault mechanism attempts to protect the device by disabling the drivers. the mstr & spe control bits in the spcr associated with the spi are cleared and an interrupt is generated subject to masking by the espi control b it. other precautions may need to be taken to prevent driver damage. if two devices are made masters at the same time, mode fault does not help protect either one unless one of them selects the other as slave. the amount of damage possible depends on the length of time both devices attempt to act as master. modf bit is set automatically by spi hardware, if the mstr control bit is set and the slave select input pin becomes 0. this condition is not permitted in normal operation. in the case where /ss is set, it is an output pin rather than being dedicated as the /ss input for the spi system. in this special case, the mode fault function is inhibited and modf remains cleared. this flag is cleared by software. the following figures show the sample hardware conn ection for multi - master/slave environment, and flow diagram which shows how s/w handles mode fault. preliminary N79E875 data s heet - 142 - miso mosi sck /ss i/o port 0 1 2 3 i/o port 0 1 2 3 miso mosi sck /ss slave mcu 0 master/slave mmcu1 master/slave mmcu2 miso mosi sck /ss slave mcu 1 miso mosi sck /ss slave mcu 2 miso mosi sck /ss figure 19- 12 spi multi - master slave environment preliminary N79E875 data s heet publication release date: april 13, 2009 - 143 - revision a02 start configuration (master); mstr = 1, spe = 1 ssoe = 0, drss = 0 s/w should configure spr0-1, cpha, cpol, lsbfe accordingly. spi intr? modf? send data? write spdr spif n n n n y y y y ok to reconfigure? spiovf read spdr n missing data. s/w should take appropriate actions here. y a a mmcu1/2 clear spif flag read spdr clear modf flag y n eg. checking /ss line. configure p0[3:0] to fh (input). missing data. s/w should take appropriate actions here. clear spif & spiovf flag mode fault detected spi overflow figure 19- 13 spi multi - master slave s/w flow diagram preliminary N79E875 data s heet - 144 - 20 timed access protect ion in this mcu, some functions are crucial to proper operation of the system like the watchdog timer. if left unprotected, errant co de may write to the watchdog control bits resulting in incorrect operation and loss of control. in order to prevent this, it has a protection scheme which controls the write access to critical bits. this protection scheme is done using a timed access. t her e registers, pdtc0(aeh), dtcnt(abh) and wdcon(d8h) have the timed access protection when cpu has a write access to one of the three registers. in this method, the bits which are to be protected have a timed write enable window. a write is successful only i f this window is active, otherwise the write will be discarded. this write enable window is open for 3 machine cycles if certain conditions are met. after 3 machine cycles, this window automatically closes. the window is opened by writing aah and immediate ly 55h to the timed access (ta) sfr. this sfr is located at address c7h. the suggested code for opening the timed access window is ta reg 0c7h ; define new register ta, located at 0c7h mov ta, #0aah mov ta, #055h when the sof tware writes aah to the ta sfr, a counter is started. this counter waits for 3 machine cycles looking for a write of 55h to ta. if the second write (55h) occurs within 3 machine cycles of the first write (aah), then the timed access window is opened. it re mains open for 3 machine cycles, during which the user may write to the protected bits. once the window closes the procedure must be repeated to access the other protected bits. examples of timed assessing are shown below. example 1: valid access mov ta , #0aah ; 3 m/c; note: m/c = machine cycles mov ta, #055h ; 3 m/c mov wdcon, #00h ; 3 m/c example 2: valid access mov ta, #0aah ; 3 m/c mov ta, #055h ; 3 m/c nop ; 1 m/c setb ewrst ; 2 m/c example 3: valid access mov ta, #0aah ; 3 m/c mov ta, #055h ; 3 m/c orl wdcon, #00000010b ; 3m/c example 4: invalid access mov ta, #0aah ; 3 m/c mov ta, #055h ; 3 m/c preliminary N79E875 data s heet publication release date: april 13, 2009 - 145 - revision a02 nop ; 1 m/c nop ; 1 m/c clr ewt ; 2 m/c example 5: invalid access mov ta, #0aah ; 3 m/c nop ; 1 m/c mov ta, #055h ; 3 m/c setb ewt ; 2 m/c in the first three examples, the writing to the protected bits is done before the 3 machine cycles? window closes. in example 4, however, the writing to the protected bi t occurs after the window has closed, and so there is effectively no change in the status of the protected bit. in example 5, the second write to ta occurs 4 machine cycles after the first write, therefore the timed access window is not opened at all, and the write to the protected bit fails. preliminary N79E875 data s heet - 146 - 21 keyboard interrupt ( kbi) the N79E875 series provide 8 keyboard interrupt function to detect keypad status which key is acted, and allow a single interrupt to be generated when any key is pressed on a keyboard or keyp ad connected to specific pins of the N79E875 series, as shown below figure. this interrupt may be used to wake up the cpu from idle or power down modes, after chip is in power down or idle mode. keyboard function is supported through by port 0. it can all ow any or all pins of port 0 to be enabled to cause this interrupt. port pins are enabled by the setting of bits of kbi0 ~ kbi7 in the kbi register, as shown below figure. the keyboard interrupt flag , kbf in the auxr1 (a2h).7, is set when any enabled pin is triggered while the kbi interrupt function is active, an interrupt will be generated if it has been enabled. the kbf bit set by hardware and must be cleared by software. in order to determine which key was pressed, the kbi will allow the interrupt service routine to poll port 0. kbi1~kbi3 support both rising and falling edge detection, and the remaining pins support low level detection only. p 0 . 7 kbi . 0 kbi . 1 kbi . 2 kbi . 3 kbi . 4 kbi . 5 kbi . 6 kbi . 7 ekb ( from eie register ) kbf ( kbi interrupt ) p 0 . 6 p 0 . 5 p 0 . 4 p 0 . 3 p 0 . 2 p 0 . 1 p 0 . 0 or or or figure 21- 1 : kbi inputs symbol defi nition address msb bit address, symbol lsb reset auxr1 aux function register 0 a2h kbf bod boi lpbod srst adcen rcclk bos 0x00 0000b kbi keyboard interrupt a1h kbi.7 kbi.6 kbi.5 kbi.4 kbi.3 kbi.2 kbi.1 kbi.0 0000 0000b preliminary N79E875 data s heet publication release date: april 13, 2009 - 147 - revision a02 22 i/o port configurati on N79E875 series have maximum four 8 bits i/o ports; port 0, port 1, port 2, port 3 and one partial port 4; p4.0 to p4.3. all pins of i/o ports can be configured to one of four types by software except p1.4 is only input pin or set to reset pin. when p1.4 is configu red reset pin by rpd=0 in the config0 register, the device can support 33 i/o pins by use crystal. if used on - chip rc oscillator and the p1.4 is configured input pin, the device can be supported up to 36 i/o pins. the i/o ports configuration setting as bel ow table. pxm1.y pxm2.y port input/output mode 0 0 quasi - bidirectional 0 1 push - pull 1 0 input only (high impedance) 1 1 open drain table 22- 1 : i/o port configuration table all port pins can be determin ed to high or low after reset by configure prhi bit in the config0 register. after reset, these pins are in quasi - bidirectional mode. the port pin of p1.4 only is a schmitt trigger input. enabled toggle outputs from timer 0 and timer 1 by t0oe and t1oe on auxr2 register, the output frequency of timer 0 or timer 1 is by timer overflow. each i/o port of N79E875 series may be selected to use ttl level inputs or schmitt inputs by p(n)s bit on ports register; where n is 0, 1, 2, 3 or 4 . when p(n)s is set to 1, ports are selected schmitt trigger inputs on port(n). the p1.0 (xtal2) can be configured as clock output when used on - chip rc or external oscillator is clock source, and the frequency of clock output is divided by 4 on on - chip rc clock or external oscillat or. p1.5 and p1.6 (/int0) that supported i2c are permanent open drain pins. 22.1 quasi - bidirectional output configuration the default port output configuration for standard N79E875 series i/o ports is the quasi - bidirectional output that is common on the 80c51 an d most of its derivatives. this output type can be used as both an input and output without the need to reconfigure the port. this is possible because when the port outputs a logic high, it is weakly driven, allowing an external device to pull the pin low. when the pin is pulled low, it is driven strongly and able to sink a fairly large current. these features are somewhat similar to an open drain output except that there are three pull - up transistors in the quasi - bidirectional output that serve different p urposes. one of these pull - ups, called the ?very weak? pull - up, is turned on whenever the port latch for the pin contains a logic 1. the very weak pull - up sources a very small current that will pull the pin high if it is left floating. a second pull - up, ca lled the ?weak? pull - up, is turned on when the port latch for the pin contains a logic 1 and the pin itself is also at a logic 1 level. this pull - up provides the primary source current for a quasi - bidirectional pin that is outputting a 1. if a pin that has a logic 1 on it is pulled low by an external device, the weak pull - up turns off, and only the very weak pull - up remains on. in order to pull the pin low under these conditions, the external device has to sink enough current to overpower the weak pull - up a nd take the voltage on the port pin below its input threshold. the third pull - up is referred to as the ?strong? pull - up. this pull - up is used to speed up low - to - high transitions on a quasi - bidirectional port pin when the port latch changes from a logic 0 t o a logic 1. preliminary N79E875 data s heet - 148 - when this occurs, the strong pull - up turns on for a brief time, two cpu clocks, in order to pull the port pin high quickly. then it turns off again. the quasi - bidirectional port configuration is shown as below. port pin 2 cpu clock delay input data port latch data p p p n vdd strong very weak weak fi gure 22- 1 : quasi - bidirectional output 22.2 open drain output configuration the open drain output configuration turns off all pull - ups and only drives the pull - down transistor of the port driver when the port latch contains a logic 0. to be used as a logic output, a port configured in this manner must have an external pull - up, typically a resistor tied to v dd . the pull - down for this mode is the same as for the quasi - bidirectional mode. the open drain port configurat ion is shown as below. port pin port latch data n input data figure 22- 2 : open drain output 22.3 push - pull output configuration the push - pull output configuration has the same pull - down structure as both the open drain an d the quasi - bidirectional output modes, but provides a continuous strong pull - up when the port latch contains a logic 1. the push - pull mode may be used when more source current is needed from a port output. the push - pull port configuration is shown below. one port pin that cannot be configured is p1.4. p1.4 may be used as a schmitt trigger input if the device has been configured for an internal reset and is not using the external reset input function /rst. the value of port pins at reset is determined by t he prhi bit in the config0 register. ports may be configured to reset high or low as needed for the application. when port pins are driven high at reset, they are in quasi - bidirectional mode and therefore do not source large amounts of current. every outpu t on the device may potentially be used as a 20ma sink led drive output. however, there is a maximum total output current for all ports which must not be exceeded. all ports pins of the device have slew rate controlled outputs. this is to limit noise gener ated by quickly switching output signals. the slew rate is factory set to approximately 10 ns rise and fall times. the preliminary N79E875 data s heet publication release date: april 13, 2009 - 149 - revision a02 ports sfr bits can enable schmitt trigger inputs on each i/o port. the auxr2 register has bits to enable toggle outputs from timer 0 and timer 1, and enable a clock output if either the internal rc oscillator or external clock input is being used. the last two functions are described in the timer/counters and oscillator sections respectively. each i/o port of this device may be selected to use ttl level inputs or schmitt inputs with hysteresis. a single configuration bit determines this selection for the entire port. port pin p1.4 always has a schmitt trigger input. port pin input data port latch data p n vdd figure 22- 3 : push - pull output 22.4 input only configuration by configure this mode, the ports are only digital input and disable digital output. the n79e8 75 series can select input pin to schmitt trigger or ttl level input by pxm1.y and pxm2.y registers. 22.5 sfr of i/o port configuration symbol definition address msb bit address, symbol lsb reset p4m2 port 4 output mode 2 fbh - - - - p4m2.3 p4m2.2 p4m2.1 p4m2.0 xxxx 0000b p4m1 port 4 output mode 1 fah - - - - p4m1.3 p4m1.2 p4m1.1 p4m1.0 xxxx 0000b ports port s hmitt register ech - - - p4s p3s p2s p1s p0s xxx0 0000b p2m2 port 2 output mode 2 b6h p2m2.7 p2m2.6 p2m2.5 p2m2.4 p2m2.3 p2m2.2 p2m2.1 p2m2.0 0000 0000b p2m1 port 2 output mode 1 b5h p2m1.7 p2m1.6 p2m1.5 p2m1.4 p2m1.3 p2m1.2 p2m1.1 p2m1.0 0000 0000b p1m 2 port 1 output mode 2 b4h p1m2.7 - - - p1m2.3 p1m2.2 p1m2.1 p1m2.0 000x 0000b p1m1 port 1 output mode 1 b3h p1m1.7 - - - p1m1.3 p1m1.2 p1m1.1 p1m1.0 000x 0000b p0m2 port 0 output mode 2 b2h p0m2.7 p0m2.6 p0m2.5 p0m2.4 p0m2.3 p0m2.2 p0m2.1 p0m2.0 0000 00 00b p0m1 port 0 output mode 1 b1h p0m1.7 p0m1.6 p0m1.5 p0m1.4 p0m1.3 p0m1.2 p0m1.1 p0m1.0 0000 0000b p3m1 port 3 output mode 1 9eh p3m1.7 p3m1.6 p3m1.5 p3m1.4 p3m1.3 p3m1.2 p3m1.1 p3m1.0 0000 0000b preliminary N79E875 data s heet - 150 - 23 oscillator N79E875 series provide three oscillator in put option s . these are configured at config register (config0) that include on - chip rc oscillator option, external clock input option and crystal oscillator input option. the crystal oscillator input frequency may be supported from 4mhz to 40mhz, and optio nally with capacitor or resister. fosc 0 fosc 1 00 b 11 b 01 b crystal oscillator external clock input internal rc oscillator 16 bits ripple counter cpu clock power monitor reset power down (config 0 ) figure 23- 1 : oscillator 23.1 on - chip rc oscillator option the on - chip rc oscillator is programmable to 22.1184mhz/11.0592mhz +/ - 2% (selectable by f s1 config bit) frequency to support clock source. when fosc1, fosc0 = 01b, the on - chip rc oscillator is enabled. a clock output on p1.0 (xtal2) may be enabled when on - chip rc oscillator is used. 23.2 external clock input option the clock source pin (xtal1) is f rom external clock input by fosc1, fosc0 = 11b, and frequency range is form 0hz up to 40mhz. a clock output on p1.0 (xtal2) may be enabled when external clock input is used. N79E875 series support a clock output function when either the on - chip rc oscillat or or the external clock input options is selected. this allows external devices to synchronize to the device. when enabled, via the enclk bit in the auxr2 register, the clock output appears on the xtal2/clkout pin whenever the on - chip oscillator is runnin g, including in idle mode. the frequency of the clock output is 1/4 of the cpu clock rate . if the clock output is not needed in idle mode, it may be turned off prior to entering idle mode, saving additional power. the clock output may also be enabled when the external clock input option is selected. preliminary N79E875 data s heet publication release date: april 13, 2009 - 151 - revision a02 24 power monitoring fun ction power - on detect and brownout are two additional power monitoring functions implemented in N79E875 series to prevent incorrect operation during power up and power drop or loss. 24.1 power on detect the power ? on detect function is a design to detect power up after power voltage reaches to a level where brownout detect can work. after power on detect, the por (pcon.4) will be set to ?1? to indicate an initial power up condition. the por flag wi ll be cleared by software. 24.2 brownout detect the N79E875 has an on - chip brown - out detection (bod) circuit for monitoring the v dd level during operation by comparing it to a fixed trigger level. there are 3 trigger levels of bod selected by 2 config0 bits bo v[1:0] suited for wide voltage use. the following table shows the brownout voltage levels supported; bov bits (config0.4 - 3) brownout voltage detect level 00 4.5v 01 3.8v 1 x 2. 6 v (default) table 24- 1 : bro wnout v oltage d etect l evels when the brownout voltage is drop to the select level, the brownout detector will detect and keeps this active until v dd is returns to above brownout detect voltage. the brownout detect block is as follow. brownout detect circuit 0 1 bof to reset to brownout interrupt bov [ 1 :0 ] bod lpbov boi bos ( config - bits) figure 24- 1 : brownout detect block when brownout detect is enabled by bod (auxr1.6), the bof (pcon.5) flag will be set that it causes brownout reset or interrupt, and bof will be cleared by software. if boi (auxr1.5) is set to ?1?, the brownout detect will cause interrupt via the ea (ie.7) and ebo (ie.5) bits is set. preliminary N79E875 data s heet - 152 - vbor+ vbor - v dd boi=0 to select brown-out reset set by hardware clear by software hysterisis voltage is about 30mv~150mv for each bod voltage level boi=1 to select brown-out interrupt clear by software t bor : brown-out reset delay time with about 8ms nominal brown- out voltage brown-out status bos t bor 8ms reset bof figure 24- 2 : brown - out voltage detection 24.3 sfr of brown -o ut detection symbol definition address msb bit address, symbol lsb reset auxr1 aux function register 1 a2h kbf bod boi lpbod srst adcen rcclk bos 0x00 0000b pcon power control 87h smod smod0 bof por gf1 gf0 pd idl 00xx 0000b preliminary N79E875 data s heet publication release date: april 13, 2009 - 153 - revision a02 25 pulse - width - modulated (pw m) outputs in sa8218, the build - in pwm function is specially designed for driving motor control applications. using the pwm and timer2/input capture module with proper control flow by software can drive 3 - phase brushless dc motor, 3 - phase ac induction moto r and dc motor. 25.1 pwm features the pwm block supports the features as below ; ? four independent 12 - bit pwm duty control units with maximum 8 port pins: ? 4 independent pwm output : pwm0, pwm2, pwm4 and pwm6 ? 3 complementary pwm pairs , with each pin in a pair mutua lly complement to each other and capable of programmable dead - time insertion : (pwm0,pwm1), (pwm2,pwm3) and (pwm4,pwm5) ? 3 synchronous pwm pairs , with each pin in a pair in - phase: (pwm0,pwm1), (pwm2,pwm3) and (pwm4,pwm5) ? group control bit: pwm2 and pwm4 are synchronized with pwm0 ? support edge aligned mode and center aligned mode. ? programmable dead - time insertion between complementary paired p wms. ? each pin of from pwm0 to pwm5 has independent polarity setting control. ? mask output control for electrically c ommutated motor operation. ? tri - state output at reset. ? hardware brake protection s . ? support 2 independent interrupts. ? interrupt is synchronously requested at pwm frequency when up/down counter comparison matched (edge aligned mode) or underflow (center align ed mode). ? interrupt is requested when external brake pins asserted ? the pwm signals before polarity control stage are defined in the view of positive logic. the pwm ports is active high or active low are controlled by polarity control register. ? high source/ sink current. after cpu reset the internal output of the each pwm channel s depend s on the polarity setting. the interval between successive outputs is controlled by a 1 2 ? bit up/ down counter which uses the oscillator frequency with configurable internal cl ock pre - scalar as its input. t he pwm counter clock has the frequency as the clock source f pwm = f cpu /pre - scalar . the figure 25- 1 is the block diagram for pwm. preliminary N79E875 data s heet - 154 - pwm control logic pwm timebase control pwm0 freq/duty pwm2 freq/duty pwm4 freq/duty pwm0 & pwm1 set complementary & dead-time insertion pwm2 & pwm3 set complementary & dead-time insertion pwm4 & pwm5 set complementary & dead-time insertion mask output control pwm0 pwm1 pwm2 pwm3 pwm4 pwm5 brake condition brake control pwm generator brake & polarity control pg0 pg1 pg2 pg3 pg4 pg5 mp0 mp1 mp2 mp3 mp4 mp5 pwm6 pwm7 pwm6 freq/duty 0 1 pg6 figure 2 5 - 1 : pwm block diagram preliminary N79E875 data s heet publication release date: april 13, 2009 - 155 - revision a02 25.2 pwm operation the following diagram shows pwm time - base generator. 12- bits up / down counter control block compare register 0 pwm 0 register pwmrun fcpu - + pwm 2 register - + pwm 4 register - + - + pwmf x x x y y y load clrpwm clear counter compare register 2 compare register 4 pwmtype prescaler ( 1 / 1 , 1 / 2 , 1 / 4 , 1 / 16 ) fpwm pwmp register edge / center ( pwmdiv . 1 ~ 0 ) pwm period interrupt q q set clr d s / w clear counter match pwmp / underflow 12- bit 12- bit 12- bit 12- bit dead - time insertion & mask control & brake control & set polarity pwm 0 pwm 1 0 1 0 1 grp bit pwm 6 ( p 0 . 7 ) pio . 6 0 1 p 0 . 7 p 3 . 3 pwm 7 ( p 3 . 3 ) pwm 0 ( p 2 . 0 ) pwm 1 ( p 3 . 0 ) pwm 2 pwm 3 pwm 2 ( p 2 . 1 ) pwm 3 ( p 3 . 1 ) pwm 4 pwm 5 pwm 4 ( p 2 . 2 ) pwm 5 ( p 3 . 2 ) pio . 7 0 1 pwm 6 register - + x y compare register 6 12- bit 0 1 p 6 ctrl load a a a a a figure 25- 2 : pwm time - base generator preliminary N79E875 data s heet - 156 - the overall funct ioning of the pwm module is controlled by the contents of the pwmcon1, pwmb and pwmcon3 registers. the operation of most of the control bits is straightforward. pwmcon1.7 (pwmrun) allows the pwm to be either in the run or idle state. the transfer of the da ta from the pwmp register to 12 - bit counter will occur on the rising edge of pwmcon1.7 (pwmrun) or during pwmrun with pwmcon1.6 (load) and counter match/underflow occur. the transfer of the data from the pwmn registers to the compare registers is controlle d by the pwmcon1.6 (load) (with condition that pwmrun= 1 and match / underflow occurs ). notes: a compare value greater than the counter reloaded value resulted in the pwm output being permanently high. in addition there are two special cases. if compare reg ister is set to 000h, the pwmn output will stay at low, and if compare register is set to fffh, the pwmn output will stuck at high until there is a change in the compare register. [n = 0 - 3]. during icp mode, pwm pins will be tri - stated. pwm operation will be stop. when exit from icp mode, the pwm pins will follow the last sfr port values. the pwmp register fact that writes are not into the counter register that controls the counter; rather they are into a holding register. the transfer of data from this h olding register, into the register which contains the actual reload value, occurs when the following conditions are met; load = 1, pwmrun = 1 and pwm match/underflow. the width of each pwm output pulse is determined by the value in the appropriate compare register. each pwm register pair of (pwmph,pwmpl), (pwm0h,pwm0l), (pwm2h,pwm2l) , (pwm4h,pwm4l) and (pwm6h, pwm6l) , in the format of 12 - bit width by combining 4 lsb of high byte register and 8 bits of low byte register , decides the pwm period and each chan nel ? s duty cycle. please take note that duty registers pwm0 ~6 and period registers pwmp are double - buffered register s used to set the duty cycle and counting period for the pwm time base respectively. for the 1 st buffer it is accessible by user while the 2 nd buffer holds the actual compare value used in the present period. load bit must be set to 1 to enable the value to be loaded in to the 2 nd buffer register when counter underflow/match. 25.2.1 pwm operation mode this device support s 2 operation modes: edge - ali gned and centre - aligned mode. the following equations show the formula for period and duty for each pwm operation mode: edge aligned : period = ( pwmp +1 ) * cpu clock period/pre - scalar duty = duty * cpu clock period /pre - scalar centre aligned : period = ( p wmp * 2) * cpu clock period/pre - scalar duty = (duty*2 - 1) * cpu clock period/pre - scalar note: ?duty? refers to pwm0/2/4/6 register value. 25.2.2 edge aligned pwm (up - counter) in e dge - aligned pwm output mode, the 12 bits counter will starts counting from 0 to mat ch with the value of the duty cycle pwm0 (old), when this happen it will toggle the pwm0 generator output to low. the counter will continue counting to match with the value of the period register pwmp (old) , at this moment, it toggle s the pwm0 generator ou tput to high and new pwm0 (new) and pwmp(new) are updated with load=1 and request the pwm interrupt if pwm interrupt is enabled(eie1. 6 =1) . preliminary N79E875 data s heet publication release date: april 13, 2009 - 157 - revision a02 figure 25- 3 , figure 25 - 4 and figure 25 - 5 depict the edge - aligned pwm timing and operation flow. pwmp ( new ) pwm 0 ( old ) pwmp ( old ) pwm 0 ( new ) new duty cycle pwm period new pwm period new pwm 0 is written new pwmp is written if 12 - bit up counter matches pwmp 1 . update new duty cycle register ( pwm 0 , 2 , 4 and 6 ) if load = 1 2 . update new pwmp period register ( pwmp ) if load = 1 pwm 0 generator ouput figure 25- 3 : edge - aligned pwm pwmp ( 7 ff ) pwm 0 ( 3 ff ) pwm 0 generator ouput pwm period pwmf ( int _ type = x ) s/w clear s /w clear s/w clear s/w clear s/w clear figure 25- 4 : pwm0 edge aligned waveform output preliminary N79E875 data s heet - 158 - set pmod[1:0] =00b pwmtype = 0b start: load = 1 pwmrun = 1 clrpwm = 1 h/w will load pwmn and pwmp to working registers. ?load? bit will be auto-cleared. pwmn output: 1 if counter < pwmn 0 if counter > pwmn counter counting up counter = pwmn? pwmn output toggle counter continue counting up counter = pwmp? pwmn output toggle reset counter to zero (h/w) pwmf flag set load = 1? h/w willl load in new pwmp/pwmn value to working registers. no no no figure 25- 5 : edge - aligned flow diagram preliminary N79E875 data s heet publication release date: april 13, 2009 - 159 - revision a02 25.2.3 center aligned pwm (up/down counter) the center - aligned pwm signals are produced by the module when the pwm time base is configured in an up/down counting mode. the counter will start counting - up from 0 to match the value of pwm0 (old), this will cause the toggling of the pwm0 generator output to low. the c ounter will continue counting to match with the pwmp (old). upon reaching this states counter is configured automatically to down counting , when counter matches the pwm0 (old) value again the pwm0 generator output toggles to high . once the counter underflows it will update the pwm period register pwmp(n ew) and duty cycle register pwm0(new) with load = 1 . in center - aligned mode, the pwm interrupt is requested at down - counter underflow if int_type (pwmcon3.0)=0 or at up - counter matching with pwmp if int_type(pwmcon3.0)=1. figure 25- 6 , figure 25 - 7 and figure 25 - 8 depict the center - aligned pwm timing and operation flow. pwmp ( new ) pwm 0 ( old ) pwmp ( old ) pwm 0 ( new ) new duty cycle pwm period new pwm period new pwm 0 is written new pwmp is written if 12 - bit up / down counter underflows 1 . update new duty cycle register ( pwm 0 , 2 , 4 and 6 ) if load = 1 2 . update new pwmp period register ( pwmp ) if load = 1 pwm period pwm 0 generator ouput figure 25- 6 : center - aligned mode preliminary N79E875 data s heet - 160 - pwmp ( 7 ff ) pwm 0 ( 3 ff ) pwm period pwmf ( int _ type = 0 ) s/w clear s/w clear s/w clear pwmf ( int _ type = 1 ) s/w clear s/w clear pwm period pwm 0 generator ouput figure 25- 7 : pwm0 center aligned waveform output preliminary N79E875 data s heet publication release date: april 13, 2009 - 161 - revision a02 set pmod[1:0] =10b pwmtype = 1b start: load = 1 pwmrun = 1 clrpwm = 1 h/w will load pwmn and pwmp to working registers. ?load? bit will be auto-cleared (h/w). pwmn output: 1 if counter < pwmn 0 if counter > pwmn counter counting up counter = pwmn? pwmn output toggle counter continue counting up counter = pwmp? counter counting down from pwmp pwmf flag set (int_type = 0) load = 1? h/w willl load in new pwmp/pwmn value to working registers. no no no counter = pwmn? pwmn output toggle counter continue counting down counter = 0? no figure 25- 8 : center - aligned flow diagram (int_typ e = 0) preliminary N79E875 data s heet - 162 - 25.3 pwm brake function this device supported 2 external brake pins; bkp0 and bkp1 pins. both brake pins ha ve each a 4- degree digital filter that is user control lable through bknfilt.1 - 0 bits (n=0,1). the brake function is controlled by the contents of t he sfr pwmcon1 - 4 registers . bkp 0 pin (p 1 .7 ) ebrk ( from eie register ) brake detect interrupt noise filter bk 0filt .1 -0 fbk 0 fbk 1 fosc /1 ,/ 2,/4,/8 noise filter bk 1 filt .1 -0 fosc /1 ,/ 2,/4,/8 bken 0 low level detection pwm 0~ 5 outputs follow pwmnb ( see note ) bken 1 autobk 1 pwm 0 ~ 5 outputs follow pwmnb ( see note ) bkp 1 pin (p1. 5) ( open - drian ) note : pwm output level during brake condition will also depend on pnp . n to control pwmnb polarity . if pnp . n = 0 , pwmn output = pwmnb . if pnp . n = 1 , pwmn output = invert ( pwmnb ). figure 25- 9 : pwm brake function the following table summaries the effect of each brake pins ; the figure 25 - 10 and figure 25- 11 illustrate the brake signals vs pwm operation. brake pin brake trigger condition action s bkp0 a falling edge at bkp0 1. f bk0 flag set by h/w; but cleared by s/w . 2. pwm0~5 outputs f ollow pwmnb bits. pnp bits are also able to contr ol the polarity of pwmnb. if pnp.n=0, pwmn pin output = pwmnb. if pnp.n=1, pwmn pin output = invert(pwmnb). 3. h/w sets pwmrun =0 to stop pwm generator. 4. pwm0~5 pin outputs does not resume on release of bkp0 pin. pwm 0~5 will remain in pwmnb state after the s/ w clearing of fbk0 flag, if user keep pwmrun = 0. if user re - enabled pwmrun, the brake state will be release on next pwm cycle/period. bkp1 a falling edge at bkp1; low level state 1. fbk 1 flag set by the falling edge at bkp1; but cleared by s/w. 2. if a uto bk1= 1 and bkp1 detected as low level, preliminary N79E875 data s heet publication release date: april 13, 2009 - 163 - revision a02 pwm0~5 pin outputs f ollow pwmnb bits. otherwise, pwm0~5 will continue follow pwm generators? output. in both situations, pnp bits are also able to control port polarity. 3. pwmrun bit remain asserted to keep pwm generator s r unning. 4. pwm 0~5 resume if bkp1 pin state returns to high state. pwm 0~5 will resume on start of next pwm cycle/period. note that user require to enable brake enable bits, bkenn, in order for the above to be effective. pwm counter pwm0 register bkp1 port pwm0 port pwm1 pwm signals resume at next start of pwm period pwm1 at brake state pwm0 at brake state bkp0 fbk0 pwm1 at brake state pwm0 at brake state *initially, autobk1=1 and bken0 =1 figu re 25- 10 : pwm brake condition (edge aligned mode) pwm counter pwm0 register bkp1 port pwm0 port pwm1 pwm signals resume at next start of a pwm period bkp0 fbk0 pwm1 at brake state pwm0 at brake state pwm0 at brake state pwm1 at brake state *initially, autobk1=1 and bken0=1 figure 25- 11 : pwm brake condition (centre aligned mode) since the both brake co nditions being asserted will automatically cause fbkn flag will be set , the user preliminary N79E875 data s heet - 164 - program can poll these brake flag bits or enable pwm ? s brake interrupt to determine which condition causes a brake to occur. 25.4 pwm output driving control 1 0 3 -state / push - pull / quasi / open drain pwmn output 3 - state control (hz_ even , hz_ odd ) (pxm 2.y , pxm 1.y) i/o bit 1 0 pmd n pio n pme n mask control polarity control driving mode control pgn dead - time insertion brake & polarity control mpn note : n = 0 ~ 5 figure 25- 12 : pwm output driving control the driving type of pwm output ports can be initialized as tri - state type or other type dependent with sfr pxmy setting after any reset. as show in the above diagram, pwm output structures are controllable through option bits (config1.0 - 1), sfr (pwmcon3.hz_even,hz_odd) bits and sfr pxmy mode registers. hz _even/ hz _odd (sfr pwmcon3 bits) pwm output drive mode 0 depend on pxmy sfr. 1 driving mode = hi - z. note : sfr bits for hz_even and hz_odd are latched from config1.0 and config1.1, respectively, during all reset. 25.5 pwm modes this powerful pwm unit supports independent mode which may be applied to dc and bldc motor system, complementary mode with dead - time inser tion which may be used in the application of ac induction motor and synchronous motor, synchronous mode that makes both pins of each pair are in phase. besides, the group mode, forces the pwm0, pwm2 and pwm4 synchronous with pwm0 generator, may simplify up dating duty control in dc and bldc motor applications. 25.5.1 independent mode independent mode is enabled when pmod.1 - 0 = 00b. on default, the pwm is operating in independent mode, with four pwm even channels outputs: pwm0, pwm2, pwm4 and pwm6. each channel is r unning off its own duty - cycle generator module. pwm6 can be user controllable to output from pwm2 generator if p6ctrl = 1. pwm7 is taking output from pwm4 generator. preliminary N79E875 data s heet publication release date: april 13, 2009 - 165 - revision a02 25.5.2 complementary mode complementary mode is enabled when pmod.1 - 0 = 01b. in this module ther e are three duty - cycle generators utilized for complementary mode, with total of three pwm output pair pins in this module. the total six pwm outputs are grouped into output pairs of even and odd numbered outputs. in complimentary modes, the internal odd p wm signal pgx, refer to figure 25- 1 , must always be the complement of the corresponding even pwm signal . for example, pg1 will be the complement of pg0 . pg3 will be the complement of pg2 and pg5 will be the complem ent of pg4 . the time base for the pwm module is provided by its own 12 - bit timer, which also incorporates selectable pre - scalar options. 25.5.2.1 dead - time insertion the dead time generator inserts an ?off? period called ?dead time? between the turnings off of one pin to the turning on of the complementary pin of the paired pins. this is to prevent damage to the power switching devices that will be connected to the pwm output pins. the complementary output pair mode has an 8 - bit counter used to produce the dead tim e insertion . the complementary outputs are delayed until the timer counts down to zero. the dead- time can be calculated from the following formula: dead - time = f cpu * (dtcnt. [7:0] +1) . the timing diagram below indicates the dead time insertion for one pai r of pwm signals . pg0 without dead-time pg1 without dead-time pwm0 with dead-time pwm1 with dead-time dead-time interval effect of dead-time for complementary pairs figure 25- 13 : dead- time insertion pdtc 0 and dtcnt have time access protection in writing access. in power inverter application, a dead time insertion avoids the upper and lower switches of the half bridge from being active at the same time. h ence the dead time control is crucial to proper operation of a system. some amount of time must be provided between turning off of one pwm output in a complementary pair a nd turning on the other transistor as the power output devices cannot switch instantaneously. 25.5.3 synchronous mode synchronous mode is enabled when pmod.1 - 0 = 10b. in the synchronization mode the pwm pair signals from pwm generator are in - phase . pg1=pg0, pg3=p g2 and pg5=pg4. 25.5.4 group mode group mode is enabled when pmod.1 - 0 = 1 1 b. preliminary N79E875 data s heet - 166 - this device support group mode control. this control allows all even pwm channels output to be duty controllable by pwm0 duty register. if grp = 1, both (pg2, pg3) and (pg4, pg5) pairs will follow (pg0, pg1), which imply; pg4 = pg2 = pg0; pg5 = pg3 = pg1 = invert (pg0) if complementary mode is enabled (pmod.1 - 0=01b) 25.6 polarity control each pwm port of from pwm0 to pwm5 has independent polarity control to configure the polarity of active st ate of pwm output. at default, the pwm output is active high. this implies the pwm off state is low and on state is high. this is controllable through sfr pnp on each individual pwm channel. the following diagram show the initial state before pwm starts wi th different polarity settings. pg0 pg1 pwm0 pwm1 off on on off off off on off (pnp.0=0) (pnp.1=0) dead-time insertion; it is only effective in complementary mode npx: negative polarity control bits; it controls the pwm output initial state and polarity pwm0 pwm1 pwm0 pwm1 pwm0 pwm1 (pnp.0=1) (pnp.1=0) (pnp.0=0) (pnp.1=1) (pnp.0=1) (pnp.1=1) initial state pwm starts on off off on off off on off off on on off off off on off off off on off on off off on pwm output with dead-time insertion and polarity control figure 25- 14 : initial state and polarity control with rising edge dead time insertion 25.7 pwm mask output each of the pwm output channels can be manua lly overridden by using the appropriate bits in the sfr p me and pmd registers to drive the pwm i/o pins to specified logic states independent of the duty cycle comparison units. the pwm mask bits are useful when controlling various types of e lectrically c o mmutated m otor (ecm) like a bldc motor. the pmd register contains six bits, pmd[5:0] determine which pwm i/o pins will be overridden. on reset p md is 00h. preliminary N79E875 data s heet publication release date: april 13, 2009 - 167 - revision a02 the pme register contains six bits, pme[5:0] determine the state of the pwm i/o pins when a particul ar output is masked via the pmd bits. on reset p me is 00h. the pme [ 5 :0] bits are active - high . when the pme [ 5 :0] bits are set, the corresponding pmd [ 5 :0 ] bit will have effect on the pwm channel. when one of the p m e bits is sets , the output on the correspond ing pwm i/o pin will be determined by the state of the pm d bit and polarity control bit . 0 2 4 1 3 5 bit number 1 0 3 2 5 4 symbol legend of a typical 3 - phase inverter 3 - phase load 0 1 1 0 1 1 pme x 0 0 x 1 0 pmd 0 1 1 0 1 1 pme x 0 0 x 0 1 pmd 1 0 1 1 0 1 pme 0 x 0 0 x 1 pmd pwm 0 pwm 1 pwm 0 pwm 1 pwm 2 pwm 3 current path = ( 0 , 3 ) current path = ( 0 , 5 ) current path = ( 2 , 5 ) mask control in complementary mode 1 0 1 1 0 1 pme 0 x 0 1 x 0 pmd pwm 2 pwm 3 current path = ( 2 , 1 ) example 1 . 1 example 1 . 2 example 1 . 3 example 1 . 4 0 1 1 1 1 1 pme x 0 0 0 1 0 pmd 0 1 1 1 1 1 pme x 0 0 0 0 1 pmd 1 0 1 1 1 1 pme 0 x 0 0 0 1 pmd pwm 0 pwm 0 pwm 2 current path = ( 0 , 3 ) current path = ( 0 , 5 ) current path = ( 2 , 5 ) mask control in independent mode 1 0 1 1 1 1 pme 0 x 0 1 0 0 pmd pwm 2 current path = ( 2 , 1 ) example 2 . 1 example 2 . 2 example 2 . 3 example 2 . 4 figure 25- 15 illustratio n of mask control figure above shows example of how pwm mask control can be used for the override feature. in example 1.1; pme[5:0] = 11 1100b, pmd[5:0] = 0010xxb (complementary mode) preliminary N79E875 data s heet - 168 - ? pwm channels 2 - 5 are masked from pwm frequency/duty generators. ? pwm cha nnels 2 - 5 outputs are determined by state of pmd bits. ? pwm channels 0 and 1 follow pwm generator. switch 0 (on/off) : control by pwm0 (pwm0 frequency/duty generator). switch 1 (on/off) : control by pwm1 (inverted of pwm0, complementary mode). switch 2 (off ) : pmd.2 = 0. switch 3 (on) : pmd.3 = 1. switch 4 (off) : pmd.4 = 0. switch 5 (off) : pmd.5 = 0. in example 1.3; pme[5:0] = 11 0011b, pmd[5:0] = 10xx00b (complementary mode) ? pwm channels 0, 1, 4 and 5 are masked from pwm frequency/duty generators. ? pw m channels 0, 1, 4 and 5 outputs are determined by state of pmd bits. ? pwm channels 2 and 3 follow pwm generator. switch 0 (off) : pmd.0 = 0. switch 1 (off) : pmd.1 = 0. switch 2 (on/off) : control by pwm2 (pwm2 frequency/duty generator). switch 3 (on/off ) : control by pwm3 (inverted of pwm2, complementary mode). switch 4 (off) : pmd.4 = 0. switch 5 (on) : pmd.5 = 1. in example 2.1; pme[5:0] = 11 1110b, pmd[5:0] = 00100xb (independent mode) ? pwm channels 1 - 5 are masked from pwm frequency/duty generators. ? pwm channels 1 - 5 outputs are determined by state of pmd bits. ? pwm channel 0 follow pwm generator. switch 0 (on/off) : control by pwm0 (pwm0 frequency/duty generator). switch 1 (off) : pmd.1 = 0. switch 2 (off) : pmd.2 = 0. switch 3 (on) : pmd.3 = 1. sw itch 4 (off) : pmd.4 = 0. switch 5 (off) : pmd.5 = 0. in example 2.3; pme[5:0] = 11 1011b, pmd[5:0] = 100x00b (independent mode) ? pwm channels 0,1,3,4 and 5 are masked from pwm frequency/duty generators. ? pwm channels 0,1,3,4 and 5 outputs are determined b y state of pmd bits. ? pwm channel 2 follow pwm generator. switch 0 (off) : pmd.0 = 0. switch 1 (off) : pmd.1 = 0. switch 2 (on/off) : control by pwm2 (pwm2 frequency/duty generator). preliminary N79E875 data s heet publication release date: april 13, 2009 - 169 - revision a02 switch 3 (off) : pmd.3 = 0. switch 4 (off) : pmd.4 = 0. switch 5 (on) : pmd.5 = 1. preliminary N79E875 data s heet - 170 - 25.8 sfr of pwm unit symbol definition addre ss msb bit address, symbol lsb reset pwm6h pwm 6 high bits regi ster feh - pwm6.11 wm6.10 pwm6.9 pwm6.8 xxxx 000 0b pwm6l pwm 6 low bits regis ter fdh pwm6.7 pwm6.6 pwm6.5 pwm6.4 pwm6.3 pwm6.2 pwm6.1 pwm6.0 0000 0000b pwmcon4 pwm control register 4 fch bk1filt.1 bk1filt.0 bk0filt.1 bk0filt.0 autobk 1 - bken1 bken0 000 0 0 x 00b pmd pwm mask data regist er eeh - - pmd.5 pmd.4 pmd.3 pmd.2 pmd.1 pmd.0 xx00 0000b pme pwm mask enable register edh - - pme.5 pme.4 pme.3 pme.2 pme.1 pme.0 xx00 0000b pwmb pwm brake output dfh - - pwm5b pwm4b pwm3b pwm2b pwm1b pwm0b xx00 0000b pwm2l pwm 2 low bits regis ter ddh pwm2.7 pwm2.6 pwm 2.5 pwm2.4 pwm2.3 pwm2.2 pwm2.1 pwm2.0 0000 0000b pwmcon1 pwm control register 1 dch pwmrun load pwmf clrpwm fbk1 fbk0 pmod.1 pmod.0 0000 0 000b pwm0l pwm 0 low bits regis ter dah pwm0.7 pwm0.6 pwm0.5 pwm0.4 pwm0.3 pwm0.2 pwm0.1 pwm0.0 0000 0000b pwmpl pw m counter low register d9h pwmp0.7 pwmp0.6 pwmp0.5 pwmp0.4 pwmp0.3 pwmp0.2 pwmp0.1 pwmp0.0 0000 0000b pwmcon3 pwm control register 3 d7h hz_even hz_odd grp pwmtype - - p6ctrl int_typ e xx 00 xx 00b pwm2h pwm 2 high bits regi ster d5h - - - - pwm2.11 pwm2.10 pwm2.9 pwm2.8 xxxx 0000b pwm0h pwm 0 high bits regi ster d2h - - - - pwm0.11 pwm0.10 pwm0.9 pwm0.8 xxxx 0000b pwmph pwm counter high register d1h - - - - pwmp.11 pwmp.10 pwmp.9 pwmp.8 xxxx 0000b pnp pwm negative polrari ty c3h - - pnp.5 pnp.4 pnp.3 pnp. 2 pnp.1 pnp.0 xx00 0000b p3 port 3 b0h (b7) p3.7 opn (b6) p3.6 opp (b5) p3.5 (b4) p3.4 (b3) p3.3 pwm7 (b2) p3.2 pwm5 (b1) p3.1 pwm3 (b0) p3.0 pwm1 1111 1111b (1) 0000 0000b pdtc0 pwm dead time contro l 0 register aeh - - - - - dtenb4 dtenb2 dtenb0 xxxx x00 0b dtcnt pwm dead time counter register abh dtcnt.7 dtcnt.6 dtcnt.5 dtcnt.4 dtcnt.3 dtcnt.2 dtcnt.1 dtcnt.0 0000 0000b p2 port 2 a0h (a7) p2.7 t1 (a6) p2.6 ic2 mosi (a5) p2.5 ic1 miso (a4) p2.4 ic0 /ss (a3) p2.3 t3 sclk (a2) p2.2 pwm4 (a1) p2.1 pwm2 cp1o (a0) p2.0 pwm0 cp2o 1111 1111b (1) 0000 0000b pio pwm io register 9bh pio.7 pio.6 pio.5 pio.4 pio.3 pio.2 pio.1 pio.0 00 00 0000b pwm4h pwm 4 high bits regi ster 97h - - - - pwm4.11 pwm4.10 pwm4.9 pwm4.8 xxxx 0000b pwm4l pwm 4 low bits regis ter 96h pwm4.7 pwm4.6 pwm4.5 pwm4.4 pwm4.3 pwm4.2 pwm4.1 pwm4.0 0000 0000b note: 1. if config0.prhi=1, the initial value is ffh at reset. if config0.prhi=0, the initial value is 00h at reset preliminary N79E875 data s heet publication release date: april 13, 2009 - 171 - revision a02 26 analog - to - digital converter (adc) N79E875 series support a 10 - bit analog - to - digital converter (adc) which contains a dac which converts the contents of a successive approximation register to a voltage (v dac ) which is compared to the analog input voltage (vin). the output of the comparator is fed to the successive approximation co ntrol logic which controls the successive approximation register. this is illustrated in the figure below. dac msb lsb successive approximation register vin + - comparator start ready ( stop ) successive approximation control logic v dac figure 26- 1 : successive approximation adc 26.1 operation of adc 26.1.1 normal operat ion of adc a conversion can be initiated by software only or by either hardware or software . the software only start mode is selected when control bit adccon.5 (adcex)=0. a conversion is then started by setting control bit adccon.3 (adcs) the hardware or software start mode is selected when adcex =1, and a conversion may be started by setting adcs as above or by applying a rising edge to external pin stadc (p1.7) or by a trigger signal synchronous with pwm unit . when a conversion is started by applying a ri sing edge, a low level must be applied to stadc for at least one machine cycle followed by a high level for at least one machine cycle. when adc c on.5 (adcex) is set by external pin to start adc conversion, after N79E875 series have ent ered idle mode, stadc /p1.7 can start adc conversion at least 1 machine cycle. the end of the 10 - bit conversion is flagged by control bit ad c con.4 (adci). the upper 8 bits of the result are held in special function register adch, and the two remaining bits are held in ad c con.7 (adc.1) and ad c con.6 (adc.0). the user may ignore the two least significant bits in ad c con and use the adc as an 8 - bit converter (8 upper bits in adch). in any event, the total actual conversion time is 34 adc clock cycles . adc i flag is set at end of adc c onversion. adcs will be hardware cleared when adci is set. control bits ad c con.0, ad c con.1 and ad c con.2 are used to control an analog multiplexer which selects one of eight analog channels. an adc conversion in progress is unaffected by an external or sof tware adc start. the result of a completed conversion remains unaffected provided adci = logic 1 . preliminary N79E875 data s heet - 172 - 10- bits adc block adc . 0 adc . 9 adci adcs av dd vref + av ss aadr [ 2 : 0 ] analog input multiplexer | 0 1 stadc / bkp 0 / p 1 . 7 adcex adc conversion block adcen adcs start conversion rcclk enable adc adc 1 ( p 0 . 1 / v br ) adc 3 ( p 0 . 3 ) adc 2 ( p 0 . 2 ) adc 4 ( p 0 . 4 ) adc 6 ( p 0 . 6 ) adc 5 ( p 0 . 5 ) adc 0 ( p 0 . 0 / opo ) adc 7 ( p 0 . 7 ) 1 0 fcpu rc_ clk ( internal rc 11 . 0592 mhz or 22 . 1184 mhz , selectable by config 1 . fs 1 bit ) prescaler / 8 , / 4 , / 2 , / 1 adclk 1 , adclk 0 bits ( sfr adccon 1 ) default : divided by 2 . adc clock [ 01 ] [ 10 ] 00 11 01 10 pwm 0 stadct . 1 ~ 0 pwmsrc . 1 ~ 0 bits stadct . 1 ~ 0 pwm 2 pwm 4 pwm 6 8 - bit up counter adcdly register adci / 1 , / 2 fcpu / 4 = reset eoc * reset pulse dlydiv bit pwm _ strt _ pulse * * notes eoc - end of conversion single pulse signal . pwm _ strt _ pulse - this pulse will be generated when detected a valid start . this signal will remain low in the event of potential multiple pwm or adcs triggers that arrives before current conversion in progress completed . an aborted conversion by clearing adcen will assert this pulse to clear the counter . [ 11 ] adc clock range : @ 5 v : 200 khz to 20 mhz @ 3 v : 200 khz to 12 mhz note 1 00 ~ 00 figure 26- 2 : adc block diagram note: ? the adc0 alternative input source will co me from op amplifier output when auxr2.enop bit is enabled. see section op amplifier for detail. user is recommended to set sfr padids.0 to disable digital input when enable enop. see figure 26 - 3 for adc0 and adc1 source selection. ? the adc1 alternative input source will come from brownout reference voltage, v br . it can be selected through auxr2.adc1sel bit. refer to figure 28 - 1: comparators block diagram for the detail. p0.0 op output enop adc0 (sfr) p0.1 1 0 v br adc1 adc1sel (sfr) brownout reference voltage figure 26- 3 : adc0 and adc1 source selections. preliminary N79E875 data s heet publication release date: april 13, 2009 - 173 - revision a02 26.1.2 adc start synchronous with pwm besides software start and external pin stadc (p1.7) to start adc conve rsion, this device has new feature to allow pwm even channels to trigger the adc start. user may configure any one of the pwm as well as trigger types; rising, falling pwm edge or central point of pwm (centre - aligned mode only) to trigger adc start. the de vice also allow user to configure the amount of delay prior to adc start after hardware detected the pwm edge. see sfr adccon1 and adcdly for bits descriptions. figure below shows the programmable delay time for pwm - triggered adc start conversion. for pwm trigger adc start conversion in centre align mode, adc start conversion point will be at the same, regardless of which pwm channel is selected. delay time delay time starts a/d converting starts a/d converting synchronized with pwm rising edge synchronized with pwm falling edge starts a/d converting synchronized with pwm central point (centre-aligned mode only) delay time figure 26- 4 : pwm - triggered adc sta rt 26.1.3 adc converting in power - dwon and idle mode when adc is operating a conversion, the noise induced by cpu clock effects the adc resolution. N79E875 series allows adc converting in power - down and idle modes to minimize the noise from cpu. software may enab le adc interrupt in advanced then set adcs=1 to start converting and follow setting pd=1(pcon.1) or idl=1(pcon.0) to force cpu entering power - down or idle mode. when the conversion is completed, hardware requests adc interrupt and release cpu from power - do wn or idle mode. note that due to cpu clock stops in power - down mode, software must set rcclk=1 to select adc clock is from internal rc oscillator before cpu enter power - down mode. 26.2 adc resolution and analog supply: the adc circuit has its own supply pins ( avdd and avss) and one pins (vref+) connected to each end of the dac?s resistance - ladder that the avdd and vref+ are connected to vdd and avss is connected to vss. the ladder has 1023 equally spaced taps, separated by a resistance of ?r?. the first tap is located 0.5r above avss, and the last tap is located 0.5r below vref+. this gives a total ladder resistance of 1024r. this structure ensures that the dac is monotonic and results in a symmetrical quantization error. for input voltages between avss and [ (vref+) + ? lsb], the 10 - bit result of an a/d conversion will be 0000000000b = 000h. for input voltages between [(vref+) ? 3/2 lsb] and vref+, the result of a conversion will be 1111111111b = 3ffh. vref+ and avss may be between av dd + 0.2v and av ss ? 0.2 v . vref+ should be positive with respect to avss, and the input voltage (vin) should be between vref+ and avss. the result can always be calculated from the following formula: result = vref vin 1024 + or result = vdd vin 1024 preliminary N79E875 data s heet - 174 - 26.3 adc continu ous mode if adc continuous mode is enabled, a repeated conversion of the selected channel will be performed until adccm or adcs bit is cleared and the new 10 - bit result will overwrite the old data. unlike the normal adc function adcs is cleared automatical ly at the end of a conversion, in this mode, adcs keeps high till software clear it or adccm is cleared and the last conversion is completed. figure below explains the behavior of the adc continuous mode. adcs software set high h/w start converting h/w complete converting & start new conversion adci h/w set s/w clear h/w complete converting & start new conversion h/w set s/w clear h/w complete converting & start new conversion h/w set s/w clear h/w complete converting & stop new conversion h/w set s/w clear adccm software set high software clear software clear software clear adc continuous mode figure 26- 5 : adc continuous mode 26.4 adc compare function N79E875 adc provides the compare function that compares the 10 - bit adc result and an arbitrary 10- bit reference data. the compare result places in adcpo bit. when the new conv ersion result makes adcpo bit change state, the adcpi flag is set by h/w and an adc interrupt is requested if eadcp bit is set in advanced. the block diagram of adc compare function is shown in the following figure. adcpi ( sfr ) eadcp ( sfr ) + - 10- bit adc data 10- bit adc ref adci ( sfr ) eadc ( sfr ) adc interrupt adcpo ( sfr ) adc compare function ( sfr ) ( sfr ) enadcp ( sfr ) figure 26- 6 : adc compare function preliminary N79E875 data s heet publication release date: april 13, 2009 - 175 - revision a02 the 10 - bit reference data adcr.9 - 0 bits (located at sfr adcrh.7 - 0 and adcrl.7 - 6) are writable only when enadcp = 0. user will have to take of potential false trigger when changing the reference data. the following is the recommended procedure note when using adc compare function. 1. disable adc compare function (enadcp=0). 2. disable adc compare function interrupt (eadcp=0). 3. update 10 - bit adc ref registers. 4. clear adcpi flag (this is to avoi d unwanted compare trigger due to new reference data). 5. enable adc compare function (enadcp=1). 6. e nable compare function interrupt ( eadcp=1 ) . 7. start next adc conversion. preliminary N79E875 data s heet - 176 - 27 op amplifier this device integrated an operational amplifier. it can be enabled throug h sfr opcon.enop bit. user can measure the output of the operational amplifier as the operation amplifier output to the integrated analog digital convert channel 0, where digital result can be taken. - + p3.6/opp p3.7/opn op amplifier enable op amplifier enop (sfr) p0.0/adc0/kb0/opo av enop: enable op amplifier 0: disable op amplifier 1: enable op amplifier and the op output is connected to adc0 to adc channel 0 figure 27- 1 : operation amplifier block diagram note: ? user is required to set auxr2.popdids bit to disable digital input at p3.6 (opp) and p3.7 (opn) pins, when using op amplifier. ? the adc0 alternative input source will come from o p amplifier output when auxr2.enop bit is enabled. user is recommended to set sfr padids.0 to disable digital input when enable enop. preliminary N79E875 data s heet publication release date: april 13, 2009 - 177 - revision a02 28 analog comparators this device is also provided with two comparators. the comparators can be used in a number of differ ent configurations. the comparator output is a logical one when positive input greater than negative input, otherwise the output is a zero. each comparator can be configured to cause to an interrupt when the comparator output value changes. the block diagr am is as below. the inputs are cpnp and cpnn, and outputs cpno (n = 1 or 2). user may select the internal reference voltage by enable sfr cmpn.cnn bit. the typical value of internal brownout reference voltage (v br ) is about 1. 16 v +/ - 10 %. - + cmf 1 cn1 v br = 1 . 18 v co 1 change detect comparator 1 p 0 . 3 / adc 3 / cp 1 p / kbi . 3 p 0 . 4 / adc 4 / cp 1 n / kbi . 4 - + cn2 co 2 comparator 2 cmp 1 analog circuit cmp 2 analog circuit enable comparator 1 brownout reference voltage cmpen 1 cmpen 2 cmf 2 change detect enable comparator 2 p 0 . 1 / adc 1 / cp 2 pa / kb 1 p 0 . 2 / adc 2 / cp 2 na / kb 2 ( sfr ) ( sfr ) ( sfr ) ( sfr ) ( sfr ) ( sfr ) comparator interrupt eci ( sfr ) p 2 . 1 / pwm 2 / cp 1 o ( sfr ) ( sfr ) 1 0 p 2 . 0 / pwm 0 / cp 2 o coe 2 ( sfr ) p 2 . 0 ( sfr ) 1 0 coe 1 ( sfr ) p 2 . 1 ( sfr ) cn1 ( sfr ) ( sfr ) cn2 p 4 . 1 / cp 2 pb p 4 . 0 / cp 2 nb cp 2 ( sfr ) p 2 . 1 ( sfr ) 1 0 cmpen 1 & coe 1 ( sfr ) 1 co 1 1 0 pio . 2 p 2 . 1 / pwm 2 / cp 1 o pwm 2 p 2 . 0 ( sfr ) 1 0 cmpen 2 & coe 2 ( sfr ) 1 co 2 1 0 pio . 0 pwm 0 p 2 . 0 / pwm 0 / cp 2 o figure 28- 1 : comparators block diagram note: when using the both comparators, user should set sfr padids.1 - 2, padids.3 - 4 or auxr2.4 - 5 bits accordingly to disable digital input at the comparator s? input pins. both comparators have hysterisis function that is controllable through hysen1 and hysen2 bits. preliminary N79E875 data s heet - 178 - 29 icp (in - circuit program) fla sh program the icp(in - circuit - program) mode is another approach to access the flash eprom. there are only 3 pins n eeded to perform the icp function. one is mode input, shared with / rst pin, which is up to 11 volt in icp working period. one is clock input, shared with p 0.5 , which accepts serial clock from external device. another is data i/o pin, shared with p 0.4 , that an external icp program tool shifts in/out data via p 0.4 synchronized with clock(p 0.5 ) to access the flash eprom of N79E875 series . user may refer to http://www.manley.com.cn/english/index.asp f or icp program tool. w 79 e 87 x p 1 . 4 / rst [ 3 ] p 0 . 4 p 0 . 5 vdd vss to application vdd vpp data clock vss icp programmer vcc jumper [ 1 ] icp connector system board icp power jumper to application to application note : 1 . circuitry separation is optionally needed between icp and application during icp operation . 2 . resistor is optional by application 3 . voltage of p 1 . 4 is up to about 11 v during icp peration [ 2 ] [ 2 ] [ 2 ] [ 2 ] notes: when using icp to upgrade code, the p1.4, p0.4 and p0.5 must be taken within design system board. after program finished by icp, to suggest system power must be off and remove icp connector th en power on. it is recommended that user performs erase function and programming configure bits continuously without any interruption. during icp mode, all pwm pins will be tri - stated. preliminary N79E875 data s heet publication release date: april 13, 2009 - 179 - revision a02 30 config bits the N79E875 series has two config bits (config0 located at fb00h, config1 located at fb01h) that must be defined at power up and can not be set the program after start of execution. those features are configured through the use of two flash eprom bytes, and the flash eprom can be programmed and verified repeat edly. until the code inside the flash eprom is confirmed ok, the code can be protected. the protection of flash eprom (config1) and those operations on it are described below. the data of these bytes may be read by the mov x instruction at the addresses. 30.1 c onfig0 config0 bit: 7 6 5 4 3 2 1 0 wdtck rpd prhi cbov1 cbov0 bpfr fosc1 fosc0 bit name function 7 wdtck clock source of watchdog timer select bit: 0: the internal 500khz rc oscillator clock is for watchdog timer clock used. 1: the uc clock is for w atchdog timer clock used. 6 rpd reset pin disable bit: 0: enable reset function of pin 1.4. 1: disable reset function of pin 1.4, and it to be used as an input port pin. 5 prhi port reset high or low bit: 0: port reset to low state. 1: port reset to hig h state. 4 - 3 cbov.1 - 0 brownout voltage select bits: 00: brownout detect voltage is 4.5v. 01: brownout detect voltage is 3.8v. 1 x : brownout detect voltage is 2. 6 v (default). 2 bpfr bypass clock filter of crystal oscillator bit: 0: disable clock filter . 1 : enable clock filter . ( default ) preliminary N79E875 data s heet - 180 - 1 - 0 fosc1 - 0 cpu oscillator type select bit s fosc1 fosc0 osc source 0 0 4mhz ~ 40mhz crystal 0 1 internal rc oscillator, 22.1184mhz/11.0592mhz 1 0 reserved 1 1 external oscillator in xtal1 preliminary N79E875 data s heet publication release date: april 13, 2009 - 181 - revision a02 30.2 config1 config1 bit: 7 6 5 4 3 2 1 0 c7 c6 fs1 - scf - pwm_even pwm_odd bit name function 7 c7 16k - byte ap flash eprom lock bit : 0: the 16k - byte embedded ap flash eprom and config registers are protected from reading through any programming tool . 1: the 16 - byte embedded ap f lash and config registers are not locked that can be read by external programming tool. 6 c6 128- byte data flash lock bit : 0: the 128 - byte data flash is protected from reading through any programming tool . 1: the 128 - byte data flash is not locked that can be read by external programming tool. refer to the below table for more detail. 5 fs1 internal oscillator 22.1184mhz/11.0592mhz select bit 0: internal osc frequency is 11.0592mhz . 1 : internal osc frequency is 22.1184mhz . (default) 4 reserved reserved bit and must be kept high. 3 scf select crystal frequency : this bit is used to adjust the oscillation circuit to meet the external crystal frequency. 0: for external crystal frequency < 24mhz . 1 : for external crystal frequency > 24mhz . 2 reserved reserved b it and must be kept high. 1 pwm_even pwm even channels driving mode select bit 1: the driving mode of even pwm pins is forced to hi - z mode all the time. 0: the driving mode of even pwm pins is controlled by output mode register (pxmy). this bit is latched to sfr pwmcon3.hz_even after all reset . preliminary N79E875 data s heet - 182 - 0 pwm_odd pwm odd channels driving mode select bit 1: the driving mode of odd pwm pins is forced to hi - z mode all the time. 0: the driving mode of odd pwm pins is controlled by output mode register (pxmy). this bit is latched to sfr pwmcon3.hz_ odd after all reset . lock bits control list: b it 7 bit 6 function description 1 1 both security of 16k - byte ap flash and 128 - byte data flash are not lock ed. they can be erased, programmed or read by writer , icp or jtag mode . 0 1 the 16k - byte ap flash is lock ed but 128 - byte data flash is not locked. 16k - byte ap flash ; ? i t ca n? t be read by writer , icp or jtag mode . 128- byte data flash ; ? it can still support program or read by writer, icp or jtag mode. ? b ank erase of this data area is supported in icp . 1 0 not support ed. 0 0 both security of 16k - byte ap flash and 128 - byte data flash are locked . they can ? t be read by write r, icp or jtag mode . preliminary N79E875 data s heet publication release date: april 13, 2009 - 183 - revision a02 31 electrical character istics 31.1 absolute maximum ratings symbol parameter min max unit dc power supply vdd ? vss - 0.3 +7.0 v input voltage vin vss - 0.3 vdd+0.3 v oscillator frequency 1/t clcl 0 40 mhz operating temperature ta - 40 + 8 5 c storage temperature t st - 55 +150 c maximum current into v dd - 120 ma maximum current out of v ss 120 ma maximum current sunk by a i/o pin 3 5 ma maximum current sourced by a i/o pin 3 5 ma maximum current sunk by total i/o pins 100 ma maximum current sourced by total i/o pins 100 ma note: exposure to conditions beyond those listed under absolut e maximum ratings may adversely affects the lift and reliability of the device. preliminary N79E875 data s heet - 184 - 31.2 dc electrical characteristics (ta = - 40~ 8 5 c, unless otherwise specified.) parameter sym. specification test conditions min. typ. max. unit operating voltage v dd 2.4 5.5 v v dd =4.5v ~ 5.5v up to 40mhz v dd = 3.0 v ~ 5.5v up to 24mhz v dd =2.4v ~ 5.5v up to 8mhz 3.0 - 5.5 p rogram and erase data flash . operating current i dd1 15 22 ma v dd = 5.0v @ 40mhz, no load, /rst = vss 7.5 ma v dd = 3.0v @ 24mhz, no load, /rst = v ss i dd2 40 ma v dd = 5.0v @ 40mhz, no load, /rst = v dd , run nop 12 ma v dd = 3.0v @ 24mhz, no load, /rst = v dd , run nop idle current i idle 22 ma v dd = 5.5v, 40mhz, no load 7 ma v dd = 3.0v, 24mhz, no load power down current i pwdn 1 10 preliminary N79E875 data s heet publication release date: april 13, 2009 - 185 - revision a02 positive going threshold (schmitt input), /rst v ihs 0.7v dd - v dd +0.5 v hysteresis voltage v hy 0.2v dd v source current p0, p1, p2, p3, p4 (quasi - bidirectional mode) i sr11 -150 -210 -360 a v dd = 4.5v, v s = 2.4v i sr12 -35 -40 -60 a v dd = 2.7v, v s = 2.2v i sr12 -18 -27 -40 a v dd = 2.4v, v s = 2.0v source current p0, p1, p2, p3, p4 (push - pulll mode) i sr21 12 16 20 ma v dd = 4.5v, v s = 3.0v i sr22 6 8 10 ma v dd = 2.7v, v s = 2.2v i sr22 2.5 3.5 4.5 ma v dd = 2.4v, v s = 2.0v sink current p0, p1, p 2, p3, p4 (quasi - bidirectional and push- pull mode) i sk1 18 25 32 ma v dd = 4.5v, v s = 0. 4 5v i sk1 15 20 25 ma v dd = 2.7v, v s = 0.45v i sk1 13 17 21 ma v dd = 2.4v, v s = 0.45v brownout voltage with bov[1:0] =0 x b v bo2. 5 2. 40 2. 5 2. 60 v brownout voltage wi th bov[1:0] =10b v bo3.8 3.6 0 3. 75 3.9 0 v brownout voltage with bov[1:0] =11b v bo4.5 4.3 0 4.5 4. 70 v hysterisis range of bod voltage v bh 50 - 140 mv v dd = 2.4v~5.5v notes: 1. /rst pin is a schmitt trigger input. 2. xtal1 is a cmos input. 3. pins of p0, p1, p2, p3 and p4 can source a transition current when they are being externally driven from 1 to 0. the transition current r eaches its maximum value when vin approximates to 2v. preliminary N79E875 data s heet - 186 - 31.3 adc converter dc electrical characteristics (v dd ? v ss = 3. 3 ~5v, ta = - 40~ 8 5 c, adc clock =12mhz , av dd is independent 1 , unless otherwise specified.) parameter symbol specification test conditions min. typ. max. unit analog input avin a v ss - 0.2 a v dd +0.2 v adc clock adcclk 200khz - 20 mhz hz v dd = 5.0v. 12mhz v dd = 3.3v. adc current consumption (adc enable) i adc 3.0 ma v dd =5.0v adcclk=11.059mhz adc input=gnd i adc 2.2 ma v dd =3.3v adcclk=11.059mhz adc input=gnd conversion time t c 34t adc 2 us differential non - linearity dnl - 1 - +1 lsb integral non - linearity inl - 2 - +2 lsb offset error ofe - 0.5 - + 3.0 lsb gain error ge - 0. 6 - + 0. 1 % absolute voltage error ae - 4 - 5 - + 4 +5 lsb v dd = 5.0v. v dd = 3.3v. notes: 1. av dd need s clear power*, power noise is small er than 0.5lsb for test condition of resolution. suggest don?t connect a v dd to d v dd directly without any isolation device *clear power for test 8 - bit resolution of 10bit - saradc, power noise need small er than 2lsb of adc. if av dd is 5v, power noise need small than 9.5mv. 2 . t adc : the period time of adc input clock. preliminary N79E875 data s heet publication release date: april 13, 2009 - 187 - revision a02 31.4 op amplifier electrical characteristics (v dd ? v ss = 3.0~5v, ta = - 40~ 8 5 c, fcpu = 16mhz, unless otherwise specified.) parameters specification unit conditions min. typ. max. temperature - 40 25 8 5 v dd 2.4 - 5.5 v op power current - - 2 ma v dd =5v, t= 8 5 input offset voltage - - 20 m v input offset average drift - - 1 uv/ output swing 0.1 - v dd - 0.1 v input common mode range 0.1 - v dd - 1.2 v dc gain - 80 - db unity gain freq. 4 - 5.5 mhz v dd =5v phase margin 50 - ps rr+ - 90 - db v dd =5v cmrr - 90 - db v dd =5v slew rate+ - 6.0 7.5 v/us v dd =5v slew rate - - 6.0 7.5 v/us v dd =5v wake up time - - 20 us preliminary N79E875 data s heet - 188 - 31.5 comparator electrical characteristics (v dd ? v ss = 3.0~5v, ta = - 40~ 8 5 c, fcpu = 16mhz, unless otherwise specified.) parameters specification unit conditions min. typ. max. temperature - 40 25 8 5 v dd 2.4 3 5.5 v power current - 20 40 ua output swing 0.1 - v dd - 0.1 v input common mode range (v cm ) 0.1 - v dd - 1.3 v dc gain - 70 - db design guarantee propagation delay - 200 - ns @ v cm =1v & vdiff=0.1v comparison voltage 10 20 - mv 20mv@ v cm =1v 50mv@ v cm =0.1v 50mv@ v cm =v dd - 1.3 @10mv for non - hysteresis hysteresis - 20 35 mv @ v cm =0.5v ~ v dd - 1.3v wake up time - - 2 us @cinp=0.9v & cinn=1v brownout reference voltage [1] (v br ) 1.13 1.11 1.16 1.14 1.20 1.18 v v dd = 5.0v. v dd = 3. 0 v. notes: 1. value is guideline only and not tested . preliminary N79E875 data s heet publication release date: april 13, 2009 - 189 - revision a02 31.6 ac electrical characteristics t clcl t clcx t chcx t clch t chcl note: duty cycle is 50%. 31.6.1 external clock characteristics parameter symbol min. typ. max. units notes clock high time t chcx 12.5 - - ns clock low tim e t clcx 12.5 - - ns clock rise time t clch - - 10 ns clock fall time t chcl - - 10 ns 31.6.2 supplied voltage - frequency supplied voltage v dd operating cpu clock unit min. typ. max. v dd =4.5v ~ 5.5v 40 mhz v dd = 3.0 v ~ 5.5v 24 mhz v dd =2.4v ~ 5.5v 8 mhz 31.6.3 internal rc oscillator characteristics (vdd ? vss = 2. 4 ~5v, ta = - 40~85 c.) parameter specification (reference) test conditions min. typ. max. unit fosc of n 79e 875 on - chip rc oscillator without calibration. nominal value of fosc is about 22mhz/11m hz. - 2 5 2 5 % v dd = 2.4v~5.5v , ta = -40c ~8 5 c fosc of n 79e 875r on - chip rc oscillator with calibration 1,2 nominal value of fosc is 2 2.1184 mhz /11.0592mhz - 2 2 % v dd = 3.3v , ta = 25c - 5 5 % v dd = 2. 7 v~ 5 .5 v, ta = -20 ~85 c - 8 8 % v dd = 2. 7 v~ 5 .5 v, ta = -40~ 8 5 c wakeup time 256 clk preliminary N79E875 data s heet - 190 - note : 1. these values are for design guidance only and are not tested. 31.6.4 typical crystal application circuits crystal c1 c2 r >24mhz 5p~15p 5p~15p 1.8k~2.2k 4mhz ~ 24 mhz without without without preliminary N79E875 data s heet publication release date: april 13, 2009 - 191 - revision a02 32 package dimens i ons 32.1 48l lqfp (7x7x1.4mm footprint 2.0mm) y seating plane d e e b a2 a1 a 1 12 48 d h e h l1 l c controlling dimension : millimeters 0.10 0 7 0 0.004 1.00 0.75 0.60 0.45 0.039 0.030 0.024 0.018 9.10 9.00 8.90 0.358 0.354 0.350 0.50 0.20 0.25 1.45 1.40 0.10 0.15 1.35 0.008 0.010 0.057 0.055 0.026 7.10 7.00 6.90 0.280 0.276 0.272 0.004 0.006 0.053 symbol min nom max max nom min dimension in inch dimension in mm a b c d e h d h e l y 0 a a l 1 1 2 e 0.008 0.006 0.15 0.20 7 0.020 0.35 0.65 0.10 0.05 0.002 0.004 0.006 0.15 9.10 9.00 8.90 0.358 0.354 0.350 7.10 7.00 6.90 0.280 0.276 0.272 0.014 37 36 25 24 13 preliminary N79E875 data s heet - 192 - 33 revision history version date page / chap. description a 01 december 30, 200 8 - initial issued a02 april 13, 2009 all all ch7 101 ch7 a. remove n79m8xx, 874 & 873 series and change 125 c to 85c . b. revise typos in the document. c. rename pdtc1(abh) to dtcnt d. revise typo in figure 15- 2 . (change p4s to p2s) e. remove ? b od = inverse (c b od) config bit ? important notice nuvoton products are neither intended nor warranted for usage in systems or equipment, any malfunction or failure of which may cause loss of human life, bodily injury or severe property damage. such ap plications are deemed , ?insecure usage?. insecure usage includes, but is not limited to: equipment for surgical implementation, atomic energy control instruments, airplane or spaceship instruments, the control or operation of dynamic, brake or safety systems designed for vehicular use, traffic si gnal instruments, all types of safety devices, and other applications intended to support or sustain life. all insecure usage shall be made at customer?s risk, and in the event that third parties lay claims to nuvoton as a result of customer?s insecure u sage, customer shall indemnify the damages and liabilities thus incurred by nuvoton. |
|
Price & Availability of N79E875
|
|
|
|
|
All Rights Reserved © IC-ON-LINE 2003 - 2022 |
| [Add Bookmark] [Contact Us] [Link exchange] [Privacy policy] |
|
Mirror Sites : [www.datasheet.hk]
[www.maxim4u.com] [www.ic-on-line.cn]
[www.ic-on-line.com] [www.ic-on-line.net]
[www.alldatasheet.com.cn]
[www.gdcy.com]
[www.gdcy.net] |