Part Number Hot Search : 
N4730 MNAC34S 1778780 120FC HY5N50FT IPS031S TPC6005 CRX0505N
Product Description
Full Text Search
 

To Download W79E825ADG Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  w79e825/824/823/822 data sheet 8-bit microcontroller publication release date: december 27, 2007 - 1 - revision a8 table of contents- 1 general des cription ......................................................................................................... 4 2 features ....................................................................................................................... .......... 5 3 parts inform ation list ..................................................................................................... 6 3.1 lead free (rohs) parts informati on li st......................................................................... 6 4 pin config uration .............................................................................................................. . 7 5 pin descri ption................................................................................................................ ..... 8 6 functional d escription.................................................................................................... 9 6.1 on-chip fl ash eprom .................................................................................................. 9 6.2 i/o ports...................................................................................................................... .... 9 6.3 timers ......................................................................................................................... .... 9 6.4 interrupts..................................................................................................................... .... 9 6.5 data po inters .................................................................................................................. 9 6.6 architecture................................................................................................................... 10 6.6.1 alu ................................................................................................................... 10 6.6.2 accumulator ...................................................................................................... 10 6.6.3 b register.......................................................................................................... 10 6.6.4 program stat us word:....................................................................................... 10 6.6.5 scratch- pad ram .............................................................................................. 10 6.6.6 stack pointer ..................................................................................................... 11 6.7 power m anagem ent...................................................................................................... 11 7 memory orga nization...................................................................................................... 12 7.1 program memory (o n-chip flash) ................................................................................. 12 7.2 data me mory ................................................................................................................ 12 7.3 register map................................................................................................................. 13 7.4 working re gisters......................................................................................................... 16 7.5 bit addressabl e locations............................................................................................. 16 7.6 stack .......................................................................................................................... ... 16 8 special function registers ......................................................................................... 17 9 instruction set................................................................................................................ .. 48 9.1 instruction timing.......................................................................................................... 56 10 power mana gement.......................................................................................................... 59 10.1 idle mode ...................................................................................................................... 59 10.2 power down mode ....................................................................................................... 59 11 reset cond itions............................................................................................................... 60 11.1 sources of reset............................................................................................................ 60 11.1.1 external reset ................................................................................................. 60
w79e825/824/823/822 data sheet - 2 - 11.1.2 power-on rese t (por)................................................................................... 60 11.1.3 watchdog time r reset.................................................................................... 60 11.2 reset state ................................................................................................................... 60 12 interrupts ..................................................................................................................... ...... 63 12.1 interrupt sources .......................................................................................................... 63 12.2 priority level structure ................................................................................................. 65 12.3 response time............................................................................................................. 66 12.4 interrupt inputs.............................................................................................................. 67 13 programmable time rs/counters ............................................................................... 69 13.1 timer/counter s 0 & 1.................................................................................................... 69 13.1.1 time-base selection ....................................................................................... 69 13.1.2 mode 0............................................................................................................. 69 13.1.3 mode 1............................................................................................................. 70 13.1.4 mode 2............................................................................................................. 71 13.1.5 mode 3............................................................................................................. 71 14 nvm memory ..................................................................................................................... .... 73 15 watchdog timer................................................................................................................. 75 15.1 watchdog control.............................................................................................. 76 15.2 clock control of watchdog.................................................................................. 77 16 serial port (uart) ............................................................................................................. 78 16.1 mode 0 ........................................................................................................................ 78 16.2 mode 1 ........................................................................................................................ 79 16.3 mode 2 ........................................................................................................................ 81 16.4 mode 3 ........................................................................................................................ 82 16.5 framing error detection ............................................................................................... 83 16.6 multiprocessor communications................................................................................... 83 17 time access pr octection .............................................................................................. 85 18 keyboard interrupt (kbi) ............................................................................................... 87 19 analog com parators ...................................................................................................... 88 20 i/o port configuration ................................................................................................... 89 20.1 quasi-bidirectional ou tput config uration ..................................................................... 89 20.2 open drain output configuration ................................................................................. 90 20.3 push-pull output configuration .................................................................................... 91 20.4 input only co nfiguration ............................................................................................... 91 21 oscillator ..................................................................................................................... ...... 92 21.1 on-chip rc osc illator op tion....................................................................................... 92 21.2 external clock input option .......................................................................................... 93 21.3 cpu clock rate select ................................................................................................. 93 22 power monitoring function ........................................................................................ 94 22.1 power on detect........................................................................................................... 94 22.2 brownout detect ........................................................................................................... 94 23 pulse-width-modulated (pwm) ou tputs ................................................................... 95
w79e825/824/823/822 data sheet publication release date: december 27, 2007 - 3 - revision a8 24 analog-to-digita l converter ...................................................................................... 99 24.1 adc resolution and analog supply: .......................................................................... 100 25 i2c serial control .......................................................................................................... 102 25.1 sio port ...................................................................................................................... 102 25.2 the i2c contro l registers: ......................................................................................... 103 25.2.1 the address regi sters, i2addr................................................................... 103 25.2.2 the data regi ster, i2dat ............................................................................. 103 25.2.3 the control regi ster, i2con ........................................................................ 104 25.2.4 the status regi ster, i2status ................................................................... 104 25.2.5 the i2c clock baud ra te bits, i2clk .......................................................... 104 25.3 modes of operation .................................................................................................... 105 25.3.1 master transm itter mode .............................................................................. 105 25.3.2 master receiver mode .................................................................................. 105 25.3.3 slave receiv er mode .................................................................................... 105 25.3.4 slave transm itter mode ................................................................................ 106 25.4 data transfer flow in five oper ating modes............................................................. 106 26 icp(in-circuit progra m) flash program ................................................................ 112 27 config bits .................................................................................................................... ..... 113 27.1 config1 .................................................................................................................... 113 27.2 config2 .................................................................................................................... 114 28 electrical cha racteristics....................................................................................... 116 28.1 absolute maxi mum ratings ........................................................................................ 116 28.2 dc electrical ch aracteristics .................................................................... 116 28.3 the adc converter dc elec trical chara cteristics ................................... 118 28.4 the comparator electr ical characteristics ........................................ 118 28.5 ac electrical ch aracteristics .................................................................... 118 28.6 external clock ch aracteristics ................................................................ 119 28.7 ac specific ation .................................................................................................. 119 28.8 typical applicat ion cir cuits .......................................................................... 119 29 package dime nsio ns ....................................................................................................... 120 29.1 20-pin sop ................................................................................................................. 120 29.2 20-pin dip ................................................................................................................... 121 29.3 24-pin sop ................................................................................................................. 122 30 revision histor y .............................................................................................................. 123
w79e825/824/823/822 data sheet - 4 - 1 general description the w79e825 series are an 8-bit turbo 51 microcontroller which has an in-system programmable flash eprom which flash eprom can program by icp (in circuit program) or by hardware writer. the instruction set of the w79e825 series are fu lly compatible with the standard 8052. the w79e825 series contain a 16k/8k/4k/2k bytes of main flash eprom; a 256/128 bytes of ram; 256/128 bytes nvm data flash eprom; two 8-bit bi-directional , one 2-bit bi-directional and bit-addressable i/o ports; two 16-bit timer/counters; 4-channel multip lexed 10-bit a/d convert; 4-channel 10-bit pwm; two serial ports that include a i2c and an enhanced full duplex serial port. these peripherals are supported by 13 sources four-level interrupt capability. to facilitate programming and verification, the flash eprom inside the w79e825 series allow the program memory to be programmed and read electronically. once the code is confirmed, the user can protect the code for security.
w79e825/824/823/822 data sheet publication release date: december 27, 2007 - 5 - revision a8 2 features ? fully static design 8-bit turbo 51 cmos micr ocontroller up to 20mhz when vdd=4.5v to 5.5v, 12mhz when vdd=2.7v to 5.5v ? 16k/8k/4k/2k bytes of ap flash eprom, with icp and external writer programmable mode. ? 256/128 bytes of on-chip ram. ? 256/128 bytes nvm data flash eprom for customer data storage used and 10k writer cycles. ? instruction-set compatible with msc-51. ? two 8-bit bi-directional and one 2-bit bi-directional ports. ? two 16-bit timer/counters. ? 13 interrupts source with four levels of priority. ? one enhanced full duplex serial port with fr aming error detection and automatic address recognition. ? the 4 outputs mode and ttl/schmitt trigger selectable port. ? programmable watchdog timer. ? four -channel 10-bit pwm (pulse width modulator). ? four-channel multiplexed with 10-bits a/d convert. ? one i2c communication port (master / slave). ? eight keypad interrupt inputs. ? two analog comparators. ? configurable on-chip oscillator. ? led drive capability (20ma) on all port pins. ? low voltage detect interrupt and reset. ? development tools: - jtag ice(in circuit emulation) tool - icp(in circuit programming) writer ? packages: - lead free (rohs) dip 20: W79E825ADG - lead free (rohs) dip 20: W79E825ADG - lead free (rohs) sop 20: w79e825asg - lead free (rohs) dip 20: w79e824adg - lead free (rohs) sop 20: w79e824asg - lead free (rohs) dip 20: w79e823bdg - lead free (rohs) sop 20: w79e823bsg - lead free (rohs) dip 20: w79e822bdg - lead free (rohs) sop 20: w79e822bsg
w79e825/824/823/822 data sheet - 6 - 3 parts information list 3.1 lead free (rohs) parts information list part no. eprom flash size ram nvm flash eprom package remark W79E825ADG 16kb 256b 256b dip-20 pin w79e825asg 16kb 256b 256b sop-20 pin w79e824adg 8kb 256b 256b dip-20 pin w79e824asg 8kb 256b 256b sop-20 pin w79e823bdg 4kb 128b 128b dip-20 pin w79e823bsg 4kb 128b 128b sop-20 pin w79e822bdg 2kb 128b 128b dip-20 pin w79e822bsg 2kb 128b 128b sop-20 pin table 3-1: lead free (rohs) parts information list
w79e825/824/823/822 data sheet publication release date: december 27, 2007 - 7 - revision a8 4 pin configuration 1 2 20 19 18 17 16 15 14 13 12 11 3 4 5 6 7 8 9 10 pwm3/cmp2/p0.0 pwm2/p1.7 pwm1/p1.6 rst/p1.5 vss xtal1/p2.1 xtal2/clkout/p2.0 int1/p1.4 sda/int0/p1.3 scl/t0/p1.2 p0.1/cin2b/pwm0 p0.2/cin2a/brake p0.3/cin1b/ad0 p0.4/cin1a/ad1 p0.5/cmpref/ad2 vdd p0.6/cmp1/ad3 p0.7/t1 p1.0/txd p1.1/rxd 20 pin dip 1 2 20 19 18 17 16 15 14 13 12 11 3 4 5 6 7 8 9 10 pwm3/cmp2/p0.0 pwm2/p1.7 pwm1/p1.6 rst/p1.5 vss xtal1/p2.1 xtal2/clkout/p2.0 int1/p1.4 sda/int0/p1.3 scl/t0/p1.2 p0.1/cin2b/pwm0 p0.2/cin2a/brake p0.3/cin1b/ad0 p0.4/cin1a/ad1 p0.5/cmpref/ad2 vdd p0.6/cmp1/ad3 p0.7/t1 p1.0/txd p1.1/rxd 20 pin sop figure 4-1: pin configuration
w79e825/824/823/822 data sheet - 8 - 5 pin description symbol type descriptions st r (p1.5) i reset: a low on this pin for two machine cycles while the oscillator is running resets the device. xtal1(p2.1) i/o crystal1: this is the crystal oscilla tor input. this pin may be driven by an external clock or configurable i/o pin. xtal2(p2.0) i/o crystal2: this is the crystal osc illator output. it is the inversion of xtal1 or configurable i/o pin. vss p ground: ground potential vdd p power: supply: s upply voltage for operation. p0.0 ? p0.7 i/o port 0: port 0 is four mode output pin and two mode input. the p0.3~p0.6 are 4-channel input por ts (adc0-adc3) for adc used. p1.0 ? p1.7 i/o port 1: port 1 is four mode output pin and two mode input. the p1.2 (scl) and p1.3 (sda) is only open drain circuit, and p1.5 only input pin. * type: p: power, i: input, o: output, i/o: bi-directional, h: pull-high, l: pull-low, d: open-drain . table 5-1: pin description
w79e825/824/823/822 data sheet publication release date: december 27, 2007 - 9 - revision a8 6 functional description the w79e825 series architecture consist of a 4t 805 1 core controller surrounded by various registers, 16k/8k/4k/2k bytes flash eprom, 256/128 bytes of ram, 256/128 bytes nvm data flash eprom, three general purpose i/o ports, two timer/counters, one serial port, one i2c serial i/o, 4 channel pwm with 10-bit counter, 4-channel multiplex ed with 10-bit adc analog input, flash eprom program by writer and icp. 6.1 on-chip flash eprom the w79e825 series include one 16k/8k/4k/2k bytes of main flash eprom for application program. a writer or icp programming board is required to program the flash eprom or nvm data flash eprom. this icp (in-circuit programming) feature makes t he job easy and efficient when the application?s firmware needs to be updated frequently . in some applications, the in-circuit programming feature makes it possible for the end-user to easily update the system firmware without opening the chassis. 6.2 i/o ports the w79e825 series have two 8-bit and one 2-bit port, up to 18 i/o pins using on-chip oscillator & /rst is input only by reset options. all ports can be used as four outputs mode when it may set by pxm1.y and pxm2.y sfr?s registers, it has st rong pull-ups and pull-downs, and does not need any external pull-ups. otherwise it can be used as gene ral i/o port as open drain circuit. all ports can be used bi-directional and these are as i/o ports. thes e ports are not true i/o, but rather are pseudo-i/o ports. this is because these ports have strong pull-downs and weak pull-ups. serial i/o the w79e825 series have one serial port that is functi onally similar to the serial port of the original 8032 family. however the serial port on the w79e825 seri es can operate in different modes in order to obtain timing similarity as well. the serial por t has the enhanced features of automatic address recognition and frame error detection. 6.3 timers the w79e825 series have two 16-bit timers that are functionally and similar to the timers of the 8052 family. when used as timers, the user has a choice of 12 or 4 clocks per count that emulates the timing of the original 8052. 6.4 interrupts the interrupt structure in the w79e825 series is slig htly different from that of the standard 8052. due to the presence of additional features and periphe rals, the number of interrupt sources and vectors has been increased. 6.5 data pointers the data pointers of w79e825 series are same as 8052 that has dual 16-bit data pointers (dptr) by setting dps bit at auxr1.0. the figure of dual dptr is as below diagram.
w79e825/824/823/822 data sheet - 10 - dptr dptr dps auxr1.0 dps=0 dps=1 figure 6-1: dual dptr 6.6 architecture the w79e825 series are based on the standard 8052 devic e. it is built around an 8-bit alu that uses internal registers for temporary storage and cont rol of the peripheral devices. it can execute the standard 8052 instruction set. 6.6.1 alu the alu is the heart of the w79e825 series. it is resp onsible for the arithmetic and logical functions. it is also used in decision making, in case of jump instructions, and is also used in calculating jump addresses. the user cannot direct ly use the alu, but the instru ction decoder reads the op-code, decodes it, and sequences the data through the al u and its associated registers to generate the required result. the alu mainly uses the acc which is a special function register (sfr) on the chip. another sfr, namely b register is also used in multiply and divide instructions. the alu generates several status signals which are stored in the program status word register (psw). 6.6.2 accumulator the accumulator (acc) is the primary register used in arithmetic, logical and data transfer operations in the w79e825 series. since the accumulator is dire ctly accessible by the cpu, most of the high speed instructions make use of the acc as one argument. 6.6.3 b register this is an 8-bit register that is used as the se cond argument in the mul and div instructions. for all other instructions it can be used simply as a general purpose register. 6.6.4 program status word: this is an 8-bit sfr that is used to store the status bits of the alu. it holds the carry flag, the auxiliary carry flag, general purpose flags, the register bank select, the overflow flag, and the parity flag. 6.6.5 scratch-pad ram the w79e825 series have a 256/128 bytes on-chip scratch-pad ram. these can be used by the user for temporary storage during program execution. a ce rtain section of this ram is bit addressable, and can be directly addressed for this purpose.
w79e825/824/823/822 data sheet publication release date: december 27, 2007 - 11 - revision a8 6.6.6 stack pointer the w79e825 series have an 8-bit stack pointer wh ich points to the top of the stack. this stack resides in the scratch pad ram in the w79e825 series . hence the size of the stack is limited by the size of this ram. 6.7 power management power management like the standard 8052, the w 79e825 series also have the idle and power down modes of operation. in the idle mode, the cl ock to the cpu is stopped while the timers, serial ports and interrupt lock continue to operate. in the power down mode, all clocks are stopped and the chip operation is completely stopped. th is is the lowest power consumption state.
w79e825/824/823/822 data sheet - 12 - 7 memory organization the w79e825 series separate the memory into two separate sections, the program memory and the data memory. the program memory is used to stor e the instruction op-codes, while the data memory is used to store data or for memory mapped devices. 7.1 program memory (on-chip flash) the program memory on the w79e825 series can be up to 16k/8k/4k/2k bytes long. all instructions are fetched for execution from this memory area. th e movc instruction can also access this memory region. 7.2 data memory the nvm data memory of flash eprom on the w79e825 series can be up to 256/128 bytes long. the w79e825 series read the cont ent of data memory by using ?m ovc a, @a+dptr?. to write data is by nvmaddr, nvmdat and nvmcon sfr?s registers. on-chip code memory space 0000h 16k/8k bytes on-chip code memory unused code memory unused code memory config 1 3fffh/1fffh 4000h/2000h ffffh page 0 64 bytes page 1 64 bytes page 2 64 bytes page 3 64 bytes fc00h fc3fh fc40h fc7fh fc80h fcbfh fcc0h fcffh nvm data memory area fc00h config 2 fcffh 256 bytes nvm data memory fbffh figure 7-1: w79e825/824 memory map
w79e825/824/823/822 data sheet publication release date: december 27, 2007 - 13 - revision a8 on-chip code memory space 0000h 4k/2k bytes on-chip code memory unused code memory unused code memory 0fffh/07ffh 1000h/0800h ffffh page 0 64 bytes page 1 64 bytes fc00h fc3fh fc40h fc7fh nvm data memory area fc00h fc7fh 128 bytes nvm data m em ory config 1 config 2 figure 7-2: w79e823/822 memory map 7.3 register map as mentioned before the w79e825 series have sepa rate program and data memory areas. the on- chip 256/128 bytes scratch pad ram is in addition to the external memory. there are also several special function registers (sfrs) which can be accessed by software. the sfrs can be accessed only by direct addressing, while the on-chip ram c an be accessed by either direct or indirect addressing.
w79e825/824/823/822 data sheet - 14 - indirect ram addressing direct & indirect ram addressing sfr direct addressing only 00h 7fh 80h ffh ram and sfr data memory space figure 7-3: w79e825 and w79e824 ram and sfr memory map unused indirect ram direct & indirect ram addressing sfr direct addressing only 00h 7fh 80h ffh ram and sfr data memory space figure 7-4: w79e823 and w79e822 ram and sfr memory map since the scratch-pad ram is only 256/128 bytes it can be used only when data contents are small. there are several other special purpose areas with in the scratch-pad ram. these are described as follows.
w79e825/824/823/822 data sheet publication release date: december 27, 2007 - 15 - revision a8 bank 0 bank 1 bank 2 bank 3 03 02 01 00 04 05 06 07 0b 0a 09 08 0c 0d 0e 0f 13 12 11 10 14 15 16 17 1b 1a 19 18 1c 1d 1e 1f 23 22 21 20 24 25 26 27 2b 2a 29 28 2c 2d 2e 2f 33 32 31 30 34 35 36 37 3b 3a 39 38 3c 3d 3e 3f 43 42 41 40 44 45 46 47 4b 4a 49 48 4c 4d 4e 4f 53 52 51 50 54 55 56 57 5b 5a 59 58 5c 5d 5e 5f 63 62 61 60 64 65 66 67 6b 6a 69 68 6c 6d 6e 6f 73 72 71 70 74 75 76 77 7b 7a 79 78 7c 7d 7e 7f 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 2dh 2eh 2fh 30h 7fh 80h ffh figure 7-5: scratch pad ram
w79e825/824/823/822 data sheet - 16 - 7.4 working registers there are four sets of working r egisters, each consisting of eight 8- bit registers. these are termed as banks 0, 1, 2, and 3. individual registers within these 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 one time the w79e825 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 re gisters are used to store the address for indirect accessing. 7.5 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 individually addresse d. 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 ex isting sfr whose address ends in a 0 or 8 is bit addressable. 7.6 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 t op of the stack. whenever a jump, call or interrupt is invoked the return address is placed on the sta ck. 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 us ed value. therefore, the sp will be incremented and then address saved onto the stack. conversely, wh ile popping from the stack the contents will be read first, and then the sp is decreased.
w79e825/824/823/822 data sheet publication release date: december 27, 2007 - 17 - revision a8 8 special function registers the w79e825 series uses special function register s (sfrs) to control and monitor peripherals and their modes. the sfrs reside in t he register locations 80-ffh and ar e accessed by direct addressing only. some of the sfrs are bit addressable. this is very useful in cases wher e users wish to modify a particular bit without changing the others. the sfrs that are bit addressable are those whose addresses end in 0 or 8. the w79e825 series co ntain 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 given new functions. the list of the sfrs is as follows. f8 ip1 f0 b p0id ip1h e8 eie e0 acc adccon adch d8 wdcon pwmpl pwm0l pwm1l pwmcon1 pwm2l pwm3l pwmcon2 d0 psw pwmph pwm0h pwm1h pwm2h pwm3h pwmcon3 c8 nvmcon nvmdat c0 i2con i2addr nvmaddr ta b8 ip0 saden i2dat i2status i2clk i2timer b0 p0m1 p0m2 p1m1 p1m2 p2m1 p2m2 ip0h a8 ie saddr cmp1 cmp2 a0 p2 kbi auxr1 98 scon sbuf 90 p1 divm 88 tcon tmod tl0 tl1 th0 th1 ckcon 80 p0 sp dpl dph pcon table 8-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 loca tions per row. empty locations indicate that these are no registers at these addresses. when a bit or register is not implemented, it will read high.
w79e825/824/823/822 data sheet - 18 - symbol definition addr ess msb bit_ a ddress, symbol lsb reset ip1 interrupt priority 1 f8h (ff) - (fe) - (fd) ppwm (fc) pwdi (fb) pc2 (fa) pc1 (f9) pkb (f8) pi2 xx000000b ip1h interrupt high priority 1 f7h - - ppwmh pwdih pc2h pc 1h pkbh pi2h xx000000b p0ids port 0 digital input disable f6h 00000000b b b register f0h (f7) (f6) (f5) (f4) (f3) (f2) (f1) (f0) 00000000b eie interrupt enable 1 e8h (ef) - (ee) - (ed) epwm (ec) ewdi (eb) ec2 (ea) ec1 (e9) ekb (e8) ei2 xx000000b adch adc converter result e2h adc.9 adc.8 adc.7 adc.6 adc.5 adc.4 adc.3 adc.2 xxxxxxxxb adccon adc control regi ster e1h adc.1 adc.0 adcex adci adcs rcclk aadr1 aadr0 xx000x00b acc accumulator e0h (e7) (e6) (e5) (e4) (e3) (e2) (e1) (e0) 00000000b pwmcon2 pwm control register 2 dfh bkch bkps bpen bken pwm3b pwm2b pwm1b pwm0b 00000000b pwm3l pwm 3 low bits register deh pwm3.7 pwm3.6 pwm3.5 pwm3.4 pwm3.3 pwm3.2 pwm3.1 pwm3.0 00000000b pwm2l pwm 2 low bits register ddh pwm2.7 pwm2.6 pwm2.5 pwm2.4 pwm2.3 pwm2.2 pwm2.1 pwm2.0 00000000b pwmcon1 pwm control register 1 dch pwmrun load cf c lrpwm pwm3i pwm2i pwm1i pwm0i 00000000b pwm1l pwm 1 low bits register dbh pwm1.7 pwm1.6 pwm1.5 pwm1.4 pwm1.3 pwm1.2 pwm1.1 pwm1.0 00000000b pwm0l pwm 0 low bits register dah pwm0.7 pwm0.6 pwm0.5 pwm0.4 pwm0.3 pwm0.2 pwm0.1 pwm0.0 00000000b pwmpl pwm counter low register d9h pwmp0.7 pwmp0. 6 pwmp0. 5 p wmp0.4 pwmp0. 3 pwmp0. 2 pwmp0.1 pwmp0. 0 00000000b wdcon watch-dog control d8h (df) wdrun (de) - (dd) wd1 (dc) wd0 (db) wdif (da) wtrf (d9) ewrst (d8) wdclr 0x0000x0b pwmcon3 pwm control register 3 d7h - - - - - - - bkf xxxxxxx0b pwm3h pwm 3 high bits register d6h - - - - - - pwm3.9 pwm3.8 xxxxxx00b pwm2h pwm 2 high bits register d5h - - - - - - pwm2.9 pwm2.8 xxxxxx00b pwm1h pwm 1 high bits register d3h - - - - - - pwm1.9 pwm1.8 xxxxxx00b pwm0h pwm 0 high bits register d2h - - - - - - pwm0.9 pwm0.8 xxxxxx00b pwmph pwm counter high register d1h - - - - - - pwmp0. 9 pwmp0. 8 xxxxxx00b psw program status word d0h (d7) cy (d6) ac (d5) f0 (d4) rs1 (d3) rs0 (d2) ov (d1) f1 (d0) p 00000000b nvmdata nvm data cfh 00000000b nvmcon nvm control ceh eer ewr - - - - - - 00000000b ta timed access protection c7h ta.7 ta.6 ta.5 ta.4 ta.3 ta.2 ta.1 ta.0 00000000b nvmaddr nvm address c6h 00000000b i2addr i2c address1 c1h addr.7 addr.6 addr.5 addr.4 addr.3 addr.2 addr.1 gc xxxxxxx0b i2con i2c control register c0h (cf) - (ce) ens1 (cd) sta (cc) sto (cb) si (ca) aa (c9) - (c8) - x00000xxb i2timer i2c timer counter register bfh - - - - - enti div4 tif 00000000b i2clk i2c clock rate beh i2clk.7 i2clk.6 i2c lk.5 i2clk.4 i2clk.3 i2clk.2 i2clk.1 i2clk.0 00000000b i2status bdh 00000000b i2dat bch i2dat.7 i2dat.6 i2dat.5 i2dat.4 i2dat.3 i2dat.2 i2dat.1 i2dat.0 xxxxxxxxb saden slave address mask b9h 00000000b ip0 interrupt priority b8h (bf) - (be) padc (bd) pbo (bc) ps (bb) pt1 (ba) px1 (b9) pt0 (b8) px0 x0000000b ip0h interrupt high priority b7h - pa dch pboh psh pt1h px1h pt0h px0h x0000000b p2m2 port 2 output mode 2 b6h - - - - - - p2m2.1 p2m2.0 xxxxxx00b p2m1 port 2 output mode 1 b5h p2s p1s p0s enclk t1oe t0oe p2m1.1 p2m1.0 00000000b p1m2 port 1 output mode 2 b4h p1m2.7 p1m2.6 - p1m2.4 p1m2.3 p1m2.2 p1m2.1 p1m2.0 00000000b p1m1 port 1 output mode 1 b3h p1m1.7 p1m1.6 - p1m1.4 p1m1.3 p1m1.2 p1m1.1 p1m1.0 00000000b p0m2 port 0 output mode 2 b2h p0m2.7 p0m2.6 p0m2.5 p0m2.4 p0m2.3 p0m2.2 p0m2.1 p0m2.0 00000000b p0m1 port 0 output mode 1 b1h p0m1.7 p0m1.6 p0m1.5 p0m1.4 p0m1.3 p0m1.2 p0m1.1 p0m1.0 00000000b
w79e825/824/823/822 data sheet publication release date: december 27, 2007 - 19 - revision a8 continued symbol definition addr ess msb bit_ a ddress, symbol lsb reset cmp2 comparator 2 control register adh - - ce2 cp2 cn2 oe2 co2 cmf2 00000000b cmp1 comparator 1 control register ach - - ce1 cp1 cn1 oe1 co1 cmf1 00000000b saddr slave address a9h 00000000b ie interrupt enable a8h (af) ea (ae) eadc (ad) ebo (ac) es (ab) et1 (aa) ex1 (a9) et0 (a8) ex0 00000000b auxr1 aux function register a2h kbf bod boi lpbov srst adcen 0 dps 000x0000b kbi keyboard interrupt a1h 00000000b p2 port 2 a0h (a7) - (a6) - (a5) - (a4) - (a3) - (a2) - (a1) xtal1 (a0) xtal2 clkout xxxxxx11b sbuf serial buffer 99h xxxxxxxxb scon serial control 98h (9f) sm0/fe (9e) sm1 (9d) sm2 (9c) ren (9b) tb8 (9a) rb8 (99) ti (98) ri 00000000b divm uc clock divide register 95h 00000000b p1 port 1 90h (97) pwm2 (96) pwm1 (95) /rst (94) /int1 (93) /int0 sdl (92) t0 scl (91) rxd (90) txd 11111111b ckcon clock control 8eh - - - t1m t0m - - - xxx00xxxb th1 timer high 1 8dh 00000000b th0 timer high 0 8ch 00000000b tl1 timer low 1 8bh 00000000b tl0 timer low 0 8ah 00000000b tmod timer mode 89h gate c/t m1 m0 gate c/t m1 m0 00000000b tcon timer control 88h (8f) tf1 (8e) tr1 (8d) tf0 (8c) tr0 (8b) ie1 (8a) it1 (89) ie0 (88) it0 00000000b pcon power control 87h smod smod0 bof por gf1 gf0 pd idl 00xx0000b dph data pointer high 83h 00000000b dpl data pointer low 82h 00000000b sp stack pointer 81h 00000111b p0 port 0 80h (87) t1 (86) ad3 cmp1 (85) ad2 cmpref (84) ad1 cin1a (83) ad0 cin1b (82) brake cin2a (81) pwm0 cin2b (80) pwm3 cmp2 11111111b table 8-2: special function registers
w79e825/824/823/822 data sheet - 20 - port 0 bit: 7 6 5 4 3 2 1 0 p0.7 p0.6 p0.5 p0.4 p0.3 p0.2 p0.1 p0.0 mnemonic: p0 address: 80h p0.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 r ead-modify-write instructions, the por t latch is read. these alternate functions are described below: bit name function 7 p0.7 timer 1 pin or kbi.7 pin of keypad input. 6 p0.6 cmp1 pin of analog comparator or kbi.6 pin of keypad input. 5 p0.5 cmpref pin of analog comparator or kbi.5 pin of keypad input. 4 p0.4 cin1a pin of analog comparator or kbi.4 pin of keypad input. 3 p0.3 cin1b pin of analog comparator or kbi.3 pin of keypad input. 2 p0.2 brake pin of pwm or cin2a pin of anal og comparator or kbi.2 pin of keypad input. 1 p0.1 pwm0 pin or cin2b pin of analog comparator or kbi.1 pin of keypad input. 0 p0.0 pwm3 pin or cmp2 pin of analog comparator or kbi.0 pin of keypad input. note: the initial value of the port is set by config1.prhi bi t. the default setting for config1.prhi =1 which the alternative function output is turned on upon reset. if config1.prhi is set to 0, the user has to write a 1 to port sfr to turn on the alternative function output. stack pointer bit: 7 6 5 4 3 2 1 0 sp.7 sp.6 sp.5 sp.4 sp.3 sp.2 sp.1 sp.0 mnemonic: sp address: 81h bit name function 7-0 sp.[7:0] the stack pointer stores the scratch-pa d ram address where the stack begins. in other words it always points to the top of the stack. data pointer low bit: 7 6 5 4 3 2 1 0 dpl.7 dpl.6 dpl.5 dpl.4 dpl.3 dpl.2 dpl.1 dpl.0 mnemonic: dpl address: 82h bit name function 7-0 dpl.[7:0] this is the low byte of the standard 8052 16-bit data pointer. data pointer high bit: 7 6 5 4 3 2 1 0 dph.7 dph.6 dph.5 dph.4 dph.3 dph.2 dph.1 dph.0 mnemonic: dph address: 83h
w79e825/824/823/822 data sheet publication release date: december 27, 2007 - 21 - revision a8 bit name function 7-0 dph.[7:0] this is the high byte of the standard 8052 16-bit data pointer. this is the high byte of the dptr 16-bit data pointer. power control 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. sc on.7 (sm0/fe) bit is used as sm0 (standard 8052 function). 1: framing error detection enable. 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 when 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 the 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 bit: 7 6 5 4 3 2 1 0 tf1 tr1 tf0 tr0 ie1 it1 ie0 it0 mnemonic: tcon address: 88h bit name function 7 tf1 timer 1 overflow flag. this bit is set when timer 1 overflows. it is cleared automatically when the program does a time r 1 interrupt service routine. software can also set or clear this bit. 6 tr1 timer 1 run control. this bit is set or cl eared by software to turn timer/counter on or off.
w79e825/824/823/822 data sheet - 22 - continued bit name function 5 tf0 timer 0 overflow flag. this bit is set when timer 0 overflows. it is cleared automatically when the program does a time r 0 interrupt service routine. software can also set or clear this bit. 4 tr0 timer 0 run control. this bit is set or cl eared by software to turn timer/counter on or off. 3 ie1 interrupt 1 edge detect flag: set by hardware when an edge/level is detected on int1 . this bit is cleared by hardware when the service routine is vectored to only if the interrupt was edge triggered. otherwise it follows the inverse of the pin. 2 it1 interrupt 1 type control. set/cleared by software to specify falling edge/ low level triggered external inputs. 1 ie0 interrupt 0 edge detect flag. set by hardware when an edge/level is detected on int0 . this bit is cleared by hardware when the service routine is vectored to only if the interrupt was edge triggered. otherwise it follows the inverse of the pin. 0 it0 interrupt 0 type control: set/cleared by software to specify falling edge/ low level triggered external inputs. timer mode control bit: 7 6 5 4 3 2 1 0 gate t c / m1 m0 gate t c / m1 m0 timer1 timer0 mnemonic: tmod address: 89h bit name function 7 gate gating control: when this bit is set, timer/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 falling edges on the t1 pin. 5 m1 timer 1 mode select bit 1. see table below. 4 m0 timer 1 mode select bit 0. see table below. 3 gate gating control: when this bit is set, timer/counter 0 is enabled only while the int0 pin is high and the tr0 control bit is set. when cleared, the int0 pin has no effect, and timer 0 is enabled whenever tr0 control bit is set. 2 t c/ timer or counter select: when clear, timer 0 is incremented by the internal clock. when set, the timer counts falling edges on the t0 pin. 1 m1 timer 0 mode select bit 1. see table below. 0 m0 timer 0 mode select bit 0. see table below.
w79e825/824/823/822 data sheet publication release date: december 27, 2007 - 23 - revision a8 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 bits. (timer 1) timer/counter 1 is stopped. timer 0 lsb bit: 7 6 5 4 3 2 1 0 tl0.7 tl0.6 tl0.5 tl0.4 tl0.3 tl0.2 tl0.1 tl0.0 mnemonic: tl0 address: 8ah bit name function 7-0 tl0.[7:0] timer 0 lsb. timer 1 lsb bit: 7 6 5 4 3 2 1 0 tl1.7 tl1.6 tl1.5 tl1.4 tl1.3 tl1.2 tl1.1 tl1.0 mnemonic: tl1 address: 8bh bit name function 7-0 tl1.[7:0] timer 1 lsb. timer 0 msb bit: 7 6 5 4 3 2 1 0 th0.7 th0.6 th0.5 th0.4 th0.3 th0.2 th0.1 th0.0 mnemonic: th0 address: 8ch bit name function 7-0 th0.[7:0] timer 0 msb. timer 1 msb bit: 7 6 5 4 3 2 1 0 th1.7 th1.6 th1.5 th1.4 th1.3 th1.2 th1.1 th1.0 mnemonic: th1 address: 8dh bit name function 7-0 th1.[7:0] timer 1 msb.
w79e825/824/823/822 data sheet - 24 - clock control 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 4 clocks. 3 t0m timer 0 clock select: 0: timer 0 uses a divide by 12 clocks. 1: timer 0 uses a divide by 4 clocks. 2-0 - reserved. port 1 bit: 7 6 5 4 3 2 1 0 p1.7 p1.6 p1.5 p1.4 p1.3 p1.2 p1.1 p1.0 mnemonic: p1 address: 90h 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 r ead-modify-write instructions, the por t latch is read. these alternate functions are described below: bit name function 7 p1.7 pwm 2 pin. 6 p1.6 pwm 1 pin. 5 p1.5 /rst pin or input pin by alternative. 4 p1.4 int1 interrupt. 3 p1.3 int0 interrupt or sda of i2c. 2 p1.2 timer 0 or scl of i2c. 1 p1.1 rxd of serial port. 0 p1.0 txd of serial port. note: the initial value of the port is set by config1.prhi bi t. the default setting for config1.prhi =1 which the alternative function output is turned on upon reset. if config1.prhi is set to 0, the user has to write a 1 to port sfr to turn on the alternative function output. divider clock bit: 7 6 5 4 3 2 1 0 divm.7 divm.6 divm.5 divm.4 divm.3 divm.2 divm.1 divm.0 mnemonic: divm address: 95h
w79e825/824/823/822 data sheet publication release date: december 27, 2007 - 25 - revision a8 bit name function 7-0 divm.[7:0] the divm register is clock divider of uc. refer oscillator chapter. serial port control bit: 7 6 5 4 3 2 1 0 sm0/fe sm1 sm2 ren tb8 rb8 ti ri mnemonic: scon address: 98h bit name function 7 sm0/fe serial port mode select bit 0 or framing error flag: the smod0 bit in pcon sfr determines whether this bit acts as sm 0 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 clear 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 bi t (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 co mpatibility with the standard 8052. when set to 1, the serial clock become divide by 4 of the oscillato r clock. this results in faster synchronous serial communication. 4 ren receive enable: 0: disable serial reception. 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 dat a bit. in mode 1, if sm2 = 0, rb8 is the stop bit that was received. in mode 0 it has no function. 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 restri ctions of sm2 apply to this bit. this bit can be cleared only by software.
w79e825/824/823/822 data sheet - 26 - sm0, sm1: 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 variable serial data buffer bit: 7 6 5 4 3 2 1 0 sbuf.7 sbuf.6 sbuf.5 sbuf.4 sbuf.3 sbuf.2 sbuf.1 sbuf.0 mnemonic: sbuf address: 99h bit name function 7-0 sbuf.[7:0] serial data on the serial port is read from or written to this location. it actually consists of two separate internal 8-bit re gisters. one is the receive resister, and the other is the transmit buffer. any re ad access gets data from the receive data buffer, while write access is to the transmit data buffer. port 2 bit: 7 6 5 4 3 2 1 0 - - - - - - p2.1 p2.0 mnemonic: p2 address: a0h bit name function 7-2 - reserved 1 p2.1 xtal1 clock input pin. 0 p2.0 xtal2 or clkout pin by alternative. note: the initial value of the port is set by config1.prhi bi t. the default setting for config1.prhi =1 which the alternative function output is turned on upon reset. if config1.prhi is set to 0, the user has to write a 1 to port sfr to turn on the alternative function output. keyboard interrupt 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 keyboard interrupt. 4 kbi.4 1: enable p0.4 as a cause of a keyboard interrupt.
w79e825/824/823/822 data sheet publication release date: december 27, 2007 - 27 - revision a8 continued . bit name function 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 bit: 7 6 5 4 3 2 1 0 kbf bod boi lpbov srst adcen 0 dps mnemonic: auxr1 address: a2h bit name function 7 kbf keyboard interrupt flag: 1: when any pin of port 0 that is enabl ed 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: disable brownout detect interrupt function and it will cause chip reset when bof is set. 1: this prevents brownout detection from causing a chip reset and allows the brownout detect function to be used as an interrupt. 4 lpbov low power brown out detect control: 0: when bod is enable, the brown out detect is always turned on by normal run or power down mode. 1: when bod is enable, the brown out detect circuit is turned on by power down mode. this control can help save 15/16 of the brownout circuit power. when uc is in power down mode, the bod will enable internal rc osc (2mhz~0.5mhz) 3 srst software reset: 1: reset the chip as if a hardware reset occurred. 2 adcen 0: disable adc circuit. 1: enable adc circuit. 1 0 reserved. 0 dps dual data pointer select 0: to select dptr of standard 8051. 1: to select dptr1
w79e825/824/823/822 data sheet - 28 - interrupt enable bit: 7 6 5 4 3 2 1 0 ea eadc ebo es et1 ex1 et0 ex0 mnemonic: ie address: a8h bit name function 7 ea global enable. enable/disable all interrupts. 6 eadc enable adc interrupt. 5 ebo enable brown out interrupt. 4 es enable serial port 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 bit: 7 6 5 4 3 2 1 0 saddr.7 saddr.6 saddr.5 saddr.4 saddr.3 saddr.2 saddr.1 saddr.0 mnemonic: saddr address: a9h bit name function 7-0 saddr.[7:0] the saddr should be programmed to the given or broadcast address for serial port to which the slave processor is designated. comparator 1 control register bit: 7 6 5 4 3 2 1 0 - - ce1 cp1 cn1 oe1 co1 cmf1 mnemonic: cmp1 address: ach bit name function 7 - reserved. 6 - reserved. 5 ce1 comparator enable: 0: disable comparator. 1: enabled comparator. comparator out put need wait stable 10 us after ce1 is first set. 4 cp1 comparator positive input select: 0: cin1a is selected as the positive comparator input. 1: cin1b is selected as the positive comparator input.
w79e825/824/823/822 data sheet publication release date: december 27, 2007 - 29 - revision a8 continued. bit name function 3 cn1 comparator negative input select: 0: the comparator reference pin cmpref is selected as the negative comparator input. 1: the internal comparator reference vref is selected as the negative comparator input. 2 oe1 output enable: 1: the comparator output is connected to the cmp1 pin if the comparator is enabled (ce1 = 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 (ce1 = 0). 0 cmf1 comparator interrupt flag: this bit is set by hardware whenever th e comparator output co1 changes state. this bit will cause a hardware interrupt if enabled and of sufficient priority. cleared by software and when the comparator is disabled (ce1 = 0). comparator 2 control register bit: 7 6 5 4 3 2 1 0 - - ce2 cp2 cn2 oe2 co2 cmf2 mnemonic: cmp2 address: adh bit name function 7 - reserved. 6 - reserved. 5 ce2 comparator enable: 0: disable comparator. 1: enabled comparator. comparator out put need wait stable 10 us after ce2 is first set. 4 cp2 comparator positive input select: 0: cin2a is selected as the positive comparator input. 1: cin2b is selected as the positive comparator input. 3 cn2 comparator negative input select: 0: the comparator reference pin cmpref is selected as the negative comparator input. 1: the internal comparator reference vref is selected as the negative comparator input.
w79e825/824/823/822 data sheet - 30 - continued . bit name function 2 oe2 output enable: 1: the comparator output is connected to the cmp2 pin if the comparator is enabled (ce2 = 1). this output is asynchronous to the cpu clock. 1 co2 comparator output: synchronized to the cpu clock to allow reading by software. cleared when the comparator is disabled (ce2 = 0). 0 cmf2 comparator interrupt flag: this bit is set by hardware whenever th e comparator output co2 changes state. this bit will cause a hardware interrupt if enabled and of sufficient priority. cleared by software and when the comparator is disabled (ce2 = 0). port 0 output mode 1 bit: 7 6 5 4 3 2 1 0 p0m1.7 p0m1.6 p0m1 .5 p0m1.4 p0m1.3 p0 m1.2 p0m1.1 p0m1.0 mnemonic: p0m1 address: b1h bit name function 7-0 p0m1.[7:0] to control the output configuration of p0 bits [7:0] port 0 output mode 2 bit: 7 6 5 4 3 2 1 0 p0m2.7 p0m2.6 p0m2 .5 p0m2.4 p0m2.3 p0 m2.2 p0m2.1 p0m2.0 mnemonic: p0m2 address: b2h bit name function 7-0 p0m2.[7:0] to control the output configuration of p0 bits [7:0] port 1 output mode 1 bit: 7 6 5 4 3 2 1 0 p1m1.7 p1m1.6 - p1m1.4 p1 m1.3 p1m1.2 p1m1.1 p1m1.0 mnemonic: p1m1 address: b3h bit name function 7-0 p1m1.[7:0] to control the output configuration of p1 bits [7:0] port 1 output mode 2 bit: 7 6 5 4 3 2 1 0 p1m2.7 p1m2.6 - p1m2.4 p1 m2.3 p1m2.2 p1m2.1 p1m2.0 mnemonic: p1m2 address: b4h
w79e825/824/823/822 data sheet publication release date: december 27, 2007 - 31 - revision a8 bit name function 7-0 p1m2.[7:0] to control the output configuration of p1 bits [7:0] port 2 output mode 1 bit: 7 6 5 4 3 2 1 0 p2s p1s p0s enclk t1oe t0oe p2m1.1 p2m1.0 mnemonic: p2m1 address: b5h bit name function 7 p2s 0: disable schmitt trigger inputs on port 2 and enable ttl inputs on port 2. 1: enables schmitt trigger inputs on port 2. 6 p1s 0: disable schmitt trigger inputs on port 1 and enable ttl inputs on port 1. 1: enables schmitt trigger inputs on port 1. 5 p0s 0: disable schmitt trigger inputs on port 0 and enable ttl inputs on port 0 1: enables schmitt trigger inputs on port 0. 4 enclk 1: enabled clock out put to xtal2 pin (p2.0) 3 t1oe 1: the p0.7 pin is toggled whenever time r 1 overflows. the output frequency is therefore one half of the timer 1 overflow rate. 2 t0oe 1: the p1.2 pin is toggled whenever time r 0 overflows. the output frequency is therefore one half of the timer 0 overflow rate. 1 p2m1.1 to control the output configuration of p2.1. 0 p2m1.0 to control the output configuration of p2.0. port 2 output mode 2 bit: 7 6 5 4 3 2 1 0 - - - - - - p2m2.1 p2m2.0 mnemonic: p2m1 address: b6h bit name function 7-2 - reserved. 1-0 p2m2.[1:0] to control the output configuration of p2 bits [1:0]
w79e825/824/823/822 data sheet - 32 - port output configuration settings: pxm1.y pxm2.y port input/output mode 0 0 quasi-bidirectional 0 1 push-pull 1 0 input only (high impedance) p2m1.pxs=0, ttl input p2m1.pxs=1, schmitt input 1 1 open drain interrupt high priority bit: 7 6 5 4 3 2 1 0 - padch pboh psh pt1h px1h pt0h px0h mnemonic: ip0h address: b7h bit name function 7 - this bit is un-implemented and will read high. 6 padch 1: to set interrupt high priority of adc is highest priority level. 5 pboh 1: to set interrupt high priority of br own out detector is highest priority level. 4 psh 1: to set interrupt high priority of serial port 0 is highest priority level. 3 pt1h 1: to set interrupt high priority of timer 1 is highest priority level. 2 px1h 1: to set interrupt high priority of exte rnal 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 exte rnal interrupt 0 is highest priority level. interrupt priority 0 bit: 7 6 5 4 3 2 1 0 - padc pbo ps pt1 px1 pt0 px0 mnemonic: ip address: b8h bit name function 7 - this bit is un-implemented and will read high. 6 padc 1: to set interrupt priority of adc is higher priority level. 5 pbo 1: to set interrupt priority of brow n out detector is hig her 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 exter nal interrupt 1 is higher priority level. 1 pt0 1: to set interrupt priority of timer 0 is higher priority level. 0 px0 1: to set interrupt priority of exter nal interrupt 0 is higher priority level.
w79e825/824/823/822 data sheet publication release date: december 27, 2007 - 33 - revision a8 slave address mask enable bit: 7 6 5 4 3 2 1 0 saden.7 saden.6 sad en.5 saden.4 saden.3 sad en.2 saden.1 saden.0 mnemonic: saden address: b9h bit name function 7-0 saden [7:0] this register enables the automatic addr ess recognition feature of the serial port 0. 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 is 0, then the bit becomes a "don't care" in the comparison. this register enables the automatic address recognition feature of the serial port 0. when all the bits of saden are 0, interrupt will occur for any incoming address. slave address mask enable 1 bit: 7 6 5 4 3 2 1 0 i2dat.7 i2dat.6 i2dat.5 i2dat.4 i2dat.3 i2dat.2 i2dat.1 i2dat.0 mnemonic: i2dat address: bch bit name function 7-0 i2dat.[7:0] the data register of i2c. i2c status register bit: 7 6 5 4 3 2 1 0 i2status.7 i2status.6 i2status.5 i2status.4 i2status.3 - - - mnemonic: i2status address: bdh bit 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 ar e 23 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 i2status 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 bit: 7 6 5 4 3 2 1 0 i2clk.7 i2clk.6 i2clk.5 i2clk.4 i2clk.3 i2clk.2 i2clk.1 i2clk.0 mnemonic: i2clk address: beh
w79e825/824/823/822 data sheet - 34 - bit name function 7-0 i2clk.[7:0] the i2c clock rate bits. i2c timer counter register bit: 7 6 5 4 3 2 1 0 - - - - - enti div4 tif mnemonic: i2timer address: bfh bit 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 coun t. after enable enti and ensi, the 14-bit 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 fosc clock. 1: the 14-bits timer counter so urce 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 overfl ow. before enable i2c timer (both enti, ensi = [1,1]) the si must be cleared. if i2c interrupt is enabled. the i2c interrupt service routine will be execut ed. this bit is cleared by software. i2c control register bit: 7 6 5 4 3 2 1 0 - ensi sta sto si aa - - mnemonic: i2con address: c0h bit name function 7 - reserved. 6 ens1 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. p1.2 (scl) and p1.3 (sda) may be used as open drain i/o ports. 1: enable i2c serial function. the p1.2 and p1.3 port latches must be to logic 1.
w79e825/824/823/822 data sheet publication release date: december 27, 2007 - 35 - revision a8 continued bit name function 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 m ode. the i2c hardware c hecks the status of i2c bus and generates a start condition if t he 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 received, 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 the bit sto bit is set while i2c is in a ma ster mode. a stop condition is transmitted to the i2c bus. when the stop conditi on is detected on the bus, the i2c hardware clears the sto flag. in a slave mode, the sto flag may be set to recover from a bus error condition. in this case, no stop condition is transmitted to the i2c bus. however, the i2c hardware behaves as if a stop condition has been received and it switches to the not addressable slave receiv er mode. the sto flag is automatically cleared by hardware. if the sta and sto bits are both set, then a stop condition is transmitted to the i2c bus if i2c is in a master mode (in a slave mode, i2c generates an internal stop condition which is not transmitted). i2c then transmits a start condition. 3 si 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 es bits (in ie register) are both set, a serial interrupt is requested when si is set. the only state that does not cause si to be set is state f8h, which indicates that no relevant state information is available. when si is set, the low period of the serial clock on t he scl line is stretched, and the serial transfer is suspended. a high level on the scl line is unaffected by the serial interrupt flag. si must be cleared by software. 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) wi ll 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 - reserved. 0 - reserved.
w79e825/824/823/822 data sheet - 36 - i2c address register bit: 7 6 5 4 3 2 1 0 i2addr.7 i2addr.6 i2addr.5 i2a ddr.4 i2addr.3 i2addr.2 i2addr.1 gc mnemonic: i2addr address: c1h bit name function 7~1 i2addr.[7:1] i2c address register: the 8051 uc can read from and write to this 8-bit, directly addressable sfr. the content of this register is i rrelevant when i2c is in master mode. in the slave mode, the seven most sign ificant 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. nvm address bit: 7 6 5 4 3 2 1 0 nvmaddr. 7 nvmaddr.6 nvmaddr. 5 nvmaddr.4 nvmaddr.3 nvmaddr.2nvmaddr.1 nvmaddr.0 mnemonic: nvmaddr address: c6h bit name function 7~0 nvmaddr.[7:0] the nvm address: the register indicates nvm data memo ry of low byte address on on-chip code memory space. timed access bit: 7 6 5 4 3 2 1 0 ta.7 ta.6 ta.5 ta.4 ta.3 ta.2 ta.1 ta.0 mnemonic: ta address: c7h bit name function 7-0 ta.[7:0] the timed access register: the timed access register controls t he 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, during which the user can write to these bits. nvm control bit: 7 6 5 4 3 2 1 0 eer ewr - - - - - - mnemonic: nvmcon address: ceh
w79e825/824/823/822 data sheet publication release date: december 27, 2007 - 37 - revision a8 bit 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 4 pages and each page have 64 bytes data memory. before sele ct page by nvmaddr register that will automatic enable page area, after set this bit, the page will be erased and program counter will halt at this instructi on. after finished, program counter will kept next instruction then executed . the nvm page?s address is defined in table below. 6 ewr nvm data write bit: 0: without write nvm data. 1: set this bit to write nvm bytes and prog ram counter will halt at this instruction. after write is finished, program counter will kept next instru ction then executed. 5-0 - reserved nvm page(n) area definition table: page start address end address 0 00h 3fh 1 40h 7fh 2 80h bfh 3 c0h ffh note: the w79e823 and w79e822 without page 2 and page 3. nvm data bit: 7 6 5 4 3 2 1 0 nvmdat.7 nvmdat.6 nvmdat.5 nvmdat.4 nvmdat3 nvmdat.2 nvmdat.1 nvmdat.0 mnemonic: nvmdata address: cfh bit name function 7~0 nvmdat.[7:0] the nvm data write register. the read nvm data is by movc instruction. program status word 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 cy carry flag: set for an arithmetic operation which re sults in a carry being generated from the alu. it is also used as the accumulator for the bit operations.
w79e825/824/823/822 data sheet - 38 - continued bit name function 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~rs0 register bank select bits. 2 ov overflow flag: set when a carry was generated from the se venth bit but not from the 8th bit as a result of the previous 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. 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 pwmp counter high bits register bit: 7 6 5 4 3 2 1 0 - - - - - - pwmp.9 pwmp.8 mnemonic: pwmph address: d1h bit name function 7-2 - reserved. 1-0 pwmp.[9:8] the pwm counter register bits 9~8. pwm 0 high bits register bit: 7 6 5 4 3 2 1 0 - - - - - - pwm0.9 pwm0.8 mnemonic: pwm0h address: d2h bit name function 7~2 - reserved. 1~0 pwm0.[9:8] the pwm 0 high bits register bit 9~8.
w79e825/824/823/822 data sheet publication release date: december 27, 2007 - 39 - revision a8 pwm 1 high bits register bit: 7 6 5 4 3 2 1 0 - - - - - - pwm1.9 pwm1.8 mnemonic: pwm1h address: d3h bit name function 7~2 - reserved. 1~0 pwm1.[9:8] the pwm 1 high bits register bit 9~8. pwm 2 high bits register 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 pwm 2 high bits register bit 9~8. pwm 3 high bits register bit: 7 6 5 4 3 2 1 0 - - - - - - pwm3.9 pwm3.8 mnemonic: pwm3h address: d6h bit name function 7~2 - reserved. 1~0 pwm3.[9:8] the pwm 3 high bits register bit 9~8. pwm control register 3 bit: 7 6 5 4 3 2 1 0 - - - - - - - bkf mnemonic: pwmcon3 address: d7h bit name function 7-6 - reserved. 0 bkf the external brake pin flag. 0: the pwm is not brake. 1: the pwm is brake by external brak e pin. it will be cleared by software. watchdog control bit: 7 6 5 4 3 2 1 0 wdrun por wd1 wd0 wdif wtrf ewrst wdclr mnemonic: wdcon address: d8h
w79e825/824/823/822 data sheet - 40 - bit name function 7 wdrun 0: the watchdog is stopped. 1: the watchdog is running. 6 - reserved. 5 wd1 4 wd0 watchdog timer time-out select bits. these bits determine the time-out period of the watchdog timer. the reset time-out period is 512 clocks longer than the watchdog time-out. wd1 wd0 interrupt time-out reset time-out 0 0 2 17 2 17 + 512 0 1 2 20 2 20 + 512 1 0 2 23 2 23 + 512 1 1 2 26 2 26 + 512 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, hardwar e will set this bit to indicate that the watchdog interrupt has occurred. 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 determi ning 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 (eie.4) is set, and 512 clocks after that a watchdog timer reset will be generated if ewrst is set. this bit is self-clearing by hardware. the wdcon sfr is set to 0x000000b on a 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 a power-on reset, reset pin reset, and watch dog timer reset. all the bits in this sfr have unrestricted r ead access. ewrst, wdif and wdclr require timed access procedure to write. the remaining bits have unrestricted write accesses. please refer ta register description.
w79e825/824/823/822 data sheet publication release date: december 27, 2007 - 41 - revision a8 ta reg c7h wdcon reg d8h mov ta, #aah ; to access protected bits mov ta, #55h setb wdcon.0 ; reset watchdog timer orl wdcon, #00110000b ; select 26 bits watchdog timer mov ta, #aah mov ta, #55h orl wdcon, #00000010b ; enable watchdog pwmp counter low bits register 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.[7:0] pwm counter low bits register. pwm0 low bits register bit: 7 6 5 4 3 2 1 0 pwm0.7 pwm0.6 pwm0 .5 pwm0.4 pwm0.3 pw m0.2 pwm0.1 pwm0.1 mnemonic: pwm0l address: dah bit name function 7~0 pwm0.[7:0] pwm 0 low bits register. pwm1 low bits register bit: 7 6 5 4 3 2 1 0 pwm1.7 pwm1.6 pwm1 .5 pwm1.4 pwm1.3 pw m1.2 pwm1.1 pwm1.0 mnemonic: pwm1l address: dbh bit name function 7~0 pwm1.[7:0] pwm 1 low bits register. pwm control register 1 bit: 7 6 5 4 3 2 1 0 pwmrun load pwmf clrpwm pwm3l pwm2l pwm1l pwm0l mnemonic: pwmcon1 address: dch
w79e825/824/823/822 data sheet - 42 - 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 pwmn are never loaded to counter and comparator registers. 1: the pwmp and pwmn registers load value to counter and compare registers at the counter underflow. this bit is auto cleared by hardware at next clock cycle. 5 cf 0: the 10-bit counter down count is not underflow. 1: the 10-bit counter down count is underflow. this bit is software clear. 4 clrpwm 1: clear 10-bit pwm counter to 000 h. this bit is auto cleared by hardware. 3 pwm3i 0: pwm3 out is non-inverted. 1: pwm3 output is inverted. 2 pwm2i 0: pwm2 out is non-inverted. 1: pwm2 output is inverted. 1 pwm1i 0: pwm1 out is non-inverted. 1: pwm1 output is inverted. 0 pwm0i 0: pwm0 out is non-inverted. 1: pwm0 output is inverted. pwm2 low bits register bit: 7 6 5 4 3 2 1 0 pwm2.7 pwm2.6 pwm2 .5 pwm2.4 pwm2.3 pw m2.2 pwm2.1 pwm2.0 mnemonic: pwm2l address: ddh bit name function 7~0 pwm2.[7:0] pwm 2 low bits register. pwm3 low bits register bit: 7 6 5 4 3 2 1 0 pwm3.7 pwm3.6 pwm3 .5 pwm3.4 pwm3.3 pw m3.2 pwm3.1 pwm3.0 mnemonic: pwm2l address: deh bit name function 7~0 pwm3.[7:0] pwm 3 low bits register. pwm control register 2 bit: 7 6 5 4 3 2 1 0 bkch bkps bpen bken pwm3b pwm2b pwm1b pwm0b mnemonic: pwmcon2 address: dfh
w79e825/824/823/822 data sheet publication release date: december 27, 2007 - 43 - revision a8 bit name function 7 bkch see the below table, when bken is set. 6 bkps 0: brake is asserted if p0.2 is low. 1: brake is asserted if p0.2 is high 5 bpen see the below table, when bken is set. 4 bken 0: the brake is never asserted. 1: the brake is enabled, and see the below table. 3 pwm3b 0: the pwm3 output is low, when brake is asserted. 1: the pwm3 output is high, when brake is asserted. 2 pwm2b 0: the pwm2 output is low, when brake is asserted. 1: the pwm2 output is high, when brake is asserted. 1 pwm1b 0: the pwm1 output is low, when brake is asserted. 1: the pwm1 output is high, when brake is asserted. 0 pwm0b 0: the pwm0 output is low, when brake is asserted. 1: the pwm0 output is high, when brake is asserted. brake condition table: bpen bkch brake condition 0 0 brake on (software brake and keeping brake). software brake condition. when acti ve (bpen=bkch=0, and bken=1), pwm output follows pwmnb setting. this br ake has no effect on pwmrun bit, therefore, internal pwm generator continues to run. when the brake is released, the state of pwm output depends on the cu rrent state of pwm generator output during the release. 0 1 brake on, when pwm is not running (p wmrun=0), the pwm output condition follows pwmnb setting. when the brake is released (by disabl ing bken = 0), the pwm output resumes to the state when pwm generator stop running prior to enabling the brake. brake off, when pwm is running (pwmrun=1). 1 0 brake on, when brake pin asserted. external pin brake condition. when active (by external pin), pwm output follows pwmnb setting, pwmrun will be cleared by hardware, and bkf flag will be set. when the brake is released (by de-asserting the external pin and disabling bken = 0), the pwm output resumes to the state of the pwm generator output prior to the brake. 1 1 no any active. accumulator bit: 7 6 5 4 3 2 1 0 acc.7 acc.6 acc.5 acc.4 acc.3 acc.2 acc.1 acc.0 mnemonic: acc address: e0h
w79e825/824/823/822 data sheet - 44 - bit name function 7-0 acc.[7:0] the a or acc register is the standard 8052 accumulator adc control register bit: 7 6 5 4 3 2 1 0 adc.1 adc.0 adcex adci adcs rcclk aadr1 aadr0 mnemonic: adccon address: e1h bit name function 7 adc.1 the adc conversion result. 6 adc.0 the adc conversion result. 5 adcex enable stadc-triggered conversion 0: conversion can only be started by software (i.e., by setting adcs). 1: conversion can be started by softwar e or by a rising edge on stadc (pin p1.4). 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. the flag ma y be cleared by the isr. while this flag is 1, the adc cannot start a new conver sion. adci can not be set by software. 3 adcs adc start and status: set this bit to star t an a/d conversion. it may also be set by stadc if adcex is 1. this signal remains high while the adc is busy and is reset right after adci is set. adcs ca n not be reset by software, and the adc cannot start a new conversion while adcs is high. it is recommended to clear adci before adcs is set. however, if adci is cleared and adcs is set at the same ti me, a new a/d conversion may start on the same channel. 2 rcclk 0: the cpu clock is used as adc clock. 1: the internal rc clock is used as adc clock. 1 aadr1 the adc input select. see table below. 0 aadr0 the adc input select. see table below. 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.
w79e825/824/823/822 data sheet publication release date: december 27, 2007 - 45 - revision a8 aadr1, aadr0: adc analog i nput channel select bits: these bits can only be changed when adci and adcs are both zero. aadr1 aadr0 selected analog input channel 0 0 ad0 (p0.3) 0 1 ad1 (p0.4) 1 0 ad2 (p0.5) 1 1 ad3 (p0.6) adc converter result high register bit: 7 6 5 4 3 2 1 0 adc.9 adc.8 adc.7 adc.6 adc.5 adc.4 adc.3 adc.2 mnemonic: adch address: e2h bit name function 7-0 adc.[9:2] the adc conversion result. interrupt enable register 1 bit: 7 6 5 4 3 2 1 0 - - epwm ewdi ec2 ec1 ekb ei2 mnemonic: eie address: e8h bit name function 7 - reserved. 6 - reserved. 5 epwm 0: disable pwm interrupt when external brake pin was brake. 1: enable pwm interrupt when ex ternal brake pin was brake. 4 ewdi 0: disable watchdog timer interrupt. 1: enable watchdog timer interrupt. 3 ec2 0: disable comparator 2 interrupt. 1: enable comparator 2 interrupt. 2 ec1 0: disable comparator 1 interrupt. 1: enable comparator 1 interrupt. 1 ekb 0: disable keypad interrupt. 1: enable keypad interrupt. 0 ei2 0: disable i2c interrupt. 1: enable i2c interrupt.
w79e825/824/823/822 data sheet - 46 - b register 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 bit name function 7-0 b.[7:0] the b register is the standard 8052 register that serves as a second accumulator. port 0 digital input disable bit: 7 6 5 4 3 2 1 0 p0id.7 p0id.6 p0id .5 p0id.4 p0id.3 p0 id.2 p0id.1 p0id.0 mnemonic: p0id address: f6h bit name function 7~0 p0id.[7:0] enable/disable port 0 digital inputs. 0: enable port 0 digital inputs. 1: disable port 0 digital inputs. interrupt high priority 1 bit: 7 6 5 4 3 2 1 0 - - ppwmh pwdih pc2h pc1h pkbh pi2h mnemonic: ip1h address: f7h bit name function 7 - reserved. 6 - reserved. 5 ppwmh 1: to set interrupt high priority of pwm?s brake is highest priority level. 4 pwdih 1: to set interrupt high priority of watchdog is highest priority level. 3 pc2h 1: to set interrupt high priority of comparator 2 is highest priority level. 2 pc1h 1: to set interrupt high priority of comparator 1 is highest priority level. 1 pkbh 1: to set interrupt high priority of keypad is highest priority level. 0 pi2h 1: to set interrupt high priority of i2c is highest priority level.
w79e825/824/823/822 data sheet publication release date: december 27, 2007 - 47 - revision a8 extended interrupt priority bit: 7 6 5 4 3 2 1 0 - - ppwm pwdi pc2 pc1 pkb pi2 mnemonic: ip1 address: f8h bit name function 7 - reserved. 6 - reserved. 5 ppwm 1: to set interrupt priority of pwm? s external brake is higher priority level. 4 pwdi 1: to set interrupt priority of watchdog is higher priority level. 3 pc2 1: to set interrupt priority of co mparator 2 is higher priority level. 2 pc1 1: to set interrupt priority of co mparator 1 is higher priority level. 1 pkb 1: to set interrupt priority of keypad is higher priority level. 0 pi2 1: to set interrupt priority of i2c is higher priority level.
w79e825/824/823/822 data sheet - 48 - 9 instruction set the w79e825 series execute all t he instructions of the standard 8 052 family. the operations of these instructions, as well as their effects on flag and status bits, are exactly the same. however, the timing of these instructions is different in two ways. firstly, the machine cycl e is four clock periods, while the standard-8051/52 machine cycle is twelve clock pe riods. secondly, it can fe tch only once per machine cycle (i.e., four clocks per fetch), while the stand ard 8051/52 can fetch twice per machine cycle (i.e., six clocks per fetch). the timing differences create an advantage for th e w79e825 series. there is only one fetch per machine cycle, so the number of machine cycles is usually equal to the number of operands in the instruction. (jumps and calls do require an additional cycle to calculate the new address.) as a result, the w79e825 series reduces the number of du mmy fetches and wasted cycles, and therefore improves overall efficiency, compared to the standard 8051/52. op-code hex code bytes w79e825 series machine cycle w79e825 series clock cycles 8032 clock cycles w79e825 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 add 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 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
w79e825/824/823/822 data sheet publication release date: december 27, 2007 - 49 - revision a8 continued op-code hex code bytes w79e825 series machine cycle w79e825 series clock cycles 8032 clock cycles w79e825 series vs. 8032 speed ratio 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 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
w79e825/824/823/822 data sheet - 50 - continued op-code hex code bytes w79e825 series machine cycle w79e825 series clock cycles 8032 clock cycles w79e825 series vs. 8032 speed ratio 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 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
w79e825/824/823/822 data sheet publication release date: december 27, 2007 - 51 - revision a8 continued op-code hex code bytes w79e825 series machine cycle w79e825 series clock cycles 8032 clock cycles w79e825 series vs. 8032 speed ratio 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 xrl 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 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
w79e825/824/823/822 data sheet - 52 - continued op-code hex code bytes w79e825 series machine cycle w79e825 series clock cycles 8032 clock cycles w79e825 series vs. 8032 speed ratio 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 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, direct 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, #data 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
w79e825/824/823/822 data sheet publication release date: december 27, 2007 - 53 - revision a8 continued op-code hex code bytes w79e825 series machine cycle w79e825 series clock cycles 8032 clock cycles w79e825 series vs. 8032 speed ratio mov @r1, a f7 1 1 4 12 3 mov @r0, direct a6 2 2 8 12 1.5 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 movx 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 xch a, r0 c8 1 1 4 12 3 xch a, r1 c9 1 1 4 12 3
w79e825/824/823/822 data sheet - 54 - continued op-code hex code bytes w79e825 series machine cycle w79e825 series clock cycles 8032 clock cycles w79e825 series vs. 8032 speed ratio 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 72 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 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
w79e825/824/823/822 data sheet publication release date: december 27, 2007 - 55 - revision a8 continued op-code hex code bytes w79e825 series machine cycle w79e825 series clock cycles 8032 clock cycles w79e825 series vs. 8032 speed ratio 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 24 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 djnz r0, rel d8 2 3 12 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 9-1: instruction set for w79e825/824/823/822
w79e825/824/823/822 data sheet - 56 - 9.1 instruction timing this section is important because some applications use software instructions to generate timing delays. it also provides more information about timing differences between the w79e825 series and the standard 8051/52. in w79e825 series, each machine cycle is four clock periods long. each clock period is called a state, and each machine cycle consists of four states: c1 , c2 c3 and c4, in order. both clock edges are used for internal timing, so the dut y cycle of the clock should be as close to 50% as possible to avoid timing conflicts. the w79e825 series does one op-code fetch per machine cycle, so, in most instructions, the number of machine cycles required is equal to the number of bytes in the instruction. there are 256 available op-codes. 128 of them are single-cycle instructions, so many op-codes are executed in just four clocks period. some of the other op-code s are two-cycle instructions, and most of these have two-byte op- codes. however, there are some in structions that have one-byte instru ctions yet take two cycles to execute. one important exampl e is the movx instruction. in the standard 8052, the movx instruction is al ways two machine cycles long. however, in the w79e825 series each machine cycle is made of only 4 clock periods compared to the 12 clock periods for the standard 8052. therefore, even thou gh the number of categories has increased, each instruction is at least 1.5 to 3 times faster than the standard 8052 in terms of clock periods. single cycle c4 c3 c2 c1 cpu clk ale psen ad<7:0> address <15:0> a7-0 address a15-8 data_ in d7-0 figure 9-1: single cycle instruction timing
w79e825/824/823/822 data sheet publication release date: december 27, 2007 - 57 - revision a8 instruction fetch c4 c3 c2 c1 op-code address a15-8 address a15-8 ale psen pc ad<7:0> a ddress<15:0> cpu clk operand fetch c4 c3 c2 c1 operand pc+1 figure 9-2: two cycles instruction timing operand operand a7-0 a7-0 a7-0 op-code address a15-8 address a15-8 address a15-8 operand fetch operand fetch instruction fetch c2 c3 c4 c2 c3 c4 c4 c3 c2 c1 c1 c1 cpu clk ale psen ad<7:0> a ddress<15:0> figure 9-3: three cycles instruction timing
w79e825/824/823/822 data sheet - 58 - operand operand operand op-code address a15-8 address a15-8 address a15-8 address a15-8 a7-0 a7-0 a7-0 a7-0 operand fetch operand fetch operand fetch instruction fetch c2 c1 c4 c3 c2 c1 cpu clk ale psen ad<7:0> a ddress<15:0> c4 c3 c2 c1 c4 c3 c2 c1 c4 c3 figure 9-4: four cycles instruction timing operand operand operand op-code address a15-8 address a15-8 address a15-8 address a15-8 a7-0 a7-0 a7-0 a7-0 operand fetch operand fetch operand fetch operand fetch instruction fetch c2 c1 c4 c3 c2 c1 cpu clk ale psen ad<7:0> a ddress<15:0> c4 c3 c2 c1 c4 c3 c2 c1 c4 c3 c2 c1 c4 c3 operand a7-0 address a15-8 figure 9-5: five cycles instruction timing
w79e825/824/823/822 data sheet publication release date: december 27, 2007 - 59 - revision a8 10 power management the w79e825 series has several features that help the user to control the power consumption of the device. these modes are discussed in the next two sections. 10.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 t hat will be executed before the device goes into idle mode. in the idle mode, the clock to the cpu is halted, but not to t he interrupt, timer, watchdog timer, i2c, pwm and serial port 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 states 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 automatica lly clear the idle bit, terminate the idle mode, and the interrupt service routine (isr) will be execut ed. after the isr, execution of the program will continue from the instruction which put the device into idle mode. the idle mode can also be exited 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 leas t two machine cycles i.e. 8 clock periods 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 cloc k is already running there is no delay and execution starts immediately. in the idle mode, the watch dog timer continues to run, and if enabled, a time-out will cause a watchdog timer interrupt which will wa ke 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-out. when the w79e825 series are exiting from an idle m ode with a reset, the instruction following the one which put the device into idle mode is not execut ed. so there is no danger of unexpected writes. 10.2 power down mode the device can be put into power down mode by writ ing 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 is completely stopped and the power consumption is reduced to the lowest possible value. the port pins output the values held by their respective sfrs. the w79e825 series will exit the power down mode with a reset or by an external interrupt pin enabled as level detected. an external reset can be used to exit the power down state. the low on /rst pin terminates the power down mode, and rest arts the clock. the program execution will restart from 0000h. in the power down mode, the clock is stopped, so the watchdog timer cannot be used to provide the reset to exit power down mode when it s clock source is external osc or crystal. the sources that can wake up from the power down mode are external interrupts, keyboard interrupt (kbi), brownout reset (bor), and comparator inte rrupt (cmf1, cmf2), and watchdog timer interrupt (if wdte = 0). the w79e825 series can be woken from the power down mode by forcing an external interrupt pin activated, provided the corresponding interrupt is enabled, while the global enable (ea) bit is set and the external input has been set to a level detect mode. if these conditions are met, then the high level on the external pin re-starts the oscillator. then device executes the interrupt service routine for the corresponding external interrupt. after the interrupt service routine is completed, the program execution returns to the instruction after one which put the device into power down mode and continues from there. during power down mode, if auxr1.lpbov = 1 and auxr1.bod = 0, the inte rnal rc clock will be enabled and hence save power.
w79e825/824/823/822 data sheet - 60 - 11 reset conditions the user has several hardware related options for placing the w79e825 series into reset condition. in general, most register bits go to their reset value ir respective 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. 11.1 sources of reset 11.1.1 external reset the device samples the /rst pin every machine cy cle during state c4. the /rst pin must be held low for at least two machine cycles before the reset circuitry applies an internal reset signal. thus, this reset is a synchronous operation and requires the clock to be running. the device remains in the reset state as long as /rst is low and remains low up to two machine cycles after /rst is deactivated. then, the devic e begins program execution at 0000h. there are no flags associated with the external reset, but, si nce the other two reset sources do have flags, the external reset is the cause if those flags are clear. 11.1.2 power-on reset (por) if the power supply falls below v rst , the device goes into the rese t state. when the power supply returns to proper levels, the device performs a po wer-on reset and sets the por flag. the software should clear the por flag, or it will be difficu lt to determine the source of future resets. 11.1.3 watchdog timer reset the watchdog timer is a free-running timer with programmable time-out intervals. the program must clear the watchdog timer before the time-out interval is reached to restart the count. if the time-out interval is reached, an interrupt flag is set. 512 cloc ks later, if the watchdog reset is enabled and the watchdog timer has not been cleared, the watchdog timer generates a reset. the reset condition is maintained by the hardware for two machine cycles , and the wtrf bit in wdcon is set. afterwards, the device begins program execution at 0000h. 11.2 reset state when the device is reset, most registers return to th eir initial state. the watchdog timer is disabled if the reset source was a power-on reset. the port regi sters are set to ffh, which puts most of the port pins in a high state. the program counter is set to 0000h, and the stack pointer is reset to 07h. after this, the device remains in the reset state as long as the reset conditions are satisfied. reset does not affect the on-chip ram, however, so ram is preserved as long as vdd remains above approximately 2 v, the minimum operating vo ltage for the ram. if vdd falls below 2 v, the ram contents are also lost. in either case, the stac k pointer is always reset, so the stack contents are lost.
w79e825/824/823/822 data sheet publication release date: december 27, 2007 - 61 - revision a8 sfr reset value sfr name reset value sfr name reset value p0 1111 1111b i2dat xxxx xxxxb sp 0000 0111b i2status 0000 0xxxb dpl 0000 0000b i2timer 0000 0000b dph 0000 0000b i2clk 0000 0000b pcon 00xx 0000b i2con 0000 0000b tcon 0000 0000b i2 addr xxxx xxxxb tmod 0000 0000b ta 0000 0000b tl0 0000 0000b psw 0000 0000b tl1 0000 0000b pwmp1 xxxx xx00b th0 0000 0000b pwm0h xxxx xx00b th1 0000 0000b pwm1h xxxx xx00b ckcon 0000 0000b pw m2h xxxx xx00b p1 1111 xx11b pwm3h xxxx xx00b divm 0000 0000b wdcon 0x00 0000b scon 0000 0000b pwmp0 0000 0000b sbuf xxxx xxxxb pwm0l 0000 0000b p2 xxx xx11b pwm1l 0000 0000b kbi 0000 0000b pwmcon1 0000 0000b auxr1 0000 0000b pwm2l 0000 0000b ie 0000 0000b pwm3l 0000 0000b saddr 0000 0000b pwmcon2 0000 0000b cmp1 0000 0000b pwmcon3 xxxxxxx0b cmp2 0000 0000b acc 0000 0000b p0m1 0000 0000b adccon xx00 0x00b p0m2 0000 0000b adch xxxx xxxxb p1m1 0000 0000b eie xx000 000b p1m2 0000 0000b b 0000 0000b p2m1 0000 0000b p0ids 0000 0000b p2m2 xxxx xx00b iph xx00 0000b ip0h x000 0000b ip1 xx00 0000b ip0 x000 0000b nvmaddr 0000 0000b saden 0000 0000b nvmdat 0000 0000b nvmcon 00xx xxxxb table 11-1: sfr reset value
w79e825/824/823/822 data sheet - 62 - the wdcon sfr bits are set/cleared in reset condition depending on the source of the reset. external reset watchdog reset power on reset wdcon 0x0x0xx0b 0x0x01x0b 01000000b 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 acce ss procedure to write. the remaining bits have unrestricted write accesses. please refer ta register description.
w79e825/824/823/822 data sheet publication release date: december 27, 2007 - 63 - revision a8 12 interrupts the w79e825 series have four priori ty level interrupts structure with 13 interrupt sources. each of the interrupt sources has an individual priority bit, fl ag, interrupt vector and enable bit. in addition, the interrupts can be globally enabled or disabled. 12.1 interrupt sources the external interrupts int0 and int1 can be either edge triggered or level triggered, depending on bits it0 and it1. the bits ie0 and ie1 in the 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 iex flag is automatically cleared when the service routine is called. if the level triggered mode is selected, then the requesting s ource 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 serv ice 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, when the time-out count is reached, the watchdog timer interrupt flag wdif (wdcon.3) is set. if the interrupt is enabled by t he enable bit eie.4, then an interrupt will occur. the serial block can generate interrupt on recepti on or transmission. there are two interrupt sources from the serial block, which are obtained by the ri and ti bits in the scon sfr. these bits are not automatically cleared by the hardw are, and the user will have to clear these bits by software. all the bits that generate interrupts can be set or reset by software, and t hereby software initiated interrupts can be generated. each of the individual interrupts can be enabled or disabled by setting or clearing a bit in the ie sfr. ie also has a gl obal enable/disable bit ea, which can be cleared to disable all interrupts. the adc can generate interrupt after finished adc conv erter. there is one interrupt source, which is obtained by the adci bit in the adccon sfr. this bit is not automatically cleared by the hardware, and the user will have to clear this bit using software. the two comparators can generate interrupt after co mparator output has toggl e occurs by cmf1 and cmf2. these bits are not automatically cleared by the hardware, and the user will have to clear these bits using software. the i2c function can generate interrupt, if ei2c and ea bits are enabled, when si flag is set due to a new i2c status code is generated, si flag is gen erated by hardware and must be cleared by software. the pwm function can generate interrupt by bkf flag, after external brake pin has brake occurred. this bit will be cleared by software. 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 lcal l 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 prio rity is not current ly 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 write to ie, eie, ip0, ip0h, ip1 or iph1 registers and is not a reti.
w79e825/824/823/822 data sheet - 64 - 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 samp led in the same machine 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. the processor responds to a valid interrupt by ex ecuting 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 whenever 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 in terrupts, 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 progr am counter contents onto the 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. t hese address of vector for the different sources are as follows: vector locations for interrupt sources source vector address source vector address external interrupt 0 0003h timer 0 overflow 000bh external interrupt 1 0013h timer 1 overflow 001bh serial port 0023h brownout interrupt 002bh i2c interrupt 0033h kbi interrupt 003bh comparator 2 interrupt 0043h - 004bh watchdog timer 0053h adc interrupt 005bh comparator 1 interrupt 0063h - 006bh pwm brake interrupt 0073h - 007bh table 12-1: vector locations for interrupt sources execution continues from the vect ored address till an reti instructi on is executed. on execution of the reti instruction the pr ocessor 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 stac k is restored to what it was after the hardware lcall, if the execution is return to the interr upted program. the processor does not notice anything if the stack contents are modified and will proceed wi th execution from the address put back into pc. note that a ret instruction would perform exactly the same process as a re ti instruction, but it would not inform the interrupt controller that the interrupt service routine is completed, and would leave the controller still thinking that the service rout ine is underway.
w79e825/824/823/822 data sheet publication release date: december 27, 2007 - 65 - revision a8 12.2 priority level structure the w79e825 series uses a four priority level in terrupt structure (highest, high, low and lowest) and supports up to 12 interrupt sources. the interrupt sources can be individually set to either high 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 inte rrupts themselves. this hierarchy comes into play when the interrupt controller has to resolve simult aneous requests having the same priority level. this hierarchy is defined as table below. this allows great flexibility in controlling and handling many interrupt sources. priority bits ipxh ipx interrupt priority level 0 0 level 0 (lowest priority) 0 1 level 1 1 0 level 2 1 1 level 3 (highest priority) table 12-2: four-level interrupt priority each interrupt source can be individually programm ed to one of four priority levels by setting or clearing bits in the ip0, ip0h, ip1, and ip1h register s. an interrupt service r outine in progress can be interrupted by a higher priority interrupt, but not by a nother interrupt of the same or lower priority. the highest priority interrupt service cannot be inte rrupted 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 requests 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 same priority level. as below table summarizes the interrupt sources, flag bits, vector addresses, enable bits, priority bits, arbitration ranking, and whether each interrupt may wake up the cpu from power down mode. source flag vector address interrupt enable bits interrupt priority flag cleared by arbitrati on ranking power down wakeup external interrupt 0 ie0 0003h ex0 (ie0.0) ip0h.0, ip0.0 hardware, follow the inverse of pin 1(highest) yes brownout detect bof 002bh ebo (ie.5) ip0h.5, ip0.5 software 2 yes watchdog timer wdif 0053h ewdi (eie.4) ip1h.4, ip1.4 software 3 yes (1) timer 0 interrupt tf0 000bh et0 (ie.1) ip0h.1, ip0.1 hardware, software 4 no i2c interrupt si 0033h ei2 (eie.0) ip1h.0, ip1.0 software 5 no adc converter adci 005bh ead (ie.6) ip0h.6, ip0.6 hardware 6 yes (1)
w79e825/824/823/822 data sheet - 66 - continued . source flag vector address interrupt enable bits interrupt priority flag cleared by arbitration ranking power down wakeup external interrupt 1 ie1 0013h ex1 (ie.2) ip0h.2, ip0.2 hardware, follow the inverse of pin 7 yes kbi interrupt kbf 003bh ekb (eie.1) ip1h.1, ip1.1 software 8 yes comparator 1 interrupt cmf1 0063h ec1 (eie.2) ip1h.2, ip1.2 software 9 yes timer 1 interrupt tf1 001bh et1 (ie.3) ip0h.3, ip0.3 hardware, software 10 no comparator 2 interrupt cmf2 0043h ec2 (eie.3) ip1h.3, ip1.3 software 11 yes serial port tx and rx ti & ri 0023h es (ie.4) ip0h.4, ip0.4 software 12 no pwm interrupt bkf 0073h epwm (eie.5) ip1h.5, ip1.5 software 13 (lowest) no note: 1. the watchdog timer and adc converter can wake up power down mode when its clock source is from internal rc. table 12-3: vector location for interrupt sources and power down wakeup 12.3 response time the response time for each interrupt source depend s on several factors, such as the nature of the interrupt and the instruction underway. in the case of external interrupts int0 to ri+ti, they are sampled at c3 of every machine cycle and then t heir corresponding interrupt 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 generat ed 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 inte rrupt service routine being executed. a longer response 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 po lling cycle 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) occu rs if the w79e825 series are performi ng a write to ie, eie, ip0, ip0h, ip1 or ip1h and then executes a mul or div instru ction. from the time an interrupt source is activated, the longest reaction time is 12 machine cy cles. this includes 1 machine cycle to detect the interrupt, 2 machine cycles to complete the ie, eie, ip0, ip0h, ip1 or ip1h access, 5 machine cycles to complete the mul or div instruction and 4 machin e cycles to complete the hardware lcall to the interrupt vector location. thus in a single-interrupt system the interrupt response time will always be more than 5 machine cycles and not more than 12 machine cycles. the ma ximum latency of 12 machine cycles is 48 clock cycles. note that in the standard 8051 the maxi mum latency is 8 machine cycles which equals 96 machine cycles. this is a 50% reduction in terms of clock periods.
w79e825/824/823/822 data sheet publication release date: december 27, 2007 - 67 - revision a8 12.4 interrupt inputs the w79e825 series have 13 interrupts source, and two individual interrupt inputs sources, one is for ie0, ie1, bof, kbf, wdt, adc, cmf1 and cmf2 , and other is if0, if1, ri+ti ,si and bkf. two interrupt inputs are identical to those present on t he standard 80c51 microcontroller as show in below figures. if an external interrupt is enabled when the w79e825 series are put into power down or idle mode, the interrupt will cause th e processor to wake up a nd resume operation. ie0 ex0 ie1 ex1 bof ebo kbf ekb adci eadc wdt ewdi cm1 ec1 cm2 ec2 ea wakeup (if in power down) interrupt to cpu figure 12-1: interrupt sources that can wake up from power down mode
w79e825/824/823/822 data sheet - 68 - ei2 si es ri+ti et1 tf1 et0 tf0 ea interrupt to cpu bkf epwm figure 12-2: interrupt sources that cannot wake up from power down mode
w79e825/824/823/822 data sheet publication release date: december 27, 2007 - 69 - revision a8 13 programmable timers/counters the w79e825 series have two 16-bit programm able timer/counters and one programmable watchdog timer. the watchdog timer is operationally quite different from the other two timers. it?s timer/counters have additional timer 0 or timer 1 over flow toggle output enable feature as compare to conventional timer/counters. this timer overflow toggle output can be configured to automatically toggle t0 or t1 pin output whenever a timer overflow occurs. 13.1 timer/counters 0 & 1 the w79e825 series have two 16-bit timer/counters . each of these timer/counters has two 8 bit registers which form the 16 bit counting register. fo r timer/counter 0 they are th0, the upper 8 bits register, and tl0, the lower 8 bit register. similarl y 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 counting external inputs. when configured as a "timer", the timer counts clock cycles. the timer clock can be programmed to be thought of as 1/12 of the system clock or 1/4 of the system cl ock. in the "counter" mode, the register is incremented on the falling edge of the exte rnal input pin, t0 for 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/8 of the master clock frequency. in either the "timer" or "counter" mode, the count register will be updated at c3. therefore, in the "timer" mode, the recognized negative transition on pi n 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.1.1 time-base selection the w79e825 series can operate like the standard 8051/52 family, counti ng at the rate of 1/12 of the clock speed, or in turbo mode, counting at the rate of 1/4 clock speed. the sp eed is controlled by the t0m and t1m bits in ckcon, and the default value is zero, which uses the standard 8051/52 speed. 13.1.2 mode 0 in mode 0, the timer/counter is a 13-bit counter. the 13-bit counter consists of thx (8 msb) and the five lower bits of tlx (5 lsb). the upper three bi ts of tlx are ignored. the timer/counter is enabled when trx is set and either gate is 0 or intx is 1. when t c / is 0, the timer/counter counts clock cycles; when t c / is 1, it counts falling edges on t0 (p1.2 fo r timer 0) or t1 (p0.7 for timer 1). for clock cycles, the time base may be 1/12 or 1/4 clock speed, and the falling edge of the clock increments the counter. when the 13-bit value move s from 1fffh to 0000h, the timer overflow flag tfx is set, and an interrupt occurs if enabled. this is illustrated in next figure below. in ?timer? mode, if output toggled enable bit of p2m1 .t0oe or p2m1.t1oe is enable, t0 or t1 output pin will toggle whenever a timer overflow occurs.
w79e825/824/823/822 data sheet - 70 - figure 13-1: timer/counters 0 & 1 in mode 0 13.1.3 mode 1 mode 1 is similar to mode 0 except that the counting register forms a 16-bit counter, 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 overfl ow flag tfx of the relevant timer is set and if enabled an interrupt will occur. the selection of the ti me-base in the timer mode is similar to that in mode 0. the gate function operates similarly to that in mode 0. figure 13-2: timer/counters 0 & 1 in mode 1
w79e825/824/823/822 data sheet publication release date: december 27, 2007 - 71 - revision a8 13.1.4 mode 2 in mode 2, the timer/counter is in the auto reload mo de. in this mode, tlx acts as 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 t he 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 (clo ck/12 or clock/4) or pulses on pin tn. in ?timer? mode, if output toggled enable bit of p2 m1.t0oe or p2m1.t1oe is enable, t0 or t1 output pin will toggle whenever a timer overflow occurs. figure 13-3: timer/counter 0 & 1 in mode 2 13.1.5 mode 3 mode 3 has different operating methods for the two time r/counters. for timer/counter 1, mode 3 simply freezes the counter. timer/counter 0, however, conf igures tl0 and th0 as two separate 8 bit count registers in this mode. the logic for this mode is shown in the figure. tl0 uses the timer/counter 0 control bits t c/ , gate, tr0, int0 and tf0. the tl0 can be used to count clock cycles (clock/12 or clock/4) or 1-to-0 transitions on pin t0 as determi ned by c/t (tmod.2). th0 is forced as a clock cycle counter (clock/12 or clock/4) and takes over the us e 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, 1 and 2, but its flexibility is somewhat lim ited. while its basic functionality is maintained, it no longer has control over its overflow flag tf1 and the enable bit tr1. 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. in ?timer? mode, if output toggled enable bit of p2 m1.t0oe or p2m1.t1oe is enable, t0 or t1 output pin will toggle whenever a timer overflow occurs.
w79e825/824/823/822 data sheet - 72 - figure 13-4: timer/counter mode 3
w79e825/824/823/822 data sheet publication release date: december 27, 2007 - 73 - revision a8 14 nvm memory the w79e825 series hav e nvm data memory of 256/128 bytes for customer?s data store used. the nvm data memory has four/two pages area and each page has 64 bytes as below figure. the page 0 address is from fc00h ~ fc3fh , page 1 address is from fc40h ~ fc7fh , page 2 address is from fc80h ~ fcbfh , and page 3 address is from fcc0h ~ fcffh . 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 nvmaddr, nvmdat and nvmcon. before write data to nvm memory, the page must be eras ed by providing page address on nvmaddr, which low byte address of on-chip code memory space w ill decode, then set eer of nvmcon.7. this will automatically hold fetch program code and pc counte r, and execute page erase. after finished, this bit will be cleared by hardware. the erase time is ~ 5ms. for writing data to nvm memory, user must se t address and data to nvmaddr 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 writ e completion, the ewr bit will be cleared by hardware, the uc will continue execute next instruction. the program time is ~50us. on-chip code memory space 0000h 16k/8k bytes on-chip code memory unused code memory unused code memory config 1 3fffh/1fffh 4000h/2000h ffffh page 0 64 bytes page 1 64 bytes page 2 64 bytes page 3 64 bytes fc00h fc3fh fc40h fc7fh fc80h fcbfh fcc0h fcffh nvm data memory area fc00h config 2 fcffh 256 bytes nvm data memory fbffh figure 14-1: w79e825/824 memory map
w79e825/824/823/822 data sheet - 74 - on-chip code memory space 0000h 4k/2k bytes on-chip code memory unused code memory unused code memory 0fffh/07ffh 1000h/0800h ffffh page 0 64 bytes page 1 64 bytes fc00h fc3fh fc40h fc7fh nvm data memory area fc00h fc7fh 128 bytes nvm data memory config 1 config 2 figure 14-2: w79e823/822 memory map
w79e825/824/823/822 data sheet publication release date: december 27, 2007 - 75 - revision a8 15 watchdog timer the watchdog timer is a free-running timer whic h can be programmed by the user to serve as a system monitor, a time-base generator or an event time r. 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 flag is set, which can cause an interrupt if enabled, and a system reset can also be caused if it is enabled. the interrupt will occur if the indi vidual interrupt enable and the global enable are set. the interrupt and reset functions are independent of each other and may be used separately or together depending on the user?s software. figure 15-1: watchdog timer the watchdog timer should first be restarted by usi ng wdclr. this ensures that the timer starts from a known state. the wdclr bit is used to restart t he watchdog timer. this bit is self clearing, i.e. after writing a 1 to this bit the software will automat ically clear it. the watc hdog timer w ill now count clock cycles. the time-out interval is sele cted 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 ti mer waits for an additional 512 clock cycles. if the watchdog reset ewrst (wdcon.1) is enabled, then 512 clocks after the time-out, if there is no wdclr, a system reset due to watc hdog timer will occur. this will la st for two machine cycles, and the watchdog timer reset flag wdrf (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 detect a time-out and the wdclr allows software to restar t 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 enable 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 unc hecked 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 interrupt is enabled to identify code locations wh ere 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 enabl ed and the watchdog interrupt may be disabled. if any errant code is executed now, then the reset watchdog timer inst ructions will not be executed at the required instants and watchdog reset will occur.
w79e825/824/823/822 data sheet - 76 - the watchdog timer time-out selection will result in different time-out values depending on the clock speed. the reset, when enabled, will occur when 512 clocks after time-out has occurred. wd1 wd0 interrupt time-out reset time-out number of clocks time @ 10 mhz 0 0 2 17 2 17 + 512 131072 13.11 ms 0 1 2 20 2 20 + 512 1048576 104.86 ms 1 0 2 23 2 23 + 512 8388608 838.86 ms 1 1 2 26 2 26 + 512 67108864 6710.89 ms table 15-2: time-out values for the watchdog timer the watchdog timer will de disabled by a power-on/fail reset. the watchdog timer reset does not disable the watchdog timer, but will restart it. in genera l, software should restart the timer to put it into a known state. the control bits that su pport the watchdog timer are discussed below. 15.1 watchdog control wdif: wdcon.3 - watchdog timer interrupt flag. this bi t is set whenever the time-out occurs in the watchdog timer. if the watchdog interrupt is enabled (eie.4), then an interrupt will occur (if the global interrupt enable is set and other interrupt requireme nts are met). software or any reset can clear this bit. wdrf: 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 ewdrst = 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 disabl e 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 t he hardware 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.
w79e825/824/823/822 data sheet publication release date: december 27, 2007 - 77 - revision a8 15.2 clock control of watchdog wd1, wd0: wdcon.5, wd con.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. the default watchdog time-out is 2 17 clocks, which is the shortest ti me-out period. the ewrst, wdif and wdclr bits are protected by the timed acce ss procedure. this prevents software from accidentally enabling or disabling the watchdog time r. more importantly, it makes it highly improbable that errant code can enable or disable the watchdog timer. the security bit wdte is located at bit 7 of config register. this bit is user to configure the clock source of watchdog timer either it is from the internal rc or from the uc clock. when wdte bit is cleared and 500khz clock is used to run the watchdog timer, there is a chance that the watchdog timer would hang as the counter does not increment. this problem arises when the watchdog is set to run, (wdcon.7, wdrun), t he wdclr bit (wdcon.0) is set to clear the watchdog timer and the next instruction is to set the pcon register for cpu to go into idle or power- down state. the reason this happens because t he setting/clearing of wdclr bit and the watchdog counter are running on different clock domains, cpu clock and internal rc clock respectively. when wdclr bit is set, to reset it, the counter must be non-zero. since the counter is running off a much slower clock, the counter may not have time to in crement before the cpu clock halts as it entered the idle/power-down mode. this results in the w dclr bit is always set & the watchdog counter remaining at zero. the solution to this problem is to monitor the wdclr bit, ens uring that it?s cleared before issue the instruction for the cp u to go into idle/power-down mode.
w79e825/824/823/822 data sheet - 78 - 16 serial port (uart) serial port in the w79e825 series is a full duplex port. the w79e825 series provide the user with additional features such as the frame error dete ction and the automatic address recognition. the serial ports are capable of synchronous as we ll as asynchronous communication. in synchronous mode the w79e825 series generate the clo ck and operates in a half duplex mode. in the asynchronous mode, full duplex operation 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 read from sbuf will be from the receiver buffer register. the seri al port can operate in four different modes as described below. 16.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 by the w79e825 series whether the devi ce 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 frame. 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 bi t (scon.5). when this bit is set to 0, then the serial port runs at 1/12 of the clock. when set to 1, the 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 the w79e825 series. the functional block diagram is shown below. data enters and leaves the serial port on 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 w79e825 series and the device at the other end of t he line. any instruction that causes a write to sbuf will start the transmission. the shift clock will be activated and data will be shifted 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 re mains low for 6 clock periods, and then goes high again. this ensures that at the receiving end the da ta on rxd line can either be clocked on the rising edge of the shift clock on txd or latc hed when the txd clock is low.
w79e825/824/823/822 data sheet publication release date: december 27, 2007 - 79 - revision a8 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.1 alternate input function p1.1 alternate output function p1.0 alternate output function 1/4 1 figure 16-1: serial port mode 0 the ti flag is set high in c1 following the end of transmi ssion of the last bit. the serial port will receive data when ren is 1 and ri is zero. the shift clock (t xd) 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 falling edge on the shift clock. this process continues till al l 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 rec eption, till the ri is cleared by software. 16.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 bi ts 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 progr ammed 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 trans mission is synchronized to the divide-by-16 counter 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 a fter the stop bit has been put out on txd pin. this will be at the 10th rollover of the divide-by-16 counter after a write to sbuf.
w79e825/824/823/822 data sheet - 80 - reception is enabled only if ren is high. the serial por t actually starts the re ceiving of serial data, with the detection of a falling edge on the rxd pin. t he 1-to-0 detector continuously monitors the rxd line, sampling it at the rate of 16 times the se lected baud rate. when a falling edge is detected, the divide?by-16 counter is immediately reset. this helps to align the bit boundaries with the rollovers of the divide-by-16 counter. the 16 states of the counter effect ively divide 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 val ue 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 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. after shifting in 8 data bits, 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 mi ddle of the stop bit, the receiver goes back to looking for a 1-to-0 transition on the rxd pin. figure 16-2: serial port mode 1
w79e825/824/823/822 data sheet publication release date: december 27, 2007 - 81 - revision a8 16.3 mode 2 this mode uses a total of 11 bits in asynch ronous full-duplex communication. the functional description is shown in the figure below. the frame cons ists 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 fre quency, which is determined by the smod bit in pcon sfr. 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 the divide-by- 16 counter. the next bit is placed on txd pin at c1 following the next rollover of the divide-by-16 count er. thus the transmission is synchronized to the divide-by-16 counter, and not directly to the wr ite 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 counter after a write to sbuf. reception is enabled only if ren is high. the serial por t actually starts the re ceiving of serial data, with the detection of a falling edge on the rxd pin. t he 1-to-0 detector continuously monitors the rxd line, sampling it at the rate of 16 times the se lected baud rate. when a falling edge is detected, the divide- by-16 counter is immediately reset. this helps to align the bit boundaries with the rollovers of the divide-by-16 counter. the 16 states of the counter effectively divide 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 improve the noise rejection feature of the serial port. figure 16-3: serial port mode 2
w79e825/824/823/822 data sheet - 82 - 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 port again looks for a falling edge in the rxd line. if a valid start bit is detected, then the rest of t he bits are also detected and shifted into the sbuf. after shifting in 9 data bits, 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 mi ddle of the stop bit, the receiver goes back to looking for a 1-to-0 transition on the rxd pin. 16.4 mode 3 this mode is similar to mode 2 in all aspects, ex cept 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. t he timer 1 should also be initialized if modes 1 and 3 are used. in all four modes, transmission is starte d by any instruction that uses sbuf as a destination register. reception is initiated in mode 0 by t he condition ri = 0 and ren = 1. this will generate a clock on the txd pin and shift in 8 bits on the rxd pi n. reception is initiated in the other modes by the incoming start bit if ren = 1. the external device will start the comm unication by transmitting the start bit. figure 16-4: serial port mode 3
w79e825/824/823/822 data sheet publication release date: december 27, 2007 - 83 - revision a8 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 bits 1 1 0, 1 1 1 3 asynch. timer 1 11 bits 1 1 0, 1 table 16-5: serial port mode summary table 16.5 framing error detection a frame error occurs when a valid stop bit is not det ected. this could indicate incorrect serial data communication. typically the frame error is due to noise and contention on the serial communication line. the w79e825 series have the facility to detect such framing errors and set a flag which can be checked by software. the frame error fe bit is located in scon.7. this bit is normally used as sm0 in the standard 8051 family. however, in the w79e825 se ries 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 determined 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 clear ed by software. note that smod0 must be 1 while reading or writing to fe. if fe is set, then any follo wing frames received without any error will not clear the fe flag. the clearing has to be done by software. 16.6 multiprocessor communications multiprocessor communications makes use of the 9t h data bit in modes 2 and 3. in the w79e825 series, 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 programmer task. in the multiprocessor communication mode, the addr ess 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 sends 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 rec eption of an address byte. the automatic address recognition feature ensures that only the addressed slave will be in terrupted. the address comparison is done in hardware not software. the addressed slave clears the sm2 bit, thereby cleari ng the way to receive data bytes. with sm2 = 0, the slave will be interrupted on the reception of ev ery single complete frame of data. the unaddressed slaves will be unaffected, as they will be still waiting fo r 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 ri is set only if a valid frame is received and the received byte matches the given or broadcast address.
w79e825/824/823/822 data sheet - 84 - the master processor can selectively communicate wi th groups of slaves by using the given address. all the slaves can be addressed together using t he broadcast 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 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. fo r slave 1, it is a 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 slave 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 simulta neously, then the address must have bit 0 = 1 and bit 1 = 0. the bit 3 position is don'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 saddr and saden sfrs. the zeros in the result are defined as don't cares. in most cases the broadca st 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 address a9 h and b9h respectively. on reset, these two sfrs are initialized to 00h. this results in gi ven address and broadcast address being set as xxxx xxxx (i.e. all bits don't care). this effectively re moves the multiprocessor communications feature, since any selectivity is disabled.
w79e825/824/823/822 data sheet publication release date: december 27, 2007 - 85 - revision a8 17 time access proctection the w79e825 series have a new feature, like the watchdog timer which is a crucial to proper operation of the system. if left unprotected, errant code may writ e to the watchdog control bits resulting in incorrect operation and loss of control. in order to prevent this, the w79e825 series have a protection scheme which controls the write access to critical bits. this protection scheme is done using a timed access. in this method, the bits which are to be protec ted have a timed write enable window. a write is successful only if 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 writ ing aah and immediately 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 software 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 remains open for 3 machine cycles, during which the user may write to the protected bi ts. 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 nop ;1 m/c nop ;1 m/c clr ewt ;2 m/c
w79e825/824/823/822 data sheet - 86 - 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 bit occurs after the window has closed, and so there is effectively no change in th e status of the protected bit. in example 5, the second write to ta occurs 4 machine cycles after t he first write, therefore t he timed access window is not opened at all, and the write to the protected bit fails.
w79e825/824/823/822 data sheet publication release date: december 27, 2007 - 87 - revision a8 18 keyboard interrupt (kbi) the w79e825 series are provided 8 keyboard interr upt function to detect keypad status which key is acted, and allow a single interrupt to be generat ed when any key is pressed on a keyboard or keypad connected to specific pins of the w79e825 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 powe r down or idle mode. keyboard function is supported through by port 0. it can allow any or all pins of port 0 to be enabled to cause this interrupt. port pins are enabled by the sett ing of bits of kbi0 ~ kbi7 in the kbi register, as shown below figure. the keyboard interrupt flag (kbf) in the auxr1 register is set when any enabled pin is pulled low while the kbi interrupt function is active, and the low pulse must be more than 1 machine cycle, an interrupt will be generat ed if it has been enabled. the kbf bit set by hardware and must be cleared by so ftware. in order to determine wh ich key was pressed, the kbi will allow the interrupt service routine to poll port 0. p0.7 p0.6 p0.5 p0.4 p0.3 p0.2 p0.0 kbi.0 kbi.1 p0.1 kbi.2 kbi.3 kbi.4 kbi.5 kbi.6 kbi.7 ekb (from ie1 register) kbf (kbi interrupt) figure 18-1: keyboard interrupt
w79e825/824/823/822 data sheet - 88 - 19 analog comparators the w79e825 series are provided two comparator s. input and output options allow use of the comparators in a number of differ ent configurations. the comparator output is a logical one when its positive input is greater than its negative input, other wise the output is a zero. each comparator can be configured to cause to an inte rrupt when the output value change. the block diagram is as below. each comparator has a control r egister (cmp1 and cmp2), both i nputs are cinna, cinnb, cmpref and internal reference voltage, and outputs are cmp1 and cmp2 by setting oen bit. after enable comparators the comparator need waited stable ti me to guarantee comparator output. if programmer used internal reference voltage, it will be set oen bi t to ?1?. the value of internal reference voltage (vref) is 1.19v +/- 10%. - + cmf1 cmp1(p0.6) interrupt cn1 cp1 vref co1 oe1 change detect comparator1 (p0.4) cin1a (p0.3) cin1b (p0.5) cmpref - + cmf2 cmp2(p0.0) interrupt cn2 cp2 co2 oe2 change detect comparator2 (p0.2) cin2a (p0.1) cin2b cmp1 analog circuit cmp2 analog circuit vref ce1 ce2 enable cmp1 enable cmp2 en figure 19-1: analog comparators
w79e825/824/823/822 data sheet publication release date: december 27, 2007 - 89 - revision a8 20 i/o port configuration the w79e825 series have three i/o ports, port 0, port 1 and port 2. all pins of i/o ports can be configured to one of four types by software except p1.5 is only input pin. when p1.5 is configured reset pin by rpd=0 in the config 1 register , the w79e825 series can support 15 pins by use crystal. if used on-chip rc oscillator the p1.5 is configured input pin, the w79e825 series can be supported up to 18 pins. the i/o ports configuration setting as below table. pxm1.y pxm2.y port input/output mode 0 0 quasi-bidirectional 0 1 push-pull 1 0 input only (high impedance) p2m1.pxs=0, ttl input p2m1.pxs=1, schmitt input 1 1 open drain table 20-1: i/o port configuration table all port pins can be determined to high or low after reset by configure prhi bit in the config1 register. after reset, these pins are in quasi-bidire ctional mode. the port pin of p1.5 only is a schmitt trigger input. enabled toggle outputs from timer 0 and timer 1 by ent0 and ent1 on p2m1 register, the output frequency of timer 0 or timer 1 is by timer overflow. each i/o port of the w79e825 series may be selected to use ttl level inputs or schmitt inputs by p(n)s bit on p2m1 register, where n is 0, 1 or 2. when p(n)s is set to 1, ports are selected schmitt trigger inputs on port(n). the p2.0 (xtal2) can be configured clock output when used on-chip rc or external oscillator is clock source, and the frequen cy of clock output is divided by 4 on on-chip rc clock or external oscillator. 20.1 quasi-bidirectional output configuration after chip was power on or reset, the all ports out put are this mode, and output is common with the 8051. this mode can be used as both an input and ou tput without the need to reconfigure the port. when the pin is pulled low, it is driven strongly and ab le 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 purposes. this mode has three pull-up resisters that are ?str ong? pull-up, ?weak? pull-up and ?very weak? pull-up. the ?strong? pull-up is used fast transition from l ogic ?0? change to logic ?1?, and it is fast latch and transition. when port pins is occur from logic ?0? to logic ?1?, the strong pull- up will quickly turn on two cpu clocks to pull high then turn off.
w79e825/824/823/822 data sheet - 90 - the ?weak? pull-up is turned on when the input port pin is logic ?1? level or itself is logic ?1?, and it provides the most source current for a quasi-bidirectional pin that output is ?1? or port latch is logic ?0??. the ?very weak? pull-up is turned on when the port latch is logic ?1?. if port latch is logic ?0?, it will be turned off. the very weak pull-up is support a very sma ll current that will pull the pin high if it is left floating. and the quasi-bidirectional port configuration is shown as below figure. if port pin is low, it can drives large sink current for output, and it is similar with push-pull and open drain on sink current output. port pin 2 cpu clock delay input data port latch data pp p n vdd strong very weak weak figure 20-2: quasi-bidirectional output 20.2 open drain output configuration to configure this mode is turned off all pull-ups. if used similar as a logic output, the port must has an external pull-up resister. the open drain port configuration is shown as below. port pin port latch data n input data figure 20-3: open drain output
w79e825/824/823/822 data sheet publication release date: december 27, 2007 - 91 - revision a8 20.3 push-pull output configuration the push-pull output mode has two strong pull-up and pull-down structure that support large source and sink current output. it removes ?weak? pull-up and ?very weak? pull-up resister and remain ?strong pull-up resister on quasi-bidirectional output mode. the ?strong? pull-up is always turns on when port latch is logic ?1? to support source current. the pus h-pull port configuration is shown in below figure. the w79e825 series have three port pins that c an?t be configured. they are p1.2, p1.3, and p1.5. the port pins p1.2 and p1.3 are configured to open drain outputs. they may be used as inputs by writing ones to their respective port latches. port pin input data port latch data p n vdd figure 20-4: push-pull output 20.4 input only configuration by configure this mode, the ports are only digita l input and disable digital output. the w79e825 series can select input pin to schmitt trigger or ttl level input by pxm1.y and pxm2.y registers.
w79e825/824/823/822 data sheet - 92 - 21 oscillator the w79e825 series provides three oscillator input option. these are configured at config register (config1) that include on-chip rc oscillator op tion, external clock i nput option and crystal oscillator input option. the crystal oscillator input frequency may be supported from 4mhz to 20mhz, and without capacitor or resister. figure 21-1: oscillator 21.1 on-chip rc oscillator option the on-chip rc oscillator is fixed at 6mhz +/- 25% frequency to support clock source. when fosc1, fosc0 = 10h, the on-chip rc oscillator is enabled. a clock output on p2.0 (xtal2) may be enabled when on-chip rc oscillator is used.
w79e825/824/823/822 data sheet publication release date: december 27, 2007 - 93 - revision a8 21.2 external clock input option the clock source pin (xtal1) is from external clock input by fosc1, fosc0 = 11h, and frequency range is form 0hz up to 20mhz. a clock output on p2.0 (xtal2) may be enabled when external clock input is used. the w79e825 series supports a clock output func tion when either the on-chip rc oscillator or the external clock input options is selected. this allo ws external devices to synchronize to the w79e825 serial. when enabled, via the enclk bit in the p2 m1 register, the cloc k output appears on the xtal2/clkout pin whenever the on-chip oscillator is running, 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. 21.3 cpu clock rate select the cpu clock of w79e825 series may be selected by the divm register. if divm = 00h, the cpu clock is running at 4 cpu clock pre machine c ycle, and without any division from source clock (fosc). when the divm register is set to n val ue, the cpu clock is divided by 2(dvim+1), so cpu clock frequency division is from 4 to 512. th e user may use this feature to set cpu at a lower speed rate for reducing power consumption. this is very similar to the situation when cpu has entered idle mode. in addition this fr equency division function affect all peripheral timings as they are all sourcing from the cpu clock(fcpu).
w79e825/824/823/822 data sheet - 94 - 22 power monitoring function power-on detect and brownout are two addition al power monitoring functions implemented in w79e825 series to prevent incorrect operation during power up and power drop or loss. 22.1 power on detect the power?on detect function is a designed to detect power up after power voltage reaches to a level where brownout detect can work. after po wer on detect, the por (pcon.4) will be set to ?1? to indicate an initial power up condition. the por flag will be cleared by software. 22.2 brownout detect the brownout detect function is detect power voltag e is drops to brownout voltage level, and allows preventing some process work or indicate power warming. the w79e825 series have two brownout voltage levels to select by bov (config1.4). if bo v =0 that brownout voltage level is 3.8v, if bov = 1 that brownout voltage level is 2.5v. when the brownout voltage is dr op to select level, the brownout detector will detect and keeps this active until vdd is returns to above brownout detect voltage. the brownout detect block is as follow. boi (enable brownout detect) brownout detect circuit 0 1 bof to reset to brownout interrupt bod figure 22-1: brownout detect block when brownout detect is enabled by bod (aux r1.6), the bof (pcon.5) flag will be set and brownout reset will occur. 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. bof is cleared by software. in order to guarantee a correct detection of brow nout, the vdd fail time must be slower than 50mv/us, and rise time is slower th an 2mv/us to ensure a proper reset.
w79e825/824/823/822 data sheet publication release date: december 27, 2007 - 95 - revision a8 23 pulse-width-modulated (pwm) outputs the w79e825 series have four pulse width modul ated (pwm) channels, and the pwm outputs are pwm0 (p0.1), pwm1 (p1.6), pwm2 (p1.7) and pwm3 (p0.0). the initial pwm outputs level correspondingly depend on the prhi level set prior to the chip reset. when prhi set to high, pwm output will initialize to high after chip reset; if prhi set to low, pwm output will be initialize to low after chip reset. the w79e825 series support 10-bits down counter with cpu clock as its input. the pwm counter clock, has the same frequency as the clock source f cpu = f osc . when the counter reaches underflow it will automatic reloaded from counter re gister. the pwm frequency is given by: f pwm = f cpu / (pwmp+1), where pwmp is 10-bits register of pwmph.1, pwmph.0 and pwmpl.7~pwmpl.0. the counter register will be loaded with the pwmp register value when pwmrun, load and cf are equal to 1; the load bit will be automatically cleared to zero on the next clock cycle, and at the same time the counter register value will be loaded to th e 10 bits down counter. cf flag is 10-bits down counter reaches underflow, the cf flag will be cleared by software. the pulse width of each pwm output is determine d by the compare registers of pwm0l through pwm3l and pwm0h through pwm3h. when pwm compar e register is greater than 10-bits counter register, the pwm output is low. load bit has to be se t to 1 for alteration of pwmn width. after the new values are written to the pwmn registers, and if load bit is set to 1, the new pwmn values will be loaded to the pwmn registers upon the next underflow. the pwm output high pulses width is given by: t hi = (pwmp ? pwmn+1). notice, if compare register is set to 000h, the pwmn output will stay at high, and if compare register is set to 3ffh, the pwmn ou tput will stuck at low until there is a change in the compare register.
w79e825/824/823/822 data sheet - 96 - 10-bits counter compare register counter register pwm0 register pwmrun f cpu + - compare register pwm1 register + - compare register pwm2 register + - compare register pwm3 register + - pwm1i pwm2i pwm3i pwm0i pwm0b pwm1b pwm2b pwm3b 0 1 0 0 0 1 1 1 + - cf x x x x y y y y > > > > load pwmp register bken brake control bl ock bpen bkch clrpwm cl ear counter bkps brake pin (p0.2) bkf 0 1 brake flag enable external brake pin (bpen,bkch) = (1,0) p0.2=0 p0.2=1 p0.1 p1.6 p1.7 p0.0 pwm0 pwm1 pwm2 pwm3 pin 20 (p0.1) pin 3 (p1.6) pin 2 (p1.7) pin 1 (p0.0) figure 23-1: w79e825/824/823/822 pwm block diagram
w79e825/824/823/822 data sheet publication release date: december 27, 2007 - 97 - revision a8 the w79e825 series devices support brake function which can be activated by software or external pin (p0.2). the brake function is controlled by the pwmcon2 register. the setting and details description of software brake and external pin brake can be found at the brake condition table at the sfr section. as for external brake, the user program can poll th e brake flag (bkf) or enable pwm?s brake interrupt to determine when the external brake pin is asse rted and causes a brake to occur. the brake pin (p0.2) can be set to trigger the brake function by either low or high level, by clearing or setting the pwmcon2.6 (bpks) bit respectively. the details description of varies brake functions can be found in the brake condition table. since the brake pin being asserted will automatic ally clear the run bit of pwmcon1.7 and bkf (pwmcon3.0) flag will be set, the user program can poll this bit or enable pwm?s brake interrupt to determine when the brake pin causes a brake to occur. the other method for detecting a brake caused by the brake pin would be to tie the brake pi n to one of the external interrupt pins. this latter approach is needed if the brake signal is of insuffi cient length to ensure that it can be captured by a polling routine. when, after being asserted, the co ndition causing the brake is removed, the pwm outputs go to whatever state that had immediately prior to the brake. this means that in order to go from brake being asserted to having the pwm r un without going through an i ndeterminate state, care must be taken. if the brake pin ca uses brake to be asserted, the fo llowing prototype code will allow the pwm to go from brake and then run smoothly after brake is released.
w79e825/824/823/822 data sheet - 98 - 1. pwmn output=pwmnb 2. h/w set bkf=1 & pwmrun=0 3. s/w switch to s/w brake (bken,bpen,bkch)=(1,0,0) 4. set pwmn comparator output = pwmnb or a given pattern 1. clear 10-bit pwm counter clrpwm=1 2. reload pwmp & pwm registers 3. enable brake function (bken,bpen,bkch)=(1,1,0) 1. clear bkf pwm output=pwm comparator output 2. re-start pwm running by setting pwmrun=1; load bit=1 start end initialize pwm function 1. set pwm control regs 2. set pwm brake output pattern(pwmnb) 3. enable brake function (bken,bpen,bkch)=(1,1,0) pwm starts running brake occurs? yes no brake pin is asserted? no yes figure 23-2: pwm brake function
w79e825/824/823/822 data sheet publication release date: december 27, 2007 - 99 - revision a8 24 analog-to-digital converter the adc contains a dac which converts the content s of a successive approximation register to a voltage (vdac) which is compared to the analog inpu t voltage (vin). the output of the comparator is fed to the successive approximation control l ogic which controls the successive approximation register. a conversion is initiated by setting adcs in the adccon register. there are two triggering methods by adc to start conversion, either by purely software start or external pin stadc triggering. the software start mode is used to trigger adc conv ersion regardless of adccon.5 (adcex) bit is set or cleared. a conv ersion will start simply by setting t he adccon.3 (adcs) bit. as for the external stadc pin triggering mode, adccon.5 (adcex) bit has to be set and a rise edge pulse has to apply to stadc pin to trigger the adc conver sion. for the rising edge triggering method, a minimum of at least 2 machine cycles symmetrical pulse is required. the low-to-high transition of stadc is recognized at the end of a machine cycle, and the conversion commences at the beginning of the next cycle. when a conversion is initiated by software, the conversion starts at the beginning of the machine c ycle which follows the inst ruction that sets adcs. adcs is actually implemented with tpw flip-flops : a command flip-flop which is affected by set operations, and a status flag which is accessed during read operations. the next two machine cycles are used to initiate the converter. at the end of t he first cycle, the adcs status flag is set end a value of ?1? will be returned if the adcs flag is read while the conversion is in progress. sampling of the analog input co mmences at the end of the second cycle. during the next eight machine cycles, the voltage at the previously selected pin of one of analog input pin is sampled, and this input voltage should be stable in order to obtain a useful sample. in any event, the input voltage slew rate must be less than 10v /ms in order to prevent an undefined result. the successive approximation control logic first sets t he most significant bit and clears all other bits in the successive approximation register (10 0000 0000b) . the output of the dac (50% full scale) is compared to the input voltage vin. if the input voltag e is greater than vdac, then the bit remains set; otherwise if is cleared. the successive approximation control logic now sets the next most significant bit (11 0000 0000b or 01 0000 0000b, depending on the previous result), and the vdac is compared to vin again. if the input voltage is greater then vdac, then the bit rema ins set; otherwise it is cleared. this process is repeated until all ten bits have been tested, at which stage the result of the c onversion is held in the successive approximation register. the conv ersion takes four machine cycles per bit. the end of the 10-bit conversion is flagged by cont rol bit adccon.4 (adci). the upper 8 bits of the result are held in special function register adch, and the two remaining bits are held in adccon.7 (adc.1) and adccon.6 (adc.0). the user may ignore the two least significant bits in adccon and use the adc as an 8-bit converter (8 upper bits in adch). in any event, the total actual conversion time is 52 machine cycles. adci will be set and the adcs status flag will be reset 52 cycles after the adcs is set. control bits adccon.0 and adccon.1 are used to control an analog multiplexer which selects one of 4 analog channels. an adc conversion in progress is unaffected by an external or software adc start. the result of a completed conver sion remains unaffected provided adci = logic 1; a new adc conversion alr eady in progress is aborted when the idle or power down mode is entered. the result of a completed conversion (adci = l ogic 1) remains unaffected when entering the idle mode.
w79e825/824/823/822 data sheet - 100 - dac msb lsb successive approximation register vin + - comparator start ready (stop) successive approximation control logic v dac figure 24-1: successive approximation adc 24.1 adc resolution and analog supply: the adc circuit has its own supply pins (av dd and avss) and one pins (vref+) connected to each end of the dac?s resistance-ladd er that the avdd and vref+ are connected to vdd and avss is connected to vss. the ladder has 1023 equally spac ed taps, separated by a resistance of ?r?. the first tap is located 0.5r above avss, and the last tap is lo cated 0.5r below vref+. this gives a total ladder resistance of 1024r. this structure ensu res that the dac is monotonic and results in a symmetrical quantization error. for input voltages between vss and [(vref+) + ? lsb ], the 10-bit result of an a/d conversion will be 0000000000b = 000h. for input voltages between [(vr ef+) ? 3/2 lsb] and vref+, the result of a conversion will be 1111111111b = 3ffh. vref+ and avss may be bet ween avdd + 0.2v and vss ? 0.2 v. vref+ should be positive with respect to vss, and the input voltage (vin) should be between vref+ and vss. the result can always be calculated from the following formula: result = vref vin 1024  u or result = vdd vin 1024 u
w79e825/824/823/822 data sheet publication release date: december 27, 2007 - 101 - revision a8 10-bits adc block adc0(p0.3) adc[9:0] adci adcs vdd vref+ vss aadr[1:0] analog input multiplexer 0 1 p1.4 adcex adcclk adcen adc1(p0.4) adc2(p0.5) adc3(p0.6) avss avdd rc_clk 1 0 rcclk f cpu /4 figure 24-2: the adc block diagram
w79e825/824/823/822 data sheet - 102 - 25 i2c serial control the i2c bus uses two wires (sda and scl) to tran sfer information between devices connected to the bus. the main features of the bus are: ? bidirectional data transfer between masters and slaves ? multimaster bus (no central master) ? arbitration between simultaneously transmitting masters without corrupti on of serial data on the bus ? serial clock synchronization allows devices with different bit rates to communicate via one serial bus ? serial clock synchronization can be used as a handshake mechanism to suspend and resume serial transfer ? the i2c bus may be used for test and diagnostic purposes 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 25-1: i2c bus timing the device?s on-chip i2c logic provides the serial interface that meets the i2c bus standard mode specification. the i2c logic handles bytes transf er autonomously. it also keeps track of serial transfers, and a status register (i2status) reflects the status of the i2c bus. the i2c port, scl and sda are at p1.2 and p1.3. w hen the i/o pins are used as i2c port, user must set the pins to logic high in advance. when i2c po rt is enabled by setting ens to high, the internal states will be controlled by i2con and i2c logic har dware. once a new stat us code is generated and stored in i2status, the i2c interrupt flag (si) w ill be set automatically. if both ea and ei2c are also in logic high, the i2c interrupt is requested. the 5 mo st significant bits of i2st atus stores the internal state code, the lowest 3 bits are always zero and the content keeps stable until si is cleared by software. 25.1 sio port the sio port is a serial i/o port, which supports all transfer modes from and to the i2c bus. the sio port handles byte transfers autonomously. to enable this port, the bit ens1 in i2con should be set to '1'. the cpu interfaces to the sio port through 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 i2timer (timer counter register, bfh). the sio h/w inte rfaces to the i2c bus via two pins: sda (p1.3, serial data line) and scl (p1.2, serial clock line) . pull up resistor is needed for pin p1.2 and p1.3 for i2c operation as these are 2 open drain pins.
w79e825/824/823/822 data sheet publication release date: december 27, 2007 - 103 - revision a8 25.2 the i2c control registers: the i2c has 1 control register (i2con) to control th e transmit/receive flow, 1 data register (i2dat) to buffer the tx/rx data, 1 status regi ster (i2status) to catch the st ate of tx/rx, recognizable slave address register for slave mode use and 1 clock rate control block for master mode to generate the variable baud rate. 25.2.1 the address registers, i2addr i2c port is equipped with one slave address register. the contents of the regi ster are irrelevant when i2c is in master mode. in the slave mode, the se ven most significant bits must be loaded with the mcu?s own slave address. the i2c hardware will re act if the contents 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 bit is set, the i2c is in slave mode, it can be received the general call address by 00h after master send general call addres s to i2c bus, then it will follow status of gc m ode. if it is in master mode, the aa bit must be cleared when it will send general call address of 00h to i2c bus. 25.2.2 the data register, i2dat this register contains a byte of serial data to be 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 i2dat remains stable as long as si bit is se t. while data is being shifted out, data on the bus is simultaneously being shifted in; i2dat always contains the last data byte present on the bus. thus, in the event of arbitration lost, the tr ansition from master transmitter to slave receiver is made with the correct data in i2dat. 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 t he cpu. serial data is shifted 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 t he acknowledge bit (ack or nack) is returned by the control logic during the ninth clock pulse. serial data is shifted out from i2dat on the falling edges of scl clock pulses, and is shifted into i2 dat on the rising edges of scl clock pulses. i2dat.7 i2dat.6 i2dat.5 i2dat.4 i2dat.3 i2dat.2 i2dat.1 i2dat.0 i2c data register: shifting direction
w79e825/824/823/822 data sheet - 104 - 25.2.3 the control register, i2con the cpu can read from and write to this 8-bit, dire ctly addressable sfr. tw o 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 bu s. the sto bit is also cleared when ens = "0". ensi set to enable 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. sta i2c start flag. setting sta to logic 1 to enter master mode, the i2c hardware sends a start or repeat 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 hardware automatically. in a slave mode, setting sto resets i2c hardware to the defined ?not addressed? sl ave mode. this means it is no longer in the slave receiver mode to receive data from the master transmit device. si i2c port 1 interrupt flag. when a new sio st ate is present in the s1sta register, the si flag is set by hardware, and if the ea and ei2c 1 bits are both set, the i2c1 interrupt is requested. si must be cleared by software. aa assert acknowledge control bit. when aa=1 prior to address or data received, an acknowledged (low level to sda) will be returned during the acknowledge clock pulse on the scl line when 1.) a slave is acknowledg ing the address sent fr om master, 2.) the receiver devices are acknowledging the data sent by transmitter. when aa=0 prior to address or data received, a not acknowledged (high level to sda) will be returned during the acknowledge clock pulse on the scl line. 25.2.4 the status register, i2status i2status is an 8-bit read-only register. the three l east significant bits are always 0. the five most significant bits contain the status code. there are 23 possi ble status 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 enter ed, a status interrupt is requested (si = 1). a valid status code is present in i2status one machine cycle after si is set by hardware and is still present one machine cycle after si has been reset by software. 25.2.5 the i2c clock baud rate bits, i2clk the data baud rate of i2c is determines by i2clk r egister when sio is in a master mode. it is not important when sio is in a slave mode. in the slave modes, sio w ill automatically synchronize with any clock frequency up to 400 khz from master i2c device. the data baud rate of i2c setting is data baud rate of i2c = fcpu / (i2clk+1 ). the fcpu=fosc/4. if fosc = 16mhz, the i2clk = 40(28h), so data baud rate of i2c = 16mhz/(4x (40 +1)) = 97.56kbits/sec. the block diagram is as below figure.
w79e825/824/823/822 data sheet publication release date: december 27, 2007 - 105 - revision a8 figure 25-2: i2c timer count block diagram 25.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 application, 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 ge neral call address. if one of these addresses is detected, and if the slave is willin g to receive or transmit data from/to master(by setting the aa bit), acknowledge pulse will be transmi tted out on the 9th clo ck, hence an interrupt is requested on both master and slave devices if interrupt is enabled. wh en the microcontroller wishes to become the bus master, the hardware waits until the bus is free bef ore the master mode is entered so that a possible slave action is not interrupted. if bus arbitration is lo st in the master mode, i2c port switches to the slave mode immediately and can detect its own slave address in the same serial transfer. 25.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, an d it is represented by ?w? in the flow diagrams. thus the first byte transmitted is sla+w. serial data is transmitted 8 bi ts at a time. after each byte is transmitted, an acknowledge bit is received. start and stop conditions are output to indicate the beginning and the end of a serial transfer. 25.3.2 master receiver mode in this case the data direction bit (r/w) will be lo gic 1, and it is represented by ?r? in the flow diagrams. thus the first byte transmitted is sla+r. serial data is 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. 25.3.3 slave receiver mode serial data and the serial clock are received thro ugh 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 per formed by hardware after reception of the slave address and direction bit.
w79e825/824/823/822 data sheet - 106 - 25.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 direction is reversed. serial data is transmitted via sda while the serial clock is input through scl. start a nd stop conditions are recognized as the beginning and end of a serial transfer. 25.4 data transfer flow in five operating modes the five operating modes are: master/transmi tter, 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 co mplexion of the new action, a new status code will be updated and the si flag will be set. if the i2c interrupt control bits (ea and ei2) are enable, appropriate action or software branch of the new st atus code can be performed in the interrupt service routine. data transfers in each mode are shown in the following figures. *** legend for the following five figures: 08h a start has been transmitted. (sta,sto,si,aa)=(0,0,0,x) sla+w will be transmitted; ack bit will be received. 18h sla+w has been transmitted; ack has been received. last state last action is done next setting in s1con expected next action next action is done new state software's access to s1dat with respect to "expected next actio n": software should load the data byte (to be transmitted) into s1dat before new s1con 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 s1dat before new s1con setting is done. (3) data byte will be received: software can read the received data byte from s1dat while a new state is entered. figure 25-3: legen for the following four figures
w79e825/824/823/822 data sheet publication release date: december 27, 2007 - 107 - revision a8 figure 25-4: master transmitter mode
w79e825/824/823/822 data sheet - 108 - figure 25-5: master receiver mode
w79e825/824/823/822 data sheet publication release date: december 27, 2007 - 109 - revision a8 figure 25-6: slave transmitter mode
w79e825/824/823/822 data sheet - 110 - figure 25-7:slave receiver mode
w79e825/824/823/822 data sheet publication release date: december 27, 2007 - 111 - revision a8 figure 25-8:gc mode
w79e825/824/823/822 data sheet - 112 - 26 icp(in-circuit program) flash program the contexts of flash in w79e825 series are empt y by default. user must program the flash eprom by external writer device or by icp (in-circuit program) tool. in the icp tool, the user must take note of ic p?s program pins used in system board. in some application circuits, the pins are located at p1.5, p0.4 and p0.5, as below figure. during icp programming, p1.5 must be set to high voltage (~10.5v), and keeping this voltage to update code, data and/or configure config bits. after programming completion, the high voltage of p1.5 should be released. so, it is highly recommended user power off then power on after icp programming has completed on the system board. upon entry into icp program mode, all pin will be set to quasi-bidirectional mode, and output to level ?1?. the w79e825 series support programming of flash eprom ( 16k/8k/4k/2k bytes ap flash eprom) and nvm data memory ( 256/128 bytes). user has the option to pr ogram the ap flash and nvm either individually or both. w79e825 series rst p0.4 p0.5 vdd vss to i/o pin to i/o pin to reset or input pin vdd vpp data clock vss vcc jumper icp connector system board icp power jumper figure 26-1: application circuit of icp note: 1. when using icp to upgrade code, the p1.5, p0.4 and p0.5 must be taken within design system board. 2. after program finished by icp, to suggest system power must power off and remove icp connector then power on. 3. it is recommended that user performs erase functi on and programming configure bits continuously without any interruption.
w79e825/824/823/822 data sheet publication release date: december 27, 2007 - 113 - revision a8 27 config bits the w79e825 series have two config bits (confi g1, config2) that must be define at power up and can not be set after the program start of execution. those featur es are configured through the use of two flash eprom bytes, and the flash eprom can be programmed and verified repeatedly. until the code inside the flash eprom is confirmed ok, the code can be protected. the protection of flash eprom (config2) and those operatio ns on it are described below. the data of these bytes may be read by the movc instruction at the addresses. 27.1 config1 config register 1 config 1 : 76 54321 0 wdte: watchdog timer clock source bit. rpd: reset pin disable bit. config bit prhi: port reset high or low bit. bov: brownout voltage select bit. fosc1: cpu oscillator type select bit 1. fosc0: cpu oscillator type select bit 0. rpd wdte prhi bov - fosc0 fosc1 - - bit name function 7 wdte clock source of watchdog timer select bit: 0: the internal rc oscillator clock is for watchdog timer clock used. 1: the uc clock is for watchdog timer clock used. 6 rpd reset pin disable bit: 0: enable reset function of pin 1.5. 1: disable reset function of pin 1.5, 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 high state. 4 bov brownout voltage select bit: 0: brownout detect voltage is 3.8v. 1: brownout detect voltage is 2.5v.
w79e825/824/823/822 data sheet - 114 - continued bit name function 3 - reserved. 2 - reserved. 1 fosc1 cpu oscillator type select bit 1 0 fosc0 cpu oscillator type select bit 0 oscillator configuration bits: fosc1 fosc0 osc source 0 0 4mhz ~ 20mhz crystal 0 1 internal rc oscillator 1 0 reserved 1 1 external oscillator in xtal1 27.2 config2 config register 2 config 2 : 76 54321 0 c7: 16k/8k/4k/2k flash eprom code lock bit. c6: 256/128 byte data lock bit. config bit c6 c7 - -- - - - c7: 16k/8k/4k/2k flash eprom lock bit this bit is used to protect the customer's progra m code. it may be set after the programmer finishes the programming and verifies sequence. once this bit is set to logic 0, both the flash eprom data and config registers can not be accessed again. c6: 256/128 byte data flash eprom lock bit this bit is used to protect the customer's data c ode. it may be set after the programmer finishes the programming and verifies sequence. once this bit is set to logic 0, both the data flash eprom and config registers can not be accessed again.
w79e825/824/823/822 data sheet publication release date: december 27, 2007 - 115 - revision a8 bit 7 bit 6 function description 1 1 both security of 16kb/8kb/4kb/2kb program code and 256/128 bytes data area are unlocked. they can be erased, prog rammed or read by writer or icp. 0 1 the 16kb/8kb/4kb/2kb program code area is locked. it can?t be read by writer or icp. 1 0 don?t support (invalid). 0 0 both security of 16kb/8kb/4kb/2kb program code and 256/128 bytes data area are locked. they can?t be read by writer or icp.
w79e825/824/823/822 data sheet - 116 - 28 electrical characteristics 28.1 absolute maximum ratings symbol parameter condition rating unit dc power supply vdd ? vss -0.3 +7.0 v input voltage vin vss-0.3 vdd+0.3 v operating temperature ta -40 +85 c storage temperature tst -55 +150 c note: exposure to conditions beyond those listed under absolute maximum ratings may adversely affects the lift and reliability of the device. 28.2 dc electrical characteristics (ta = -40~85 c, unless otherwise specified.) specification parameter symbol min. typ. max. unit test conditions operating voltage v dd 2.7 5.5 v v dd =4.5v ~ 5.5v @ 20mhz v dd =2.7v ~ 5.5v @ 12mhz i dd 18 25 ma no load, /rst = vss,v dd = 5.0v @ 20mhz operating current 6 8 ma no load, /rst = vss, v dd = 3.0v @ 12mhz i idle 11.5 15 ma no load, v dd = 5.5v @ 20mhz idle current 5 6.5 ma no load, v dd = 3.0v @ 12mhz i pwdn 1 10 a no load, v dd = 5.5v @ disable bov function power down current 1 10 ua no load, v dd = 3.0v @ disable bov function input current p0, p1, p2 i in1 -50 - +13 a v dd = 5.5v, 0 w79e825/824/823/822 data sheet publication release date: december 27, 2007 - 117 - revision a8 dc electrical characteristics, continued specification parameter symbol min. typ. max. unit test conditions 0 - 0.8 v v dd = 4.5v input low voltage xtal1 [*2] v il3 0 - 0.4 v v dd = 3.0v 3.5 - v dd +0.2 v v dd = 5.5v input high voltage xtal1 [*2] v ih3 2.4 - v dd +0.2 v v dd = 3.0v v ih1 2.4 - v dd +0.2 v v dd = 5.5v input high voltage p0, p1, p2 (ttl input) 2.0 - v dd +0.2 v v dd = 3.0v negative going threshold (schmitt input) v ils -0.5 - 0.3v dd v positive going threshold (schmitt input) v ihs 0.7v dd - v dd +0.5 v hysteresis voltage v hy 0.2v dd v source current p0, p1, p2 (quasi-bidirectional mode) i sr1 -180 -210 -360 ua v dd = 4.5v, v s = 2.4v sink current p0, p1, p2 (quasi-bidirectional mode) i sk2 13 18.5 24 ma v dd = 4.5v, v s = 0.45v - 0.5 0.9 v v dd = 4.5v, i ol = 20 ma output low voltage p0, p1, p2 (push-pull mode) v ol1 - 0.1 0.4 v v dd = 2.7v, i ol = 3.2 ma 2.4 3.4 - v v dd = 4.5v, i oh = -16ma output high voltage p0, p1, p2 (push-pull mode) v oh 1.9 2.4 - v v dd = 2.7v, i oh = -3.2ma brownout voltage with bov=1 v bo2.5 2.4 - 2.7 v ta = -0 to 70 c brownout voltage with bov=0 v bo3.8 3.5 - 4.0 v ta = -0 to 70 c comparator reference voltage vref 1.02 1.20 1.31 v notes: *1. /rst pin is a schmitt trigger input. *2. xtal1 is a cmos input. *3. pins of p0, p1 and p2 can source a trans ition current when they are being externally driven from 1 to 0. the transition current reaches its maximum value when vin approximates to 2v.
w79e825/824/823/822 data sheet - 118 - 28.3 the adc converter dc electrical characteristics (v dd ? v ss = 3.0~5v, ta = -40~85 c, fosc = 20mhz, unless otherwise specified.) specification parameter symbol min. typ. max. unit test conditions analog input avin v ss -0.2 v dd +0.2 v adc clock adcclk 200kh z 5mhz hz adc circuit input clock conversion time t c 52t adc [1] us differential non-linearity dnl -1 - +1 lsb integral non-linearity inl -2 - +2 lsb offset error ofe -1 - +1 lsb gain error ge -1 - +1 % absolute voltage error ae -3 - +3 lsb notes: 1. tadc: the period time of adc input clock. 28.4 the comparator electrical characteristics (v dd ? v ss = 3.0~5v, ta = -40~85 c, fosc = 20mhz, unless otherwise specified.) specification parameter symbol min. typ. max. unit test conditions common mode range comparator inputs v cr 0 v dd -0.3 v common mode rejection ratio cmrr -50 db response time t rs - 30 100 ns comparator enable to output valid time t en - 1 5 us input leakage current, comparator i il -10 0 10 ua 0< v in w79e825/824/823/822 data sheet publication release date: december 27, 2007 - 119 - revision a8 28.6 external clock characteristics parameter symbol min. typ. max. units notes clock high time t chcx 12.5 - - ns clock low time t clcx 12.5 - - ns clock rise time t clch - - 10 ns clock fall time t chcl - - 10 ns 28.7 ac specification parameter symbol variable clock min. v ariable clock max. units oscillator frequency 1/t clcl 0 20 mhz 28.8 typical application circuits crystal c1 c2 r 4mhz ~ 20 mhz without without without the above table shows the reference values for crystal applications. xtal2 xtal1 w79e825 w79e824 c1 c2 r w79e823 w79e822
w79e825/824/823/822 data sheet - 120 - 29 package dimensions 29.1 20-pin sop l o c e h a1 a e b d seating plane y 0.25 gauge plane e 1 20 11 10 7.60 0.32 0.51 0.30 e c b a1 7.40 0.23 0.33 0.10 0.299 0.013 0.020 0.012 0.291 0.009 0.013 0.004 max. dimension in mm 2.65 a symbol min. 2.35 dimension in inch 0.104 min. 0.093 max. control demensions are in milmeters . 1.27 0.10 10.65 l t y h 08 0.40 10.00 e 1.27 bsc 0.050 0.004 0.419 0 0.016 0.394 8 0.050 bsc e d 12.60 13.00 0.496 0.512 figure 29-1: 20l sop-300mil
w79e825/824/823/822 data sheet publication release date: december 27, 2007 - 121 - revision a8 29.2 20-pin dip 1.63 1.47 0.064 0.058 symbol min nom max max nom min dimension in inch dimension in mm a b c d e a l s a a 1 2 e 0.060 1.52 0.175 4.45 0.010 0.125 0.016 0.130 0.018 0.135 0.022 3.18 0.41 0.25 3.30 0.46 3.43 0.56 0.008 0.120 0.375 0.010 0.130 0.014 0.140 0.20 3.05 0.25 3.30 0.36 3.56 0.255 0.250 0.245 6.48 6.35 6.22 9.53 7.62 7.37 7.87 0.300 0.290 0.310 2.29 2.54 2.79 0.090 0.100 0.110 b 1 1 e e 1 1.026 1.040 20.06 26.42 015 0.075 1.91 0.355 0.335 8.51 9.02 15 0 seating plane a e 2 a c e base plane 1 a 1 e l a s 1 e d 1 b b 20 110 11 figure 29-2: 20l pdip 300mil
w79e825/824/823/822 data sheet - 122 - 29.3 24-pin sop l o c e h a1 a e b d seating plane y 0.25 gauge plane e 1 24 13 12 7.60 0.32 0.51 0.30 e c b a1 7.40 0.23 0.33 0.10 0.299 0.013 0.020 0.012 0.291 0.009 0.013 0.004 max. dimension in mm 2.65 a symbol min. 2.35 dimension in inch 0.104 min. 0.093 max. control demensions are in milmeters . 1.27 0.10 10.65 l t y h 08 0.40 10.00 e 1.27 bsc 0.050 0.004 0.419 0 0.016 0.394 8 0.050 bsc e d 15.20 15.60 0.598 0.614 figure 29-3: 24l sop-300mil
w79e825/824/823/822 data sheet publication release date: december 27, 2007 - 123 - revision a8 30 revision history version date page description a1 mar. 30, 2006 - initial issued a2 june 04, 2006 to add w79e823/822 parts and function description a3 june 19, 2006 4~5 to remove normal package of part number list a4 june 23, 2006 86~92 to revise pwm function of w79e823 and w79e822 to 4 pwm output channel a5 oct. 04, 2006 8 98 112~114 96 89 1. to remove block diagram. 2. to add gc call function description. 3. revise dc characteristics spec. 4. revise timer counter of i2c block diagram. 5. revise ?release brake of pwm? flow chart. a6 mar. 12, 2007 112 61 26 95~98 105 1. added note for icp mode. 2. change sfr name ie1 to eie due to conflict with ie1 bit name in tcon.3. 3. sfr reset value table: added pwmcon3, nvmaddr, nvmdat & nvmcon. rename pwmp1 to pwmph, pwmp0 to pwmpl. 4. port 2 sfr bit p2.0 and p2.1 descriptions reverse order. 5. to revise pwm function of w79e823, w79e822 and w79e821 to 4 pwm output channel. 6. revise timer counter of i2c block diagram. a7 jul. 16, 2007 18 19 30 31 59 63 112 92 101 1. added sfr reg bit p1m1.2, p1m2.2, p1m1.3, p1m2.3. 2. port1 sfr register for bit p0.7~p0.0 description in reverse order. 3. removed port1 output mode reg bit p1m1.5, p1m2.5 4. revised reg bit enclk description 5. changed the ?external reset pin has to be held low for at least two machine cycles?.(not held high) 6. changed the ?all the bits that generate interrupts can be set or reset by software?. (not by hardware) 7. revised figure 26-1: application circuit of icp 8. revised figure 21-1: oscillator 9. revised figure 24-2: the adc block diagram a8 dec. 27, 2007 26 revise the content of uart mode select table. (sm0, sm1) is exchanged.
w79e825/824/823/822 data sheet - 124 - important notice winbond products are not designed, intended, authorized or warranted for use as components in systems or equipment intended for surg ical implantation, atomic energy control instruments, airplane or spaceship instruments, transportation instruments, traffic signal instruments, combustion control instruments, or for other applications intended to support or sustain life. further more, winbond products are not intended for applications wherein failure of winbond products could result or lead to a situation wherein personal injury, death or severe property or environmental damage could occur. winbond customers using or selling these products for use in such applications do so at their own risk and agree to fully indemnify winbond for any damages resulting from such improper use or sales.


▲Up To Search▲   

 
Price & Availability of W79E825ADG

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]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X