![]() |
|
If you can't view the Datasheet, Please click here to try to view without PDF Reader . |
|
Datasheet File OCR Text: |
toshiba original cmos 16-bit microcontroller tlcs-900/l1 series tmp91c829 semiconductor company
preface thank you very much for making us e of toshiba microcomputer lsis. before use this lsi, refer the section, ?points of note and restrictions?. especially, take care below cautions. ** caution ** how to release the halt mode usually, interrupts can release all halts status. however, the interrupts = ( nmi , int0 to int4), which can release the ha lt mode may not be able to do so if they are input during the period cpu is shifting to the halt mode (for about 5 clocks of f fph ) with idle1 or stop mode (idle2 is not applicable to this case). (in this case, an interrupt request is kept on hold internally.) if another interrupt is generated after it has shifted to halt mode completely, halt status can be released without difficultly. the priority of this interrupt is compare with that of the interrupt kept on hold internally, and the interrupt with higher priority is handled first fo llowed by the other interrupt. tmp91c829 91c829-1 2006-03-15 cmos 16-bit microcontroller TMP91C829FG 1. outline and features tmp91c829 is a high-speed 16-bit microcontroller designed for the control of various mid- to large-scale equipment.with 2 kbytes of boot rom included, it allows your programs to be erased and rewritten on board. TMP91C829FG comes in a 100-pin flat package. listed below are the features. (1) high-speed 16-bit cpu (900/l1 cpu) ? instruction mnemonics are upward compatible with tlcs-90/900 ? 16 mbytes of linear address space ? general-purpose registers and register banks ? 16-bit multiplication and division instructions; bit transfer and arithmetic instructions ? micro dma: 4 channels (444 ns/2 bytes at 36 mhz) (2) minimum instruction execution time: 111 ns (at 36 mhz) (3) built-in ram: 8 kbytes built-in rom: none built-in boot rom: 2 kbytes tmp91c829 91c829-2 2006-03-15 (4) external memory expansion ? expandable up to 16 mbytes (shared program/data area) ? can simultaneously support 8-/16-bit width external data bus ? dynamic data bus sizing (5) 8-bit timers: 6 channels (6) 16-bit timer/event counter: 1 channel (7) serial bus interface: 2 channels (8) 10-bit ad converter: 8 channels (9) watchdog timer (10) chip select/wait controller: 4 blocks (11) interrupts: 35 interrupts ? 9 cpu interrupts: software interrupt instruction and illegal instruction ? 19 internal interrupts: 7 priority levels are selectable ? 7 external interrupts: 7 priority levels are selectable (level mode, rising edge mode and falling edge mode are selectable.) (12) input/output ports: 46 pins (except data bus (8bit), address bus (16bit) and rd pin) (13) standby function three halt modes: idle2 (programmable), idle1, stop (14) operating voltage ? vcc (5 v) = 4.75 v to 5.25 v (fc max = 36 mhz) ? vcc (3 v) = 3.0 v to 3.6 v (fc max = 36 mhz) (15) package ? 100-pin qfp: p-lqfp100-1414-0.50f power on and power off the supply power on and power off of the supply require the simu ltaneous execution of the 5 v power supply and 3.3 v power supply. if the both power supplies cannot be turned on or off simultaneously, turn on or off each power supply within the specifications shown in figure 3. 1.2 and 3.1.2 ?power on and power off of the supply?. when power on and power off of the supply is performed on eigher of them, overlap current may run into the internal logic. leaving overlap current running results in increase of power dissipation and short lsi life. please avoid leaving either of power supplies on. tmp91c829 91c829-3 2006-03-15 ( ): initial function after reset figure 1.1 tmp91c829 block diagram adtrg (an3/pa3) an0 to an7 (pa0 to pa7) vrefh vrefl avcc avss rd wr pz2 ( hwr ) pz3 txd0 (p80) rxd0 (p81) sclk0/ cts0 (p82) 0sts (p83) txd1 (p84) rxd1 (p85) sck1/ 1cts (p86) 1sts (p87) ta0in/int1 (p70) ta1out (p71) ta3out/int2 (p72) ta4in/int3 (p73) ta5out (p74) int4 (p75) lvcc 3v hvcc 5v vss boot a m0/am1 reset x1 x2 emu0 emu1 (p10 to p17) d8 to d15 (p20 to p27) a16 to a23 d0 to d7 a 0 to a7 a 8 to a15 busrq (p53) busak (p54) wait (p55) cs0 (p60) cs1 (p61) cs2 (p62) 3cs (p63) nmi int0 (p56) tb0in0 (p93) tb0in1 (p94) tb0out0 (p95) tb0out1 (p96) int5 (p90) 10-bit 8-ch ad converter port a 8-bit timer (timer 0) port z 8-bit timer (timer 1) 8-bit timer (timer 2) 8-bit timer (timer 3) serial i/o (channel 0) osc clock gear port 1 cs/wait controller (4 blocks) address bus interrupt controller 16-bit timer (tmrb0) data bus port 9 8-kbyte ram watchdog timer (wdt) xwa xbc xde xhl xix xiy xiz xsp w a b c d e h l ix iy iz sp 32 bits sr pc f f cpu ( tlcs-900l1 ) port 2 2-kbyte boot rom port 5 serial i/o (channel 1) port 8 8-bit timer (timer 4) 8-bit timer (timer 5) port 7 tmp91c829 91c829-4 2006-03-15 2. pin assignment and pin functions the assignment of input/output pins for the TMP91C829FG, their names and functions are as follows: 2.1 pin assignment diagram figure 2.1.1 shows the pin assignment of the TMP91C829FG. pin pin no. pin name pin name no. 63 hvcc (5 v) p27/a23 64 62 boot p26/a22 65 61 vss p25/a21 66 60 p17/d15 p24/a20 67 59 p16/d14 p23/a19 68 58 p15/d13 p22/a18 69 57 p14/d12 p21/a17 70 56 p13/d11 p20/a16 71 55 p12/d10 a15 72 54 p11/d9 a14 73 53 p10/d8 a13 74 52 d7 a12 75 51 d6 a11 76 50 d5 a10 77 49 d4 a9 78 48 d3 a8 79 47 d2 a7 80 46 d1 a6 81 45 d0 a5 82 44 p96/tb0out1 a4 83 43 p95/tb0out0 a3 84 42 p94/tb0in1 a2 85 41 p93/tb0in0 a1 86 40 p90/int5 a0 87 39 p75/int4 rd 88 38 p74/ta5out wr 89 37 p73/ta4in/int3 lvcc (3 v) 90 36 p72/ta3out/int2 pz2/ hwr 91 35 p71/ta1out vss 92 34 p70/ta0in/int1 pa0/an0 93 33 reset pa1/an1 94 32 am1 pa2/an2 95 31 x1 adtrg / pa3/an3 96 30 dvss pa4/an4 97 29 x2 pa5/an5 98 28 lvcc (oscillator) pa6/an6 99 27 am0 pa7/an7 100 26 p63/ cs3 vrefh 1 25 p62/ cs2 vrefl 2 24 p61/ cs1 avss 3 23 p60/ cs0 avcc 4 22 emu1 nmi 5 21 emu0 vss 6 20 p87/ sts1 p53/ busrq 7 19 p86/sclk0/ cts1 hvcc (5 v) 8 18 p85/rxd1 p54/ busak 9 17 p84/txd1 p55/ wait 10 16 p83/ sts0 p56/int0 11 15 p82/sclk0/ cts0 pz3 12 14 p81/rxd0 p80/txd0 13 figure 2.1.1 pin assignment diagram (100-pin lqfp) 75 74 73 72 71 70 69 68 67 66 65 64 63 62 61 60 59 58 57 56 55 54 53 52 51 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 p-lqfp100-1414-0.50f TMP91C829FG top view tmp91c829 91c829-5 2006-03-15 2.2 pin names and functions the names of the input/output pins and their functions are described below. table 2.2.1 pin names and functions (1/3) pin name number of pins i/o functions d0 to d7 8 i/o data (lower): bits 0 to 7 of data bus p10 to p17 d8 to d15 8 i/o i/o port 1: i/o port that allows i/o to be selected at the bit level (when used to the external 8-bit bus) data (upper): bits 8 to15 of data bus p20 to p27 a16 to a23 8 output output port 2: output port address: bits 16 to 23 of address bus a8 to a15 8 output address: bits 8 to 15 of address bus a0 to a7 8 output address: bits 0 to 7 of address bus rd 1 output read: strobe signal for reading external memory wr 1 output write: strobe signal for writing data to pins d0 to d7 p53 busrq 1 i/o input port 53: i/o port (with pull-up resistor) bus request: signal used to reques t bus release (high impedance) p54 busak 1 i/o output port 54: i/o port (with pull-up resistor) bus acknowledge: signal used to acknowledge bus release (high impedance) p55 wait 1 i/o input port 55: i/o port (with pull-up resistor) wait: pin used to request cpu bus wait. p56 int0 1 i/o input port 56: i/o port (with pull-up resistor) interrupt request pin0: interrupt reques t pin with programmable level/rising edge/falling edge p60 cs0 1 output output port 60: output port chip select 0: outputs 0 when address is within specified address area p61 cs1 1 output output port 61: output port chip select 1: outputs 0 when address is within specified address area p62 cs2 1 output output port 62: output port chip select 2: outputs 0 when address is within specified address area p63 3cs 1 output output port 63: output port chip select 3: outputs 0 when address is within specified address area p70 ta0in int1 1 i/o input input port 70: i/o port timer a0 input interrupt request pin2: interrupt reques t pin with programmable level/rising edge/falling edge p71 ta1out 1 i/o output port 71: i/o port timer a0 or timer a1 output p72 ta3out int2 1 i/o output input port 72: i/o port timer a2 or timer a3 output interrupt request pin2: interrupt reques t pin with programmable level/rising edge/falling edge tmp91c829 91c829-6 2006-03-15 table 2.2.2 pin names and functions (2/3) pin name number of pins i/o functions p73 ta4in int3 1 i/o input input port 73: i/o port timer a4 input interrupt request pin 3: interrupt reques t pin with programmable level/rising edge/falling edge p74 ta5out 1 i/o output port 74: i/o port timer a4 or timer a5 output p75 int4 1 i/o input port 75: i/o port interrupt request pin 4: interrupt request pin with programmable p80 txd0 1 i/o output port 80: i/o port (with pull-up resistor) serial send data 0: programmable open-drain output pin p81 rxd0 1 i/o input port 81: i/o port (with pull-up resistor) serial receive data 0 p82 sclk0 cts0 1 i/o input i/o port 82: i/o port: (with pull-up resistor) serial clock i/o 0 serial data send enable 0 (clear to send) p83 0sts 1 i/o port 83: i/o port (with pull-up resistor) serial data request signal 0 p84 txd1 1 i/o output port 84: i/o port (with pull-up resistor) serial send data 0: programmable open-drain output pin p85 rxd1 1 i/o input port 85: i/o port (with pull-up resistor) serial receive data 1 p86 sclk1 cts1 1 i/o input i/o port 86: i/o port: (with pull-up resistor) serial clock i/o 1 serial data send enable 1 (clear to send) p87 1sts 1 i/o port 87: i/o port (with pull-up resistor) serial data request signal 1 p90 int5 1 i/o input port 90: i/o port interrupt request pin 5: interrupt reques t pin with programmable level/rising edge/falling edge p93 tb0in0 1 i/o input port 93: i/o port timer b0 input 0 p94 tb0in1 1 i/o input port 94: i/o port timer b0 input 1 p95 tb0out0 1 i/o output port 95: i/o port timer b0 output 0 p96 tb0out1 1 i/o output port 96: i/o port timer b0 output 1 pa0 to pa7 an0 to an7 adtrg 8 input input input port a0 to a7: pin used to input port analog input 0 to 7: pins us ed to input to ad converter a/d trigger: signal used to request ad start (pa3) pz2 hwr 1 i/o output port z2: i/o port (with pull-up resistor) high write: strobe signal for writing data to pins d8 to d15 pz3 1 i/o port z3: i/o port (with pull-up resistor) tmp91c829 91c829-7 2006-03-15 table 2.2.3 pin names and functions (3/3) pin name number of pins i/o functions boot 1 input this pin sets boot mode (with pull-up resistor) nmi 1 input non-maskable interrupt request pin: interrupt request pin with programmable falling edge level or with both edge levels programmable am0 to am1 2 input address mode : external data bus with select pin when external 16-bit bus is fixed or ex ternal 8- or 16-bit buses are mixed, am1 = 0 , am0 = 1 when external 8-bit bus is fixed, am1 = 0 , am0 = 0 reset 1 input reset: initializes tmp91c829 (with pull-up resistor) vrefh 1 input pin for reference voltage input to ad converter (h) vrefl 1 input pin for reference voltage input to ad converter (l) avcc 1 i/o power supply pin for ad converter avss 1 gnd supply pin for ad converter x1/x2 2 oscillator connection pins hvcc 2 power supply pins (5 v) lvcc 2 power supply pins (3 v) dvss 3 gnd pins (0 v) emu0 1 output open pin emu1 1 output open pin note 1: an external dma controller cannot access t he device?s built-in memory or built-in i/o devices using the busrq and busak signal. note 2: all pins which have a built-in pull-up resistor (other than the reset pin and the boot pin ) can be disconnected from the resistor in software. tmp91c829 2006-03-15 91c829-8 3. operation this section describes the bas ic components, functions and operation of the tmp91c829. notes and restrictions which apply to the various items described here are outlined in section 7. ?points to note and restrictions? at the end of this databook. 3.1 cpu the tmp91c829 incorporates a high-perform ance 16-bit cpu (the 900/l1 cpu). for a description of this cpu?s operatio n, please refer to the section of this databook which describes the tlcs-900/l1 cpu. the following sub sections des cribe functions peculiar to the cpu used in the tmp91c829; these functions are not covered in the section devoted to the tlcs-900/l1 cpu. 3.1.1 reset when resetting the tmp91c829 microcontroller, ensure that the power supply voltage is within the operating voltage range, and that the internal high-frequency oscillator has stabilized. then set the reset input to low level at least for 10 system clocks (8.89 s at 36 mhz). thus, when turn on the switch, be set to the power supply voltage is within the operating voltage range, and that the internal high-frequency oscillator has stabilized. then hold the reset input to low-level at least for 10 system clocks. clock gear is intitialized 1/16 mode by reset operation. it means that the system clock mode f sys is set to fc/32 ( = fc/16 1/2). when the reset is accept, the cpu: ? sets the program counter (pc) as follows in accordance with the reset vector stored at address ffff00h to ffff02h: pc<0:7> data in location ffff00h pc<8:15> data in location ffff01h pc<16:23> data in location ffff02h ? sets the stack pointer (xsp) to 100h. ? sets bits tmp91c829 2006-03-15 91c829-9 read write f fph a23 to a0 data-in d0 to d15 d0 to d15 sampling (after reset released, starting 2 waits read cycle) pull up (internal) high-z sampling 0ffff00h data-in d ata-in cs0 , cs1 , cs3 (pz2 input mode) reset cs2 rd w r hw r figure 3.1.1 tmp91c829 reset timing example tmp91c829 2006-03-15 91c829-10 3.1.2 power on and power off of the supply figure 3.1.2 power supply on/off timing 3.2 outline of operation modes there are multi chip and multi boot modes. which mode is selected depends on the device?s pin state after a reset. ? multi chip mode: the device normally operations in this mode. after a reset, the device starts executing the external memory program. ? multi boot mode: this mode is used to rewrite the external flash memory by serial transfer (uart) or atapi transfer. after a reset, internal boot program starts up, executing a on-board rewrite program. table 3.2.1 operation mode setup table mode setup input pin operation mode reset boot multi chip mode h multi boot mode l vcc 5 vcc 3.3 max 1 [s] min 10 [ms] min 0 [s] max 1 [s] reset oscillator operation time + clock doubler stabilization time tmp91c829 2006-03-15 91c829-11 3.3 memory map figure 3.3.1 is a memory map of the tmp91c829. multi chip mode multi boot mode 000000h 000100h internal i/o (4 kbytes) 000000h 000100h internal i/o (4 kbytes) direct area (n) 001000h internal ram (8 kbytes) 001000h internal ram (8 kbytes) 003000h external memory 003000h 01f800h 16-mbyte area 01ffffh internal boot rom (2 kbytes) (r32) ( ? r32) external memory external memory (r32 + ) (r32 + d8/16) (r32 + r8/16) (nnn) fff800h fffeffh internal boot rom (2 kbytes) ffff00h ffffffh vector table (256 bytes) ffff00h ffffffh vector table (256 bytes) ( = internal area) figure 3.3.1 tmp91c829 memory map tmp91c829 2006-03-15 91c829-12 3.4 triple clock function and standby function the tmp91c829 contains (1) a clock gearing system, (2) a standby controller, and (3) a noise-reducing circuit. it is used for low-power, lo w-noise systems. the clock operating mode is as follows: (a) single clock mode (x1, x2 pins only). figure 3.4.1 shows a transition figure. reset (f osch /32) release reset instruction interrupt stop mode (stops all circuits) normal mode (f osch /gear value/2) idle2 mode (i/o operate) idle1 mode (operate only oscillator) clock mode transition figure instruction instruction interrupt interrupt figure 3.4.1 system clock block diagram the clock frequency input from the x1 and x2 pins is called fc. in case of tmp91c829, fc = f fph . the system clock f sys is defined as the divided clock of f fph , and one cycle of f sys is regarded as one state. tmp91c829 2006-03-15 91c829-13 3.4.1 block diagram of system clock f osch fc/8 f fph clock gear tmra01 to tmra45 syscr0 tmp91c829 2006-03-15 91c829-14 3.4.2 sfrs 7 6 5 4 3 2 1 0 bit symbol ? ? ? ? ? wuef prck1 prck0 syscr0 (00e0h) read/write r/w after reset 1 0 1 0 0 0 0 0 function always write ?1?. always write ?0?. always write ?1?. always write ?0?. always write ?0?. warm-up timer write 0: don?t care write 1: start timer read 0: end warm-up read 1: do not end warm-up select prescaler clock 00: f fph 01: reserved 10: fc/16 11: reserved 7 6 5 4 3 2 1 0 bit symbol ? gear2 gear1 gear0 syscr1 (00e1h) read/write r/w after reset 0 0 0 0 function always write ?0?. select gear value of high frequency (fc) 000: fc 001: fc/2 010: fc/4 011: fc/8 100: fc/16 101: (reserved) 110: (reserved) 111: (reserved) 7 6 5 4 3 2 1 0 bit symbol ? wuptm1 wuptm0 haltm1 haltm0 drve syscr2 (00e2h) read/write r/w r/w r/w r/w r/w r/w after reset 0 1 0 1 1 0 function always write ?0?. warm-up timer 00: reserved 01: 2 8 inputted frequency 10: 2 14 inputted frequency 11: 2 16 inputted frequency halt mode 00: reserved 01: stop mode 10: idle1 mode 11: idle2 mode 1: drive the pin during stop mode figure 3.4.3 sfr for system clock tmp91c829 2006-03-15 91c829-15 7 6 5 4 3 2 1 0 bit symbol protect ? ? ? ? extin ? ? emccr0 (00e3h) read/write r r/w r/w r/w r/w r/w r/w r/w after reset 0 0 1 0 0 0 1 1 function protect flag 0: off 1: on always write ?0?. always write ?1?. always write ?0?. always write ?0?. 1: external clock always write ?1?. always write ?1?. bit symbol read/write after reset emccr1 (00e4h) function writing 1fh turns protections off. writing any value other than 1fh turns protection on. figure 3.4.4 sfr for noise reducing tmp91c829 2006-03-15 91c829-16 3.4.3 system clock controller the system clock controller gene rates the system clock signal (f sys ) for the cpu core and internal i/o. it contains a clock gear circuit for high-frequency (fc) operation. the register syscr1 tmp91c829 2006-03-15 91c829-17 3.4.4 prescaler clock controller for the internal i/o (tmra01:45, tmrb0 and sio0, sio1), there is a prescaler which can divide the clock. the t clock input to the prescaler is either the clock f fph divided by 2 or the clock fc/16 divided by 2. the setting of the syscr0 tmp91c829 2006-03-15 91c829-18 (2) protection of register contents (purpose) an item for mistake operation by inputted noise. to execute the program certainty which is occurred mistake operation, the protect-register can be disabled write operation for the specific sfr. write disabled sfrs 1. cs/wait controller b0cs, b1cs, b2cs, b3cs, bexcs, msar0, msar1, msar2, msar3, mamr0, mamr1, mamr2, mamr3 2. clock gear (only emccr1 can be written to.) syscr0, syscr1, syscr2, emccr0 (block diagram) protect register emccr0 tmp91c829 2006-03-15 91c829-19 3.4.6 standby controller (1) halt modes when the halt instruction is executed, the operating mode switches to idle2, idle1 or stop mode, depending on the contents of the syscr2 tmp91c829 2006-03-15 91c829-20 (2) how to clear a halt mode the halt state can be cleared by a reset or by an interrupt request. the combination of the value in tmp91c829 2006-03-15 91c829-21 table 3.4.3 source of halt state cl earance and halt clearance operation status of received interrupt interrupt enabled (interrupt level) (interrupt mask) interrupt disabled (interrupt level) < (interrupt mask) halt mode idle2 idle1 stop idle2 idle1 stop interrupt nmi intwdt int0 to int4 (note) int5 intta0 to intta5 inttb00, inttb01, inttbof0 intrx0, inttx0 intrx1, inttx1 intad ? ? ? ? ? ? ? ? ? ? ? ? * 1 ? * 1 ? ? ? ? ? ? * 1 source of halt state clearance reset reset initializes the lsi ? : after clearing the halt mode, cpu starts interrupt processing. : after clearing the halt mode, cpu resumes execut ing starting from instruction following the halt instruction. : cannot be used to clear the halt mode. ? : the priority level (interrupt request level) of non- maskable interrupts is fixed to 7, the highest priority level. there is not this combination type. * 1: the halt mode is cleared when the warm-up time has elapsed. note: when the halt mode is cleared by int0 to int4 interrupt of the level mode in the interrupt enabled status, hold the level until starting interrupt processi ng. changing level before holding level, interrupt processing is correctly started. (example: clearing idle1 mode) an int0 interrupt clears the halt stat e when the device is in idle1 mode. address 8200h ld (p5fc), 40h ; sets p56 to int0 8203h ld (iimc0), 00h ; sets int0 interrupt rising edge. 8206h ld (inte0ad), 06h ; sets int0 interrupt level to 6. 8209h ei 5 ; sets interrupt level to 5 for cpu. 820bh ld (syscr2), 28h ; sets halt mode to idle1 mode. 820eh halt ; halts cpu. int0 interrupt routine int0 reti 820fh ld xx, xx tmp91c829 2006-03-15 91c829-22 (3) operation a. idle2 mode in idle2 mode only specific internal i/o operations, as designated by the idle2 setting register, can take place. instruction execution by the cpu stops. figure 3.4.5 illustrates an example of the timing for clearance of the idle2 mode halt state by an interrupt. x1 a0 to a23 rd wr d0 to d15 data data idle2 mode clearing interrup t figure 3.4.5 timing chart for idle2 mo de halt state cleared by interrupt b. idle1 mode in idle1 mode, only the internal oscillator and the rtc continue to operate. the system clock in the mcu stops. in the halt state, the interrupt request is sampled asynchronously with the system clock; however, clearance of the halt state (e.g., restart of operation) is synchronous with it. figure 3.4.6 illustrates the timing for clearance of the idle1 mode halt state by an int errupt. x1 a0 to a23 rd wr clearing interrup t idle1 mode d0 to d15 data data figure 3.4.6 timing chart for idle1 mo de halt state cleared by interrupt tmp91c829 2006-03-15 91c829-23 c. stop mode when stop mode is selected, all internal circuits stop, including the internal oscillator pin status in stop mode depends on the settings in the syscr2 tmp91c829 2006-03-15 91c829-24 table 3.4.5 input buffer state table input buffer state in halt mode (stop) when the cpu is operating in halt mode (idle2/idle1) tmp91c829 2006-03-15 91c829-25 table 3.4.6 output buffer state table output buffer state in halt mode (stop) when the cpu is operating in halt mode (idle2/idle1) tmp91c829 2006-03-15 91c829-26 3.5 interrupts interrupts are controlled by the cpu interrupt mask register sr tmp91c829 2006-03-15 91c829-27 count = 0 general-purpose interrupt processing interrupt specified by micro dma start vector? yes interrupt processing push pc push sr sr tmp91c829 2006-03-15 91c829-28 3.5.1 general-purpose interrupt processing when the cpu accepts an interrupt, it usually performs the following sequence of operations. that is also the same as tlcs-900/l and tlcs-900/h. (1) the cpu reads the interrupt vector from the interrupt controller. if the same level interrupts occur simultaneo usly, the interrupt controller generates an interrupt vector in accordance with the default priority and clears the interrupt request. (the default priority is alre ady fixed for each interrupt: the smaller vector value has the higher priority level.) (2) the cpu pushes the value of program counter (pc) and status register (sr) onto the stack area (indicated by xsp). (3) the cpu sets the value which is the priority level of the accepted interrupt plus 1 ( + 1) to the interrupt mask register tmp91c829 2006-03-15 91c829-29 table 3.5.1 tmp91c829 interrupt ve ctors and micro dma start vectors default priority type interrupt source or source of micro dma request vector value vector reference address micro dma start vector 1 reset or ?swi0? instruction 0000h ffff00h ? 2 ?swi1? instruction 0004h ffff04h ? 3 illegal instruction or ?swi2? instruction 0008h ffff08h ? 4 ?swi3? instruction 000ch ffff0ch ? 5 ?swi4? instruction 0010h ffff10h ? 6 ?swi5? instruction 0014h ffff14h ? 7 ?swi6? instruction 0018h ffff18h ? 8 ?swi7? instruction 001ch ffff1ch ? 9 nmi : nmi pin input 0020h ffff20h ? 10 non-mask able intwd: watchdog timer 0024h ffff24h ? ? micro dma ? ? ? 11 int0: int0 pin input 0028h ffff28h 0ah 12 int1: int1 pin input 002ch ffff2ch 0bh 13 int2: int2 pin input 0030h ffff30h 0ch 14 int3: int3 pin input 0034h ffff34h 0dh 15 int4: int4 pin input 0038h ffff38h 0eh 16 int5: int5 pin input 003ch ffff3ch 0fh 17 (reserved) 0040h ffff40h 10h 18 (reserved) 0044h ffff44h 11h 19 (reserved) 0048h ffff48f 12h 20 intta0: 8-bit timer 0 004ch ffff4ch 13h 21 intta1: 8-bit timer 1 0050h ffff50h 14h 22 intta2: 8-bit timer 2 0054h ffff54h 15h 23 intta3: 8-bit timer 3 0058h ffff58h 16h 24 intta4: 8-bit timer 4 005ch ffff5ch 17h 25 intta5: 8-bit timer 5 0060h ffff60h 18h 26 (reserved) 0064h ffff64h 19h 27 (reserved) 0068h ffff68h 1ah 28 inttb00: 16-bit timer 0 (tb0rg0) 006ch ffff6ch 1bh 29 inttb01: 16-bit timer 0 (tb0rg1) 0070h ffff70h 1ch 30 (reserved) 0074h ffff74h 1dh 31 (reserved) 0078h ffff78h 1eh 32 inttbof0: 16-bit timer 0 (overflow) 007ch ffff7ch 1fh 33 (reserved) 0080h ffff80h 20h 34 intrx0: serial receive (channel 0) 0084h ffff84h 21h 35 inttx0: serial transmission (channel 0) 0088h ffff88h 22h 36 intrx1: serial receive (channel 1) 008ch ffff8ch 23h 37 inttx1: serial transmission (channel 1) 0090h ffff90h 24h 38 (reserved) 0094h ffff94h 25h 39 (reserved) 0098h ffff98h 26h 40 intad: ad conversion end 009ch ffff9ch 27h 41 inttc0: micro dma end (channel 0) 00a0h ffffa0h 28h 42 inttc1: micro dma end (channel 1) 00a4h ffffa4h 29h 43 inttc2: micro dma end (channel 2) 00a8h ffffa8h 2ah 44 inttc3: micro dma end (channel 3) 00ach ffffach 2bh ? to ? maskable (reserved) 00b0h to 00fch ffffb0h to fffffch ? to ? tmp91c829 2006-03-15 91c829-30 3.5.2 micro dma processing in addition to general-purpose interrupt processing, the tmp91c829 supprots a micro dma function. interrupt requests set by micro dma perform micro dma processing at the highest priority level (level 6) among maskable interrupts, regardless of the priority level of the particular interrupt source. the micro dma has 4 channels and is possible continuous transmission by spec ifing the say later burst mode. because the micro dma function has been implemented with the cooperative operation of cpu, when cpu goes to a standby mode by halt instruction, the requirement of micro dma will be ignored (pending). (1) micro dma operation when an interrupt request specified by the micro dma start vector register is generated, the micro dma triggers a micro dma request to the cpu at interrupt priority level 6 and starts processing the requ est in spite of any interrupt source?s level. the micro dma is ignored on tmp91c829 2006-03-15 91c829-31 if a micro dma request is set for more than one channel at the same time, the priority is not based on the interrupt priority level but on the channel number. the smaller channel number has the higher priori ty (channel 0 (high) > channel 3 (low)). while the register for setting the transfer source/transfer destin ation addresses is a 32-bit control register, this register can only effectively output 24-bit addresses. accordingly, micro dma can access 16 mbytes (the upper eight bits of the 32 bits are not valid). three micro dma transfer modes are support ed: 1-byte transfer, 2-byte (one word) transfer, and 4-byte transfer. after a transfer in any mode, the transfer source/transfer destination addresses are increased, decreased, or remain unchanged. this simplifies the transfer of data from i/o to memory, from memory to i/o. for details of the transfer modes, see (4) ?detailed description of the transfer mode register?. as the transfer counter is a 16-bit counter, micro dma pr ocessing can be set for up to 65536 times per interrupt source. (the micro dma processing count is maximized when the transfer counter initial value is set to 0000h.) micro dma processing can be started by the 23 interrupts shown in the micro dma start vectors of figure 3.5.1 and by the micro dma soft start, making a total of 24 int errupts. figure 3.5.2 shows the word transfer mi cro dma cyc le in transfer destination address inc mode (except for counter mode, the same as for other modes). (the conditions for this cycle are based on an external 16-bit bus, 0 waits, transfer source/transfer destination addresses both even numbered values.) output input transfer destination address 1 state d0 to d15 x1 a0 to a23 dm1 dm2 dm3 dm4 dm5 dm6 dm7 dm8 (note 1) (note 2) rd wr / hwr transfer source address figure 3.5.2 timing for micro dma cycle states 1 to 3: instruction fetch cycle (gets next address code). if 3 bytes and more instruction codes are inserted in the instruction queue buffer, this cycle becomes a dummy cycle. states 4 to 5: micro dma read cycle. state 6: dummy cycle (the address bus remains unchanged from state 5.) states 7 to 8: micro dma write cycle. note 1: if the source address area is an 8- bit bus, it is increased by 2 states. if the source address area is a 16-bit bus and the address starts from an odd number, it is increased by 2 states. note 2: if the destination address area is an 8-bit bus, it is increased by 2 states. if the destination address area is a 16-bit bus and the address starts from an odd number, it is increased by 2 states. tmp91c829 2006-03-15 91c829-32 (2) soft start function in addition to starting the micro dma function by interrupts, tmp91c829 includes a micro dma software start function that st arts micro dma on the generation of the write cycle to the dmar register. writing 1 to each bit of dmar register causes micro dma once (if write 0 to each bitm micro dma doesn?t operate). at the end of transfer, the corresponding bit of the dmar register is automatically cleared to 0. only one-channel can be set for micro dma at once. (do not write 1 to plural bits.) when writing again 1 to the dmar register, check whether the bit is 0 before writing 1. if read 1, micro dma transfer isn?t started yet. when a burst is specified by dmab register, data is continuously transferred until the value in the micro dma transfer counter is 0 after start up of the micro dma transfer counter doesn?t change. don?t use read-modify ?write instruction to avoid writing to other bits by mistake. symbol name address 7 6 5 4 3 2 1 0 dmar3 dmar2 dmar1 dmar0 r / w 0 0 0 0 dmar dma request register 89h (prohibit rmw) dma request (3) transfer control registers the transfer source address and the tran sfer destination address are set in the following registers. data setting for these registers is done by an ?ldc cr,r? instruction. channel 0 dmas0 dma source address register 0: only use lsb 24 bits. dmad0 dma destination address register 0: only use lsb 24 bits. dmac0 dma counter register 0: 1 to 65536. dmam0 dma mode register 0. channel 3 dmas3 dma source address register 3. dmad3 dma destination address register 3. dmac3 dma counter register 3. dmam3 dma mode register 3. 8 bits 16 bits 32 bits tmp91c829 2006-03-15 91c829-33 (4) detailed description of the transfer mode register 8 bits 0 0 0 mode number of transfer bytes mode description number of execution states minimum execution time at fc = 36 mhz 000 (fixed) 000 00 byte transfer 8 states 444 ns 01 word transfer 10 4-byte transfer transfer destination address inc mode .............. i/o to memory (dmadn + ) (dmasn) dmacn dmacn ? 1 if dmacn = 0, then inttcn is generated. 12 states 667 ns 001 00 byte transfer 8 states 444 ns 01 word transfer 10 4-byte transfer transfer destination address dec mode .............. i/o to memory (dmadn ? ) (dmasn) dmacn dmacn ? 1 if dmacn = 0, then inttcn is generated. 12 states 667 ns 010 00 byte transfer 8 states 444ns 01 word transfer 10 4-byte transfer transfer source address inc mode .............. memory to i/o (dmadn) (dmasn + ) dmacn dmacn ? 1 if dmacn = 0, then inttcn is generated. 12 states 667 ns 011 00 byte transfer 8 states 444ns 01 word transfer 10 4-byte transfer transfer source address dec mode .............. memory to i/o (dmadn) (dmasn ? ) dmacn dmacn ? 1 if dmacn = 0, then inttcn is generated. 12 states 667 ns 100 00 byte transfer 8 states 444 ns 01 word transfer 10 4-byte transfer fixed address mode .............. i/o to i/o (dmadn) (dmasn ? ) dmacn dmacn ? 1 if dmacn = 0, then inttcn is generated. 12 states 667 ns 101 00 counter mode ............. for c ounting number of times interrupt is generated. dmasn dmasn + 1 dmacn dmacn ? 1 if dmacn = 0, then inttcn is generated. 5 states 278 ns note: when setting a value in this register, write 0 to the upper 3 bits. dmam0 to dmam3 note 1: ?n? is the corresponding micro dma channels 0 to 3. dmadn + /dmasn + : post-increment (increment register value after transfer) dmadn ? /dmasn ? : post-decrement (decrement register value after transfer) the i/os in the table mean fixed address and t he memory means increment (inc) or decrement (dec) addresses. note 2: execution time is under the condition of: 16-bit bus width (both translation and destination address area)/0 waits/ fc = 36 mhz/selected high-frequency mode (fc 1) note 3: do not use an undefined code for the transfer mode register except for the defined codes listed in the above table. tmp91c829 2006-03-15 91c829-34 3.5.3 interrupt controller operation the block diagram in figure 3.5.3 shows the interrupt circuits. the left-hand side of the diagram shows the int errupt controller ci rcuit. the right-hand side shows the cpu interrupt request signal circuit and the halt release circuit. for each of the 26 interrupt channels there is an interrupt request flag (consisting of a flip-flop), an interrupt priority setting register and a micro dma start vector register. the interrupt request flag latches interrupt requests from the peripherals. the flag is cleared to zero in the following cases: ? when reset occurs ? when the cpu reads the channel vector after accepted its interrupt ? when executing an instruction that clears the interrupt (write micro dma start vector to intclr register) ? when the cpu receives a micro dma request (when micro dma is set) ? when the micro dma burst transfer is terminated an interrupt priority can be set independently for each interrupt source by writing the priority to the interrupt priority setting re gister (e.g., inte0ad or inte12). 6 interrupt priorities levels (1 to 6) are provided. setting an interrupt source?s priority level to 0 (or 7) disables interrupt requests from that source. the priority of non-maskable interrupts (nmi pin interrupts and watchdog timer interrupts) are fixed at 7. if interrupt request with the same level are generated at the same time, th e default priority (the interrupt with the lowest priority or, in other words, the interrupt with the lowest vector value) is used to determine which interrupt request is accepted first. the 3rd and 7th bits of the interrupt priority setting register indicate the state of the interrupt request flag and thus whether an interrupt request for a given channel has occurred. the interrupt controller sends the interrupt request with the highest priority among the simulateous interrupts and its vector address to the cpu. the cpu compares the priority value tmp91c829 2006-03-15 91c829-35 interrupt request signal to cpu if iff = 7 then 0 micro dma start vector setting register intad inttc0 inttc1 inttc2 inttc3 v = 9ch v = a0h v = a4h v = a8h v = ach soft start micro dma counter 0 interrupt 6 inttc during idle1 26 3 3 3 1 6 1 7 2 2 4 6 34 4 input or int0 to int4 micro dma channel priority encoder priority encoder dma0v dma1v dma2v dma3v reset interrupt request f/f reset decoder reset priority setting register v = 20h v = 24h interrupt controller cpu s q r v = 28h v = 2ch v = 30h v = 34h v = 38h v = 3ch v = 4ch d q clr y1 y2 y3 y4 y5 y6 a b c dn dn + 1 dn + 2 interrupt request f/f interrupt vector read micro dma acknowledge interrupt request flag dn + 3 a b c interrupt vector read d2 d3 d4 d5 d6 d7 selector s q r 0 1 2 3 a b d0 d1 interrupt vector read interrupt mask f/f micro dma request halt release nmi intrq2 to 0 iff2:0 interrupt level detect reset ei1 to 7 di interrupt request signal during stop micro dma channel specification reset nmi intwd int0 int1 int2 int3 int4 int5 intta0 s interrupt vector generator highest priority interrupt level select 1 2 3 4 5 6 7 d5 d4 d3 d2 d1 d0 d q clr if intrq2 to 0 iff 2 to 0 then 1. figure 3.5.3 block diagram of interrupt controller tmp91c829 2006-03-15 91c829-36 (1) interrupt priority setting registers symbol name address 7 6 5 4 3 2 1 0 intad int0 iadc iadm2 iadm1 iadm0 i0c i0m2 i0m1 i0m0 r r/w r r/w inte0ad inte0 & intad enable 90h 0 0 0 0 0 0 0 0 int2 int1 i2c i2m2 i2m1 i2m0 i1c i1m2 i1m1 i1m0 r r/w r r/w inte12 int1 & int2 enable 91h 0 0 0 0 0 0 0 0 int4 int3 i4c i4m2 i4m1 i4m0 i3c i3m2 i3m1 i3m0 r r/w r r/w inte34 int3 & int4 enable 92h 0 0 0 0 0 0 0 0 int5 i5c i5m2 i5m1 i5m0 r r/w inte5 int5 enable 93h 0 0 0 0 intta1 (tmra1) intta0 (tmra0) ita1c ita1m2 ita1m1 ita1m0 ita0c ita0m2 ita0m1 ita0m0 r r/w r r/w inteta01 intta0 & intta1 enable 95h 0 0 0 0 0 0 0 0 intta3 (tmra3) intta2 (tmra2) ita3c ita3m2 ita3m1 ita3m0 ita2c ita2m2 ita2m1 ita2m0 r r/w r r/w inteta23 intta2 & intta3 enable 96h 0 0 0 0 0 0 0 0 intta5 (tmra5) intta4 (tmra4) ita5c ita5m2 ita5m1 ita5m0 ita4c ita4m2 ita4m1 ita4m0 r r/w r r/w inteta45 intta4 & intta5 enable 97h 0 0 0 0 0 0 0 0 lxxm2 lxxm1 lxxm0 function (write) 0 0 0 disables interrupt requests 0 0 1 sets interrupt priority level to 1 0 1 0 sets interrupt priority level to 2 0 1 1 sets interrupt priority level to 3 1 0 0 sets interrupt priority level to 4 1 0 1 sets interrupt priority level to 5 1 1 0 sets interrupt priority level to 6 1 1 1 disables interrupt requests interrupt request flag tmp91c829 2006-03-15 91c829-37 symbol name address 7 6 5 4 3 2 1 0 inttb01 (tmrb0) inttb00 (tmrb0) itb01c itb01m2 itb01m1 itb01m0 itb00c itb00m2 itb00m1 itb00m0 r r/w r r/w intetb0 interrupt enable tmrb0 99h 0 0 0 0 0 0 0 0 (reserved) inttbof0 (overflow) itf0c itf0m2 itf0m1 itf0m0 r r/w intetb0v interrupt enable tmrb0v (overflow) 9bh 0 0 0 0 inttx0 intrx0 itx0c itx0m2 itx0m1 itx0m0 irx0c irx0m2 irx0m1 irx0m0 r r/w r r/w intes0 interrupt enable serial 0 9ch 0 0 0 0 0 0 0 0 inttx1 intrx1 itx1c itx1m2 itx1m1 itx1m0 irx1c irx1m2 irx1m1 irx1m0 r r/w r r/w intes1 interrupt enable serial 1 9dh 0 0 0 0 0 0 0 0 inttc1 inttc0 itc1c itc1m2 itc1m1 itc1m0 itc0c itc0m2 itc0m1 itc0m0 r r/w r r/w intetc01 inttc0 & inttc1 enable a0h 0 0 0 0 0 0 0 0 inttc3 inttc2 itc3c itc3m2 itc3m1 itc3m0 itc2c itc2m2 itc2m1 itc2m0 r r/w r r/w intetc23 inttc2 & inttc3 enable a1h 0 0 0 0 0 0 0 0 lxxm2 lxxm1 lxxm0 function (write) 0 0 0 disables interrupt requests 0 0 1 sets interrupt priority level to 1 0 1 0 sets interrupt priority level to 2 0 1 1 sets interrupt priority level to 3 1 0 0 sets interrupt priority level to 4 1 0 1 sets interrupt priority level to 5 1 1 0 sets interrupt priority level to 6 1 1 1 disables interrupt requests interrupt request flag tmp91c829 2006-03-15 91c829-38 (2) external interrupt control symbol name address 7 6 5 4 3 2 1 0 ? i2edge i2le i1dge i1le i0edge i0le nmiree w 0 0 0 0 0 0 0 0 iimc0 interrupt input mode control 0 8ch (prohibit rmw) write ?0?. int2edge 0: rising 1: falling int2edge 0: edge 1: level int1edge 0: rising 1: falling int1edge 0: edge 1: level int0edge 0: rising 1: falling int0 0: edge 1: level 1: operates even on rising + falling edge of nmi int2 level enable 0 edge detect int 1 h level int int1 level enable 0 edge detect int 1 h level int int0 level enable 0 edge detect int 1 h level int nmi rising edge enable 0 int request generat ion at falling edge 1 int request gen eration at rising/falling edge symbol name address 7 6 5 4 3 2 1 0 i5edge i5le i4edge i4le i3edge i3le w 0 0 0 0 0 0 iimc1 interrupt input mode control1 8dh (prohibit rmw) int5edge 0: rising 1: falling int5 0: edge 1: level int4edge 0: rising 1: falling int4 0: edge 1: level int3edge 0: rising 1: falling int3 0: edge 1: level int5 level enable 0 edge detect int 1 h level int int4 level enable 0 edge detect int 1 h level int int3 level enable 0 edge detect int 1 h level int when switching iimc0 and iimc1 register s, first every fc registers in port which built-in int function set to 0. tmp91c829 2006-03-15 91c829-39 setting functions on external interrupt pins interrupt pin mode setting method falling edge tmp91c829 2006-03-15 91c829-40 (4) micro dma start vector registers these registers assign micro dma processing to sets which source corresponds to dma. the interrupt source whose micro dma start vector value matches the vector set in one of these registers is designated as the micro dma start source. when the micro dma transfer counter value reaches zero, the micro dma transfer end interrupt corresponding to the channel is sent to the interrupt controller, the micro dma start vector register is cleared, and the micro dma start source for the channel is cleared. therefore, in order for micro dma processing to continue, the micro dma start vector register must be set again during proc essing of the micro dma transfer end interrupt. if the same vector is set in the micro dma start vector registers of more than one channel, the lowest numbered channel takes priority. accordingly, if the same vector is set in the micro dma start vector registers for two different channels, the interrupt generated on the lower-numbered channel is executed until micro dma transfer is complete. if the micro dma start vector for this channel has not been set in the channel?s mi cro dma start vector register again, micro dma transfer for the higher-numbered chan nel will be commenced. (this process is known as micro dma chaining.) symbol name address 7 6 5 4 3 2 1 0 dma0v5 dma0v4 dma0v3 dma0v2 dma0v1 dma0v0 r/w 0 0 0 0 0 0 dma0v dma0 start vector 80h dma0 start vector dma1v5 dma1v4 dma1v3 dma1v2 dma1v1 dma1v0 r/w 0 0 0 0 0 0 dma1v dma1 start vector 81h dma1 start vector dma2v5 dma2v4 dma2v3 dma2v2 dma2v1 dma2v0 r/w 0 0 0 0 0 0 dma2v dma2 start vector 82h dma2 start vector dma3v5 dma3v4 dma3v3 dma3v2 dma3v1 dma3v0 r/w 0 0 0 0 0 0 dma3v dma3 start vector 83h dma3 start vector (5) specification of a micro dma burst specifying the micro dma burst function causes micro dma transfer, once started, to continue until the value in the transfer co unter register reaches zero. setting any of the bits in the register dmab which corre spond to a micro dma channel (as shown below) to 1 specifies that any micro dma transfer on that channel will be a burst transfer. symbol name address 7 6 5 4 3 2 1 0 dmar3 dmar2 dmar1 dmar0 r/w r/w r/w r/w 0 0 0 0 dmar dma software request register 89h (prohibit rmw) 1: dma software request dmab3 dmab2 dmab1 dmab0 r/w 0 0 0 0 dmab dma burst register 8ah 1:dma burst request tmp91c829 2006-03-15 91c829-41 (6) notes the instruction execution unit and the bus interface unit in this cpu operate independently. therefore if, immediately before an interrupt is generated, the cpu fetches an instruction which clears the corre sponding interrupt request flag (note), the cpu may execute this instruction in between accepting the interrupt and reading the interrupt vector. in this case, the cpu will read the default vector 0008h and jump to interrupt vector address ffff08h. to avoid the avobe problem, place instruct ions that clear interrupt request flags after a di instruction. and in the case of setting an interrupt enable again by ei instruction after the execution of clearing instruction, execute ei instruction after clearing and more than 1 instructions (ex. ?nop? * 1 time). if placed ei instruction without waiting nop instruction after executio n of clearing instruction, interrupt will be enable before request flag is cleared. in the case of changing the value of the interrupt mask register tmp91c829 2006-03-15 91c829-42 3.6 port functions the tmp91c829 features 53 bit settings which relate to the various i/o ports. as well as general-purpose i/o po rt functionality, the port pins also have i/o functions which relate to the built-in cpu and internal i/os. table 3.6.1 lists the functions of each port pin. table 3.6.2 lists the i/o regist ers and t heir specifications. table 3.6.1 port functions (r: = with programmable pull-up resistor) port name pin name number of pins direction r direction setting unit pin name for internal function port 1 p10 to p17 8 i/o ? bit d8 to d15 port 2 p20 to p27 8 output ? bit a16 to a23 port 5 p53 1 i/o bit busrq p54 1 i/o bit busak p55 1 i/o bit wait p56 1 i/o bit int0 port 6 p60 1 output ? bit cs0 p61 1 output ? bit cs1 p62 1 output ? bit cs2 p63 1 output ? bit cs3 port 7 p70 1 i/o ? bit ta0in/int1 p71 1 i/o ? bit ta1out p72 1 i/o ? bit ta3out/int2 p73 1 i/o ? bit ta4in/int3 p74 1 i/o ? bit ta5out p75 1 i/o ? bit int4 port 8 p80 1 i/o bit txd0 p81 1 i/o bit rxd0 p82 1 i/o bit sclk0/ cts0 p83 1 i/o bit 0sts p84 1 i/o bit txd1 p85 1 i/o bit rxd1 p86 1 i/o bit sclk1/ cts1 p87 1 i/o bit 1sts port 9 p90 1 i/o ? bit int5 p93 1 i/o ? bit tb0in0 p94 1 i/o ? bit tb0in1 p95 1 i/o ? bit tb0out0 p96 1 i/o ? bit tb0out1 port a pa3 pa0 to pa7 1 7 input input ? ? (fixed) (fixed) adtrg an0 to an7 port z pz2 1 i/o bit hwr pz3 1 i/o bit tmp91c829 2006-03-15 91c829-43 table 3.6.2 i/o registers and their specifications (1/2) i/o registers port name specification pn pncr pnfc input port x 0 0 output port x 1 0 port 1 p10 to p17 d8 to d15 bus x 1 1 output port x 1 0 port 2 p20 to p27 a16 to a23 output x 1 1 input port (without pu) 0 0 0 input port (with pu) 1 0 0 output port x 1 0 pz2 hwr output x 1 1 input port (without pu) 0 0 input port (with pu) 1 0 port z pz3 output port x 1 none input port (without pu) 0 0 0 input port (with pu) 1 0 0 output port x 1 0 busrq input (without pu) 0 0 1 p53 busrq input (with pu) 1 0 1 input port (without pu) 0 0 0 input port (with pu) 1 0 0 output port x 1 0 p54 busak output x 1 1 input port/wait input (without pu) 0 0 input port/wait input (with pu) 1 0 p55 output port x 1 none input port/int0 input (without pu) 0 0 1 input port/int0 input (with pu) 1 0 1 port 5 p56 output port x 1 0 p60 to p63 output port x 0 p60 cs0 output x 1 p61 cs1 output x 1 p62 cs2 output x 1 port 6 p63 cs3 output x none 1 input port x 0 0 p70 to p75 output port x 1 0 ta0in input x 0 none p70 int1 input x 0 1 p71 ta1out output x 1 1 ta3out output x 1 1 p72 int2 input x 0 1 ta4in input x 0 none p73 int3 input x 0 1 p74 ta5out output x 1 1 port 7 p75 int4 input x 0 1 x: don?t care tmp91c829 2006-03-15 91c829-44 table 3.6.3 i/o registers and their specifications (2/2) i/o registers port name specification pn pncr pnfc input port (without pu) 0 0 0 input port (with pu) 1 0 0 output port x 1 0 p80 txd0 output x 1 1 input port/rxd0 input (without pu) 0 0 input port/rxd0 input (with pu) 1 0 p81 output port x 1 none input port/sclk0/cts0 input (without pu) 0 0 0 input port/sclk0/cts0 input (with pu) 1 0 0 output port x 1 0 p82 sclk0 output x 1 1 input port (without pu) 0 0 0 input port (with pu) 1 0 0 output port x 1 0 p83 0sts output x 1 1 input port (without pu) 0 0 0 input port (with pu) 1 0 0 output port x 1 0 p84 txd1 output x 1 1 input port/rxd1 input (without pu) 0 0 input port/rxd1 input (with pu) 1 0 p85 output port x 1 none input port/sclk1/cts1 input (without pu) 0 0 0 input port/sclk1/cts1 input (with pu) 1 0 0 output port x 1 0 p86 sclk1 output x 1 1 input port (without pu) 0 0 0 input port (with pu) 1 0 0 output port x 1 0 port 8 p87 1sts output x 1 1 input port x 0 0 output port x 1 0 p90 int5 input x 0 1 input port x 0 p93 to p96 output port x 1 p93 tb0in0 input x 0 p94 tb0in1 input x 0 none p95 tb0out0 output x 1 1 port 9 p96 tb0out1 output x 1 1 input port x pa3 adtrg input x input port x port a pa0 to pa7 an0 to an7 x none x: don?t care note 1: when pa1 to pa4 are used as ad converte r input channels, a 3-bit field in the ad mode control register admod1 tmp91c829 2006-03-15 91c829-45 after a reset the port pins listed below f unction as general-purpose i/o port pins. a reset sets i/o pins which can be programmed fo r either input or output to be input port pins. setting the port pins for internal func tion use must be done in software. note about bus release and programmable pull-up i/o port pins when the bus is released (e.g., when busak = 0), the output buffers for d0 to d15, a0 to a23, and the control signals ( rd , wr , hwr and cs0 to cs3 ) are off and are set to high-impedance. however, the output of built-in programmable pull-up resistors are kept before the bus is released. these programmable pull-up resistors can be selected on/off by programmable when they are used as the input ports. when they are used as output ports , they cannot be turned on/off in software. table 3.6.4 shows the pin states aft er the bus has been released. table 3.6.4 pin states (after bus release) pin state (after bus release) pin names used as port used for function p10 to p17 (d8 to d15) unchanged (e.g., not set to high-impedance (high-z)) high-impedance (high-z) p20 to p27 (a16 to 23) unchanged (e.g., not set to high-impedance (high-z)) first all bits are set high, then they are set to high-impedance (high-z). rd wr pz2 ( hwr ) the output buffer is set to off. the programmable pull-up resistor is set to on irrespective of the output latch. p60 ( cs0 ) p61 ( cs1 ) p62 ( cs2 ) p63 ( cs3 ) tmp91c829 2006-03-15 91c829-46 figure 3.6.1 shows an example external interf ac e circuit when the bus release function is used. when the bus is released, neither the internal memory nor the internal i/o can be accessed. however, the internal i/o continues to operate. as a result, the watchdog timer also continues to run. therefore, the bus release time must be taken into account and care must be taken when setting the detection time for the wdt. p20 (a16) to p27 (a23) rd wr pz2 ( hwr ) p60 ( cs0 ) p61 ( cs1 ) p62 ( cs2 ) p63 ( cs3 ) a ddress bus (a23 to a16) system control bus figure 3.6.1 interface circuit ex ample (using bus release function) the above circuit is necessary to set the signal level when the bus is released. a reset sets ( rd ) and ( wr ), p60 ( cs0 ), p61 ( cs1 ), p62 ( cs2 ), p63 ( cs3 ) to output, and pz2 ( hwr ) and p54 ( busak ) to input with pull-up resistor. tmp91c829 2006-03-15 91c829-47 3.6.1 port 1 (p10 to p17) port 1 is an 8-bit general-purpose i/o port. ea ch bit can be set individually for input or output using the control register p1cr. resetting, the control register p1cr to 0 and sets port 1 to input mode. in addition to functioning as a general-purpos e i/o port, port 1 can also function as an address data bus (d8 to d15). in case of am1 = 0, and am = 1 (outside 16-bit data bus), port 1 always functions as the data bus (d8 to d15) irre spective of the setting in p1cr control register. internal data bus direction control (on bit basis) p1cr write p10 to p17 (d8 to d15) output buffer reset p1 read output latch p1 write port 1 figure 3.6.2 port 1 port 1 register 7 6 5 4 3 2 1 0 bit symbol p17 p16 p15 p14 p13 p12 p11 p10 read/write r/w p1 (0001h) after reset data from external port (output latch register is cleared to 0.) port 1 control register 7 6 5 4 3 2 1 0 bit symbol p17c p16c p15c p14c p13c p12c p11c p10c read/write w after reset (note) 0/1 0/1 0/1 0/1 0/1 0/1 0/1 0/1 p1cr (0004h) function 0: input 1: output note1: read-modify-write is prohibited for p1cr. note2: it is set to ?port? or ?data bus? by am pins state. port 1 i/o setting 0 input 1 output figure 3.6.3 register for port 1 tmp91c829 2006-03-15 91c829-48 3.6.2 port 2 (p20 to p27) port 2 is an 8-bit output port. in addition to functioning as a output port, port 2 can also function as an address bus (a16 to a23). each bit can be set individually for address bus using the function register p2fc. resetting sets all bits of the function register p2fc to 1 and sets port 2 to address bus. internal data bus function control (on bits basis) p2fc write p20 to p27 (a16 to a23) output buffer reset p2 read output latch p2 write port 2 selector s a b s internal a16 to a23 figure 3.6.4 port 2 port 2 register 7 6 5 4 3 2 1 0 bit symbol p27 p26 p25 p24 p23 p22 p21 p20 read/write r/w p2 (0006h) after reset 1 1 1 1 1 1 1 1 port 2 function register 7 6 5 4 3 2 1 0 bit symbol p27f p26f p25f p24f p23f p22f p21f p20f read/write w after reset 1 1 1 1 1 1 1 1 p2fc (0009h) function 0: port 1: address bus (a23 to a16) note: read-modify-write is prohibited for p2fc. figure 3.6.5 register for port 2 tmp91c829 2006-03-15 91c829-49 3.6.3 port 5 (p53 to p56) port 5 is an 4-bit general-purpose i/o port . i/o is set using control register p5cr and p5fc. resetting resets all bits of the output latch p5 to 1, the control register p5cr and the function register p5fc to 0 and sets p52 to p56 to input mode with pull-up register. in addition to functioning as a general-purpos e i/o port, port 5 also functions as i/o for the cpu?s control/status signal. function control (on bit basis) s output latch p5fc write p5 write p53 ( busrq ) p5 read internal data bus direction control (on bit basis) p5cr write p-ch (programmable pull up) reset internal busrq figure 3.6.6 port 53 tmp91c829 2006-03-15 91c829-50 function control (on bit basis) s output latch p54( busak ) selector internal data bus direction control (on bit basis) p5cr write p-ch (programmable pull up) reset p5fc write p5 write output buffer p5 read s a b busak figure 3.6.7 port 54 internal wait s output latch p5 write p5 read internal data bus direction control (on bit basis) p5cr write p-ch (programmable pull up) reset p55 ( wait ) output buffer figure 3.6.8 port 55 tmp91c829 2006-03-15 91c829-51 internal data bus selector a b s p56 (int0) p5 write direction control (on bit basis) p5cr write function control (on bit basis) p5 write reset level or edge and rising edge or falling edge int0 iimc0 tmp91c829 2006-03-15 91c829-52 port 5 register 7 6 5 4 3 2 1 0 bit symbol p56 p55 p54 p53 read/write r/w after reset data from external port (output latch register is set to 1.) p5 (000dh) function 0(output latch register): pull-up resistor off 1(output latch register): pull-up resistor on port 5 control register 7 6 5 4 3 2 1 0 bit symbol p56c p55c p54c p53c read/write w after reset 0 0 0 0 p5cr (0010h) function 0: input 1: output i/o setting 0 input 1 output port 5 function register 7 6 5 4 3 2 1 0 bit symbol p56f p54f p53f read/write w w after reset 0 0 0 p5fc (0011h) function 0: port 1: int0 input 0: port 1: busak 0: port 1: busrq note 1: read-modify-write is prohibited for register p5cr, p5fc. note 2: when port 5 is used in the input mode, p5 register controls the built-in pull-up resistor. read-modify-write is prohibited in the input mode or the i/o mode. setting the built-in pull-up resistor may be depended on the states of the input pin. note 3: when p55 pin is used as a wait pin, set p5cr tmp91c829 2006-03-15 91c829-53 3.6.4 port 6 (p60 to p63) port 6 is a 4-bit output port. when reset, the p62 latch is cleared to 0 while the p60 to p63 output latches are set to 1. in addition to functioning as an output port, this port can output standard chip select signals ( cs0 to cs3 ). these settings are made by using the p6fc register. when reset, the p6fc register has all of its bi ts cleared to 0, so that the port is set for output mode. funtion control (on bit basis) s output lacth p6 read reset p60 ( cs0 ), p61 ( cs1 ), p63 ( cs3 ) cs0 , cs1 , cs3 selector p6fc write p6 write s a b internal data bus output buffer figure 3.6.11 port 60, 61, 63 function control (on bit basis) r output latch p6 read internal data bus reset output buffer p6fc write p6 write s a b p62 ( cs2 ) cs2 selector figure 3.6.12 port 62 tmp91c829 2006-03-15 91c829-54 port 6 register 7 6 5 4 3 2 1 0 bit symbol p63 p62 p61 p60 read/write r/w p6 (0012h) after reset 1 0 1 1 port 6 function register 7 6 5 4 3 2 1 0 bit symbol p63f p62f p61f p60f read/write w after reset 0 0 0 0 p6fc (0015h) function 0: port 1 1: cs note: read-modify-write is prohibited for the registers p6fc. 0 port (p60) 1 cs0 0 port (p61) 1 cs1 0 port (p62) 1 cs2 0 port (p63) 1 cs3 figure 3.6.13 register for port 6 tmp91c829 2006-03-15 91c829-55 3.6.5 port 7 (p70 to p75) port 7 is a 6-bit general-purp ose i/o port. each bit can be set individually for input or output. resetting sets port 7 to be an input port. in addition to functioning as a general-purpose i/o port, the indi vidual port can also have the following functions: port 70 and 73 can function as the inputs ta0in and ta 4in to the 8-bit timer, and port 71, 72 and 74 can function as the 8-bit timer outputs ta 1out, ta3out and ta5out. for each of the output pins, timer output can be enabled by writing a 1 to the corresponding bit in the port 7 function register (p7fc). resetting resets all bits of the registers p7cr and p7fc to 0, and sets all bits to be input port pins. p7 read selector a bs p70 (ta0in/int1) p73 (ta4in/int3) p75 (int4) int1 int3 int4 direction control (on bit basis) s output latch p7cr write p7 write function control (on bit basis) p7fc write reset internal data bus level or edge and rising edge or falling edge iimc0 tmp91c829 2006-03-15 91c829-56 p7 write ta1out: tmra1 ta5out: tmra5 reset p7 read selector a b s selector a b s p71 (ta1out) p74 (ta5out) timer f/f out direction control (on bit basis) p7cr write function control (on bit basis) p7fc write s output latch internal data bus figure 3.6.15 port 71, 74 p7 write (ta3out: tmra3) reset p7 read selector a b s selector a b s p72 (ta3out/int2) timer f/f out direction control (on bit basis) p7cr write function control (on bit basis) p7fc write s output latch internal data bus edge or level and rising edge or falling edge iimc0 tmp91c829 2006-03-15 91c829-57 port 7 register 7 6 5 4 3 2 1 0 bit symbol p75 p74 p73 p72 p71 p70 read/write r/w p7 (0013h) after reset data from external port (output latch register is set to 1.) port 7 control register 7 6 5 4 3 2 1 0 bit symbol p75c p74c p73c p72c p71c p70c read/write w after reset 0 0 0 0 0 0 p7cr (0016h) function 0: input 1: output port 7 i/o setting 0 input 1 output port 6 function register 7 6 5 4 3 2 1 0 bit symbol p72f2 p75f p74f p73f p72f1 p71f p70f read/write w w w w w after reset 0 0 0 0 0 0 0 p7fc (0017h) function 0: port 1: int2 input 0: port 1: int4 input 0: port 1: ta5out 0: port 1: int3 input 0: port 1: ta3out 0: port 1: ta1out 0: port 1: int1 input setting p71 as timer output 1 p7fc tmp91c829 2006-03-15 91c829-58 3.6.6 port 8 (p80 to p87) port 80 to 87 constitute a 8-bit general- purpose i/o port. each bit can be set individually for input or output. resetting sets p80 to p87 to be an input port. it also sets all bits of the output latch register to 1. in addition to functioning as general-purp ose i/o port, p80 to p87 can also function as the i/o for serial channels 0. these functi on can be enabled for i/o by writing a 1 to the corresponding bit of the port 8 function register (p8fc). resetting resets all bits of the registers p8 cr and p8fc to 0 and sets all bits to be input port (with pull-up resistors). (1) port 80 (txd0), 84 (txd1) as well as functioning as i/o port, port 80, 84 can also function as serial channel txd output pins. these port feature a programmable open-drain function. p80 (txd0) p84 (txd1) open-drain possible ode tmp91c829 2006-03-15 91c829-59 (2) port 81 (rxd0), 85 (rxd1) port 81, 85 are i/o port and can also be used as rxd input pin for the serial channels. rxd0 or rxd1 selector a bs p8 read p81 (rxd0) p85 (rxd1) derection control (on bit basis) p8cr write reset s output latch internal data bus p8 write p-ch (programmable pull up) out p ut buffe r figure 3.6.19 port 81, 85 (3) port 82 ( cts0 /sclk0), 86 ( cts1 /sclk1) port 82, 86 are i/o port and can also be used as the cts input pins or sclk i/o pins for the serial channels. selector a b s selector a bs p82 (sclk0/ cts0 ) p86 (sclk1/ cts1 ) sclk0 sclk1 p8 read direction control (on bit basis) p8cr write function contorl (on bit basis) p8fc write p8 write reset internal data bus s output latch sclk0, cts0 input sclk1, cts1 input p-ch (programmable pull up) figure 3.6.20 port 82, 86 tmp91c829 2006-03-15 91c829-60 (4) port 83 ( 0sts ), 87 ( 1sts ) port 83, 87 are i/o port and can also be used as sts output for the received data request signal. reset p8cr write p8 write p8 read function control (on bit basis) p8fc write 0sts or 1sts p83 ( 0sts ) p87 ( 1sts ) s b y a selector direction control (on bit basis) p-ch (programmable pull up) internal data bus s output latch s a y selector b figure 3.6.21 port 83, 87 tmp91c829 2006-03-15 91c829-61 port 8 register 7 6 5 4 3 2 1 0 bit symbol p87 p86 p85 p84 p83 p82 p81 p80 read/write r/w after reset data from external port (o utput latch register is set to 1.) p8 (0018h) function 0(output latch register) : pull-up resistor off 1(output latch register): pull-up resistor on port 8 control register 7 6 5 4 3 2 1 0 bit symbol p87c p86c p85c p84c p83c p82c p81c p80c read/write w after reset 0 0 0 0 0 0 0 0 p8cr (001ah) function 0: input 1: output port 8 i/o setting 0 input 1 output port 8 function register 7 6 5 4 3 2 1 0 bit symbol p87f p86f p84f p83f p82f p80f read/write w w w w w w after reset 0 0 0 0 0 0 p8fc (001bh) function 0: port 1: 1sts output 0: port 1: sclk1 output 0: port 1: txd1 output 0: port 1: 0sts output 0: port 1: sclk0 output 0: port 1: txd0 input to set p80, 84 for txd0, txd1 output p8fc tmp91c829 2006-03-15 91c829-62 3.6.7 port 9 (p90, p93 to p96) port 9 is an 8-bit general-purpose i/o port. ea ch bit can be set individually for input or output, resetting sets port 9 to be an input po rt, it also sets all bits in the output latch register p9 to 1. in addtion to functioning as a general-purpose i/o port, the various pins of port 9 can also function as the clock input for the 16-bit timer flipflop putput, on as input int5. these functions cn be enabled by writing a 1 to the corresponding bits in the port 9 function registers (p9fc). (1) p90 internal data bus direction control (on bit basis) reset s output latch p9 write p90 (int5) selector p9 read p9fc tmp91c829 2006-03-15 91c829-63 (2) p93 to p96 tb0in0 tb0in1 p95 (tb0out0) p96 (tb0out1) p9 read timer f/f out p9 read internal data bus selector a b s selector a b s selector a b s p93 (tb0in0) p94 (tb0in1) direction control (on bit basis) s output latch p9cr write p9 write direction control (on bit basis) p9cr write function control (on bit basis) p9fc write s output latch p9 write reset tb0out0: tmrb0 tb0out1: tmrb0 reset figure 3.6.24 port p93 to p96 tmp91c829 2006-03-15 91c829-64 port 9 register 7 6 5 4 3 2 1 0 bit symbol p96 p95 p94 p93 p90 read/write r/w r/w p9 (0019h) after reset data from external port (output latch register is set to 1.) data from external port (output latch register is set to 1.) port 9 control register 7 6 5 4 3 2 1 0 bit symbol p96c p95c p94c p93c p90c read/write w w after reset 0 0 0 0 0 p9cr (001ch) function 0: input 1: output 0: input 1: output port 9 i/o setting 0 input 1 output port 9 function register 7 6 5 4 3 2 1 0 bit symbol p96f p95f p90f read/write w w w after reset 0 0 0 p9fc (001dh) function 0: port 1: tb0out1 0: port 1: tb0out0 0: port 1: int5 input to set p95 for timer 8 output 1 p9fc tmp91c829 2006-03-15 91c829-65 3.6.8 port a (pa0 to pa7) port a is an 8-bit input port and can also be used as the analog input pins for the internal ad converter. internal data bus ad read conversion result register ad converter channel selector port a read pa0 to pa7 ( adtrg , an0 to an7) a dtrg (only pa3) figure 3.6.26 port a port a register 7 6 5 4 3 2 1 0 bit symbol pa7 pa6 pa5 pa4 pa3 pa2 pa1 pa0 read/write r pa (0019h) after reset data from external port. note: the input channel selection of ad converter and the permission of adtrg input are set by ad converter mode register admod1. figure 3.6.27 register for port a tmp91c829 2006-03-15 91c829-66 3.6.9 port z (pz2, pz3) port z is a 4-bit general-purpose i/o port. i/o is set using control register pzcr and pzfc. resetting resets all bits of the output latch pz to 1, the control register pzcr and the function register pzfc to 0 and sets pz2 and pz3 to input mode with pull-up register. in addition to functioning as a general-purpos e i/o port. port z also functions as i/o for the cpu?s control/status signal. function control (on bit basis) s output latch pz2( hwr ) selector internal data bus direction control (on bit basis) pzcr write p-ch (programmable pull up) reset pzfc write pz write output buffer pz read s a b hwr figure 3.6.28 port z2 internal data bus selector a b s pz read direction control (on bit basis) pzcr write reset s output latch pz write pz3 p-ch (programmable pull up) output buffer figure 3.6.29 port z3 tmp91c829 2006-03-15 91c829-67 port z register 7 6 5 4 3 2 1 0 bit symbol pz3 pz2 read/write r/w pz (007dh) after reset data from external port (output latch register is set to 1.) port z control register 7 6 5 4 3 2 1 0 bit symbol pz3 pz2 read/write w after reset 0 0 pzcr (007eh) function 0: input 1: output setting port z as i/o 0 input 1 output port z control register 7 6 5 4 3 2 1 0 bit symbol pz2f read/write w after reset 0 pzfc (007fh) function 0: port 1: hwr note: read-modify ?write is prohibited for the registers pzcr and pzfc. figure 3.6.30 register for port z tmp91c829 2006-03-15 91c829-68 3.7 chip select/wait controller on the tmp91c829, four user specifiable address areas (cs0 to cs3) can be set. the data bus width and the number of waits can be set independ ently for each address area (cs0 to cs3 plus any other). the pins cs0 to cs3 (which can also function as p60 to p63) are the respective output pins for the areas cs0 to cs3. when the cpu specifies an address in one of these areas, the corresponding cs0 to cs3 pin outputs the chip select signal for the specified address area (in rom or sram). however, in order for the chip se lect signal to be output, the port 6 function register p6fc must be set. external connection of rom and sram is supported. the areas cs0 to cs3 are defined by the values in the memory start address registers msar0 to msar3 and the memory addre ss mask registers mamr0 to mamr3. the chip select/wait control registers b0cs to b3cs and bexcs should be used to specify the master enable/disable status the data bus width and the number of waits for each address area. the input pin which controls these states is the bus wait request pin ( wait ). 3.7.1 specifying an address area the address areas cs0 to cs3 are specified using the memory start address registers (msar0 to msar3) and the memory addre ss mask registers (m amr0 to mamr3). during each bus cycle, a compare operation is performed to determine whether or not the address specified on the bus corresponds to a location in one of the areas cs0 to cs3. if the result of the comparison is a match, it indicates that the corresponding cs area is to be accessed. if so, the corresponding cs0 to cs3 pin outputs the chip select signal and the bus cycle proceeds according to the settings in the corresponding b0cs to b3cs chip select/wait control register. (see 3.7.2 ? chip select/wait control registers?.) tmp91c829 2006-03-15 91c829-69 (1) memory start address registers figure 3.7.1 shows the memory start addr ess registers. the m emory start address registers msar0 to msar3 determine the start addresses for the memory areas cs0 to cs3 respectively. the eight most significan t bits (a23 to a16) of the start address should be set in tmp91c829 2006-03-15 91c829-70 (2) memory address mask registers figure 3.7.3 shows the memory address mask registers. the size of each of the areas cs0 to cs3 can be set by specifying a mask in the corresponding memory address mask register (mamr0 to mamr3). each bit in a memory address mask register (mamr0 to mamr3) which is set to 1 masks the co rresponding bit of the start address which has been set in the corresponding memory start address register (msar0 to msar3). the compare operation used to determine whether or not a bus address is in one of the areas cs0 to cs3 only compares address bits for which a 0 has been set in the corresponding bit position in the corres ponding memory address mask register. also, the address bits which each memory a ddress mask register can mask vary from register to register; hence, the possible si ze settings for the areas cs0 to cs3 differ accordingly. memory address mask regi ster (for cs0 area) 7 6 5 4 3 2 1 0 bit symbol v20 v19 v18 v17 v16 v15 v14 to 9 v8 read/write r/w after reset 1 1 1 1 1 1 1 1 mamr0 (00c9h) function sets size of cs0 area. 0: used for address compare range of possible settings for cs0 area size: 256 bytes to 2 mbytes. memory address mask register (cs1) 7 6 5 4 3 2 1 0 bit symbol v21 v20 v19 v18 v17 v16 v15 to 9 v8 read/write r/w after reset 1 1 1 1 1 1 1 1 mamr1 (00cbh) function sets size of cs1 area. 0: used for address compare range of possible settings for cs1 area size: 256 bytes to 4 mbytes. memory address mask register (cs2, cs3) 7 6 5 4 3 2 1 0 bit symbol v22 v21 v20 v19 v18 v17 v16 v15 read/write r/w after reset 1 1 1 1 1 1 1 1 mamr2 (00cdh)/ mamr3 (00cfh) function sets size of cs2 or cs3 area. 0: used for address compare range of possible settings for cs2 and cs3 area sizes: 32 kbytes to 8 mbytes. figure 3.7.3 memory address mask registers tmp91c829 2006-03-15 91c829-71 (3) setting memory start ad dresses and address areas figure 3.7.4 shows an example in which cs 0 is spec ified to be a 64-kbyte address area starting at 010000h. first, msar0 tmp91c829 2006-03-15 91c829-72 (4) address area si ze specification table 3.7.1 shows the valid area sizes for each cs area and indicates which method can be used to make th e size setting. a ? ? indicates that it is not possible to set the area size in question using the memory start address register and memory address mask register. if an area size for a cs area marked ? ? in the table is to be set, the start address must either be set to 000000h or to a value that is greater than 000000h by an integer multiple of the desired area size. if the cs2 area is set to 16 mbytes or if two or more areas overlap, the lowest-numbered cs area has highest priority (e.g., cs0 has a higher priority than any other area). example: to set the area size for cs0 to 128 kbytes: a. valid start addresses 000000h 020000h 040000h 060000h 128 kbytes 128 kbytes 128 kbytes any of these addresses may be set as the start address. b. invalid start addresses 000000h 010000h 030000h 050000h 64 kbytes 128 kbytes 128 kbytes this is not an integer multiple of the desired area size setting. hence, none of these addresses can be set as the start address. table 3.7.1 valid area sizes for each cs area size (bytes) cs area 256 512 32 k 64 k 128 k 256 k 512 k 1 m 2 m 4 m 8 m cs0 cs1 cs2 cs3 tmp91c829 2006-03-15 91c829-73 3.7.2 chip select/wait control registers figure 3.7.5 lists the chip select/wait control registers. the master enable/disable, chip select outp ut waveform, data bus width, and number of wait states for each address area (cs0 to cs3 plus any other) are set in the respective chip select/wait control registers, b0cs to b3cs or bexcs. chip select/wait control register 7 6 5 4 3 2 1 0 bit symbol b0e b0om1 b0om0 b0bus b0w2 b0w1 b0w0 read/write w w after reset 0 0 0 0 0 0 0 function 0: disable 1: enable chip select output waveform selection 00: for rom/sram 01: 10: don?t care 11: data bus width 0: 16 bits 1: 8 bits number of waits 000: 2 waits 001: 1 wait 010: (1 + n) waits 1xx: reserved 011: 0 waits bit symbol b1e b1om1 b1om0 b1bus b1w2 b1w1 b1w0 read/write w w after reset 0 0 0 0 0 0 0 function 0: disable 1: enable chip select output waveform selection 00: for rom/sram 01: 10: don?t care 11: data bus width 0: 16 bits 1: 8 bits number of waits 000: 2 waits 001: 1 wait 010: (1 + n) waits 1xx: reserved 011: 0 waits bit symbol b2e b2m b2om1 b2om0 b2bus b2w2 b2w1 b2w0 read/write w after reset 1 0 0 0 0 0 0 0 function 0: disable 1: enable cs2 area selection 0: 16-mbyte area 1: cs area chip select output waveform selection 00: for rom/sram 01: 10: don?t care 11: data bus width 0: 16 bits 1: 8 bits number of waits 000: 2 waits 001: 1 wait 010: (1 + n) waits 1xx: reserved 011: 0 waits bit symbol b3e b3om1 b3om0 b3bus b3w2 b3w1 b3w0 read/write w w after reset 0 0 0 0 0 0 0 function 0: disable 1: enable chip select output waveform selection 00: for rom/sram 01: 10: don?t care 11: data bus width 0: 16 bits 1: 8 bits number of waits 000: 2 waits 001: 1 wait 010: (1 + n) waits 1xx: reserved 011: 0 waits bit symbol bexbus bexw2 bexw1 bexw0 read/write w after reset 0 0 0 0 function data bus width 0: 16 bits 1: 8 bits number of waits 000: 2 waits 001: 1 wait 010: (1 + n) waits 1xx: reserved 011: 0 waits chip select output waveform selection 00 for rom/sram 01 10 11 don?t care master enable bit 0 cs area disable 1 cs area enable b0cs (00c0h) read- modify- write instructions are prohibited. b1cs (00c1h) read- modify- write instructions are prohibited. b2cs (00c2h) read- modify- write instructions are prohibited. b3cs (00c3h) read- modify- write instructions are prohibited. bexcs (00c7h) read- modify- write instructions are prohibited. cs2 area selection 0 16-mbyte area 1 specified address area data bus width selection 0 16-bit data bus 1 8-bit data bus number of address area waits (see 3.7.2 (3) ?wait control?.) figure 3.7.5 chip select/wait control registers tmp91c829 2006-03-15 91c829-74 (1) master enable bits bit7 ( tmp91c829 2006-03-15 91c829-75 (3) wait control bits 0 to 2 ( tmp91c829 2006-03-15 91c829-76 (6) procedure for setting chip select/wait control when using the chip select/wait control function, set the registers in the following order: a. set the memory start addre ss registers msar0 to msar3. set the start addresses for cs0 to cs3. b. set the memory address mask registers mamr0 to mamr3. set the sizes of cs0 to cs3. c. set the chip select/wait control registers b0cs to b3cs. set the chip select output waveform, data bus width, number of waits and master enable/disable status for cs0 to cs3 . the cs0 to cs3 pins can also function as pins p60 to p63. to output a chip select signal using one of these pins, set the corresponding bit in the port 6 function register p6fc to 1. if a cs0 to cs3 address is specified whic h is actually an internal i/o, ram or rom area address, the cpu a ccesses the internal address area and no chip select signal is output on any of the cs0 to cs3 pins. example: in this example cs0 is set to be the 64-kbyte area 010000h to 01ffffh. the bus width is set to 16 bits and the number of waits is set to 0. msar0 = 01h ............start address: 010000h mamr0 = 07h...........address area: 64 kbytes b0cs = 83h ...............rom/sram, 16-bit data bus, zero waits, cs0 area settings enabled. tmp91c829 2006-03-15 91c829-77 3.7.3 connecting external memory figure 3.7.6 shows an example of how to connect external memory to the tmp91c829. in this example the rom is connected using a 16-bit bus. the ram and i/o are connected using an 8-bit bus. address bus cs 8-bit ram oe we tmp91c829 cs upper byte rom oe cs lower byte rom oe cs 8-bit i/o oe we cs0 cs1 cs2 a0 to a23 d8 to d15 d0 to d7 rd wr figure 3.7.6 example of external memory connection (rom uses 16-bit bus; ram and i/o use 8-bit bus.) a reset clears all bits of the port 4 control register p6cr and the port 6 function register p6fc to 0 and disables output of the cs signal. to output the cs signal, the appropriate bit must be set to 1. tmp91c829 2006-03-15 91c829-78 3.8 8-bit timers (tmra) the tmp91c829 features six built-in 8-bit timers. these timers are paired into three modules: tmra01, tmra23 and tmra45. each module consists of two channels and can operate in any of the following four operating modes. ? 8-bit interval timer mode ? 16-bit interval timer mode ? 8-bit programmable square wave puls e generation output mode (ppg ? variable duty cycle with variable period) ? 8-bit pulse width modulation output mode (pwm ? variable duty cycle with constant period) figure 3.8.1 to 3.8.3 show block diag ra ms for tmra01, tmra23 and tmra45. each channel consists of an 8-bit up counter, an 8-bit comparator and an 8-bit timer register. in addition, a timer flip-flop and a prescale r are provided for each pair of channels. the operation mode and timer flip-flops are controlled by five control sfrs (special function registers). each of the four modules (tmra01, tmra23, and tmra45) can be operated independently. all modules operate in the same manner; hence only the operation of tmra01 is explained here. table 3.8.1 registers and pins for each module module tmra01 tmra23 tmra45 input pin for external clock ta0in (shared with p70) no ta4in (shared with p73) external pin output pin for timer flip-flop ta1out (shared with p71) ta3out (shared with p72) ta5out (shared with p74) timer run register ta01run (0100h) ta23run (0108h) ta45run (0110h) timer register ta0reg (0102h) ta1reg (0103h) ta2reg (010ah) ta3reg (010bh) ta4reg (0112h) ta5reg (0113h) timer mode register ta01mod (0104h) ta23mod (010ch) ta45mod (0114h) sfr (address) timer flip-flop control register ta1ffcr (0105h) ta3ffcr (010dh) ta5ffcr (0115h) tmp91c829 2006-03-15 91c829-79 3.8.1 block diagrams run/clear prescaler clock: t0 ta0trg external input clock: ta0in ta01mod tmp91c829 2006-03-15 91c829-80 t1 t16 t256 run/clear prescale r clock: t0 ta2trg ta23mod tmp91c829 2006-03-15 91c829-81 run/clear prescale r clock: t0 ta4trg external input clock: ta4in ta45mod tmp91c829 2006-03-15 91c829-82 3.8.2 operation of each circuit (1) prescalers a 9-bit prescaler generates the input clock to tmra01. the clock t0 is divided by 4 and input to this prescaler. t0 can be either f fph or fc/16 and is selected using the prescaler clock selection register syscr0 tmp91c829 2006-03-15 91c829-83 (3) timer registers (ta0reg and ta1reg) these are 8-bit registers which can be used to set a time interval. when the value set in the timer register ta0reg or ta1reg matches the value in the corresponding up counter, the comparator match detect signal goes active. if the value set in the timer register is 00h, the signal goes active when the up counter overflows. the ta0reg are double buffer structure, each of which makes a pair with register buffer. the setting of the bit ta01run tmp91c829 2006-03-15 91c829-84 (4) comparator (cp0) the comparator compares the value in an up counter with the value set in a timer register. if they match, the up counter is cleared to zero and an interrupt signal (intta0 or intta1) is generated. if timer flip-flop inversion is enabled, the timer flip-flop is inverted at the same time. (5) timer flip-flop (ta1ff) the timer flip-flop (ta1ff) is a flip-flop inverted by the match detect signal (8-bit comparator output) of each interval timer. whether inversion is enabled or disabled is determined by the setting of the bit ta1ffcr tmp91c829 2006-03-15 91c829-85 3.8.3 sfrs tmra01 run register 7 6 5 4 3 2 1 0 bit symbol ta0rde i2ta01 ta01prun ta1run ta0run read/write r/w r/w after reset 0 0 0 0 0 ta01run (0100h) function double buffer 0: disable 1: enable idle2 0: stop 1: operate 8-bit timer run/stop control 0: stop and clear 1: run (count up) ta0reg double buffer control timer run/stop control 0 disable 0 stop and clear 1 enable 1 run (count up) i2ta01: operation in idle2 mode ta01prun: run prescaler ta1run: run tmra1 ta0run: run tmra0 note: the values of bits 4 to 6 of ta01run are undefined when read. tmra23 run register 7 6 5 4 3 2 1 0 bit symbol ta2rde i2ta23 ta23prun ta3run ta2run read/write r/w r/w after reset 0 0 0 0 0 ta23run (0108h) function double buffer 0: disable 1: enable idle2 0: stop 1: operate 8-bit timer run/stop control 0: stop and clear 1: run (count up) ta2reg double buffer control timer run/stop control 0 disable 0 stop and clear 1 enable 1 run (count up) i2ta23: operation in idle2 mode ta23prun: run prescaler ta3run: runtmra3 ta2run: run tmra2 note: the values of bits 4 to 6 of ta23run are undefined when read. figure 3.8.5 tmra registers tmp91c829 2006-03-15 91c829-86 tmra45 run register 7 6 5 4 3 2 1 0 bit symbol ta4rde i2ta45 ta45prun ta5run ta4run read/write r/w r/w after reset 0 0 0 0 0 ta45run (0110h) function double buffer 0: disable 1: enable idle2 0: stop 1: operate 8-bit timer run/stop control 0: stop and clear 1: run (count up) ta4reg double buffer control timer run/stop control 0 disable 0 stop and clear 1 enable 1 run (count up) i2ta45: operation during idle2 mode ta45prun: run for prescaler ta5run: run tmra5 ta4run: run tmra4 note: the values of bits 4 to 6 of ta45run are undefined when read. figure 3.8.6 tmra registers tmp91c829 2006-03-15 91c829-87 tmra01 mode register 7 6 5 4 3 2 1 0 bit symbol ta01m1 ta01m0 pwm01 pwm 00 ta1clk1 ta1clk0 ta0clk1 ta0clk0 read/write r/w after reset 0 0 0 0 0 0 0 0 ta01mod (0104h) function operation mode 00: 8-bit timer mode 01: 16-bit timer mode 10: 8-bit ppg mode 11: 8-bit pwm mode pwm cycle 00: reserved 01: 2 6 10: 2 7 11: 2 8 source clock for tmra1 00: ta0trg 01: t1 10: t16 11: t256 source clock for tmra0 00: ta0in pin 01: t1 10: t4 11: t16 tmra0 source clock selection 00 ta0in (external input) 01 t1 (prescaler) 10 t4 (prescaler) 11 t16 (prescaler) tmra1 source clock selection ta01mod tmp91c829 2006-03-15 91c829-88 tmra23 mode register 7 6 5 4 3 2 1 0 bit symbol ta23m1 ta23m0 pwm21 pwm 20 ta3clk1 ta3clk0 ta2clk1 ta2clk0 read/write r/w after reset 0 0 0 0 0 0 0 0 ta23mod (010ch) function operation mode 00: 8-bit timer mode 01: 16-bit timer mode 10: 8-bit ppg mode 11: 8-bit pwm mode pwm cycle 00: reserved 01: 2 6 10: 2 7 11: 2 8 tmra3 clock for tmra3 00: ta2trg 01: t1 10: t16 11: t256 tmra2 clock for tmra2 00: reserved 01: t1 10: t4 11: t16 tmra2 source clock selection 00 do not set 01 t1 (prescaler) 10 t4 (prescaler) 11 t16 (prescaler) tmra3 source clock selection ta23mod tmp91c829 2006-03-15 91c829-89 tmra45 mode register 7 6 5 4 3 2 1 0 bit symbol ta45m1 ta45m0 pwm41 pwm 40 ta5clk1 ta5clk0 ta4clk1 ta4clk0 read/write r/w after reset 0 0 0 0 0 0 0 0 ta45mod (0114h) function operation mode 00: 8-bit timer mode 01: 16-bit timer mode 10: 8-bit ppg mode 11: 8-bit pwm mode pwm cycle 00: reserved 01: 2 6 10: 2 7 11: 2 8 source clock for tmra5 00: ta4trg 01: t1 10: t16 11: t256 source clock for tmra4 00: ta4in pin 01: t1 10: t4 11: t16 source clock for tmra4 00 ta4in (external input) 01 t1 (prescaler) 10 t4 (prescaler) 11 t16 (prescaler) source clock for tmra5 ta45mod tmp91c829 2006-03-15 91c829-90 tmra1 flip-flop control register 7 6 5 4 3 2 1 0 bit symbol ta1ffc1 ta1ffc0 ta1ffie ta1ffis read/write r/w r/w after reset 1 1 0 0 ta1ffcr (0105h) read- modify-write instructions are prohibited. function 00: invert ta1ff 01: set ta1ff 10: clear ta1ff 11: don?t care ta1ff control for inversion 0: disable 1: enable ta1ff inversion select 0: tmra0 1: tmra1 inverse signal for timer flip-flop 1 (ta1ff) (don?t care except in 8-bit timer mode) 0 inversion by tmra0 1 inversion by tmra1 inversion of ta1ff 0 disabled 1 enabled control of ta1ff 00 inverts the value of ta1ff 01 sets ta1ff to 1 10 clears ta1ff to 0 11 don?t care figure 3.8.10 tmra registers tmp91c829 2006-03-15 91c829-91 tmra3 flip-flop control register 7 6 5 4 3 2 1 0 bit symbol ta3ffc1 ta3ffc0 ta3ffie ta3ffis read/write r/w r/w after reset 1 1 0 0 ta3ffcr (010dh) read- modify-write instructions are prohibited. function 00: invert ta3ff 01: set ta3ff 10: clear ta3ff 11: don?t care ta3ff control for inversion 0: disable 1: enable ta3ff inversion select 0: tmra2 1: tmra3 inverse signal for timer flip-flop 3 (ta3ff) (don?t care except in 8-bit timer mode) 0 inversion by tmra2 1 inversion by tmra3 inversion of ta3ff 0 disabled 1 enabled control of ta3ff 00 inverts the value of ta3ff 01 sets ta3ff to 1 10 clears ta3ff to 0 11 don?t care figure 3.8.11 tmra registers tmp91c829 2006-03-15 91c829-92 tmra5 flip-flop control register 7 6 5 4 3 2 1 0 bit symbol ta5ffc1 ta5ffc0 ta5ffie ta5ffis read/write r/w r/w after reset 1 1 0 0 ta5ffcr (0115h) read- modify-write instructions are prohibited. function 00: invert ta5ff 01: set ta5ff 10: clear ta5ff 11: don?t care ta5ff control for inversion 0: disable 1: enable ta5ff inversion select 0: tmra4 1: tmra5 inverse signal for timer flip-flop 5 (ta5ff) (don?t care except in 8-bit timer mode) 0 inversion by tmra4 1 inversion by tmra5 inversion of ta5ff 0 disabled 1 enabled control of ta5ff 00 inverts the value of ta5ff 01 sets ta5ff to 1 10 clears ta5ff to 0 11 don?t care figure 3.8.12 tmra registers tmp91c829 2006-03-15 91c829-93 tmra register 7 6 5 4 3 2 1 0 bit symbol ? read/write w ta0reg (0102h) after reset undefined bit symbol ? read/write w ta1reg (0103h) after reset undefined bit symbol ? read/write w ta2reg (010ah) after reset undefined bit symbol ? read/write w ta3reg (010bh) after reset undefined bit symbol ? read/write w ta4reg (0112h) after reset undefined bit symbol ? read/write w ta5reg (0113h) after reset undefined note: the above registers are prohibit ed read-modify-write instruction. figure 3.8.13 tmra registers tmp91c829 2006-03-15 91c829-94 3.8.4 operation in each mode (1) 8-bit timer mode both tmra0 and tmra1 can be used independently as 8-bit interval timers. a. generating interrupts at a fixed interval (using tmra1) to generate interrupts at constant inte rvals using tmra1 (intta1), first stop tmra1 then set the operation mode, input clock and a cycle to ta01mod and ta1reg register, respecti vely. then, enable the interrupt intta1 and start tmra1 counting. example: to generate an intta1 interrupt every 8.8 s at fc = 36 mhz, set each register as follows: * clock state system clock: high frequency (fc) prescaler clock: f fph msb lsb 7 6 5 4 3 2 1 0 ta01run ? ? x x ? ? 0 ? stop tmra1 and clear it to 0. ta01mod 0 0 x x 1 0 x x select 8-bit timer mode and select t1 ((2 3 /fc) s at fc = 36 mhz) as the input clock. ta1reg 0 0 1 0 1 0 0 0 set ta1reg to 8.8 s t1 (2 3 /fc) = 40 = 28h inteta01 x 1 0 1 ? ? ? ? enable intta1 and set it to level 5. ta01run ? x x x ? 1 1 ? start tmra1 counting. x: don?t care, ? : no change select the input clock using table 3.8.4 note: the input clocks for tmra0 and tmra1 differ as follows: tmra0: uses ta0in input and can be selected from t1, t4, or t16. tmra1: match output of tmra 0 and can be selected from t1, t16, t256. tmp91c829 2006-03-15 91c829-95 b. generating a 50% duty ratio square wave pulse the state of the timer flip-flop (ta1ff) is inverted at constant intervals and its status output via the timer output pin (ta1out). example: to output a 1.32 s square wave pulse from the ta1out pin at fc = 36 mhz, use the following procedure to make the appropriate register settings. this example uses tmra1; however, either tmra0 or tmra1 may be used. * clock state system clock: high frequency (fc) clock gear: 1 (fc) prescaler clock: f fph 7 6 5 4 3 2 1 0 ta01run ? x x x ? ? 0 ? stop tmra1 and clear it to 0. ta01mod 0 0 x x 0 1 ? ? select 8-bit timer mode and select t1 ((2 3 /fc)s at fc = 36 mhz) as the input clock. ta1reg 0 0 0 0 0 0 1 1 set the timer register to 1.32 s t1(2 3 /fc)s 2 = 3 ta1ffcr x x x x 1 0 1 1 clear ta1ff to 0 and set it to invert on the match detect signal from tmra1. p7cr x x ? ? ? ? 1 ? p7fc x x ? ? x ? 1 x set p71 to function as the ta1out pin. ta01run ? x x x ? 1 1 ? start tmra1 counting. x: don?t care, ? : no change 0.67 s at fc = 36 mhz bit7 to 2 t1 intta1 uc1 clea r ta1ff bit0 bit1 ta01run tmp91c829 2006-03-15 91c829-96 c. making tmra1 count up on the match signal from the tmra0 comparator select 8-bit timer mode and set the comparator output from tmra0 to be the input clock to tmra1. tmra1 up counter (when ta1reg = 2) tmra0 up counter (when ta0reg = 5) 1 2 3 4 5 1 1 22 33 45 12 1 comparator output (tmra0 match) tmra1 match output figure 3.8.15 tmra1 count up on signal from tmra0 (2) 16-bit timer mode a 16-bit interval timer is configured by pairing the two 8-bit timers tmra0 and tmra1. to make a 16-bit interval timer in whic h tmra0 and tmra1 are cascaded together, set ta01mod tmp91c829 2006-03-15 91c829-97 the comparator match signal is output from tmra0 each time the up counter uc0 matches ta0reg, where the up counter uc0 is not be cleared. in the case of the tmra1 comparator, the match detect signal is output on each comparator pulse on which the values in the up counter uc1 and ta1reg match. when the match detect signal is output simultaneously from both the comparators tmra0 and tmra1, the up counters uc0 and uc1 are cleared to 0 and the interrupt intta1 is generated. also, if inversion is enabled, the value of the timer flip-flop ta1ff is inverted. example: when ta1reg = 04h and ta0reg = 80h figure 3.8.16 timer output by 16-bit timer mode (3) 8-bit ppg (programmable pulse generation) output mode square wave pulses can be generated at any frequency and duty ratio by tmra0. the output pulses may be active-low or active-high. in this mode tmra1 cannot be used. tmra0 outputs pulses on the ta1out pin (which can also be used as p71). figure 3.8.17 8-bit ppg output waveforms t ta0reg and uc0 match (interrupt intta0) t h t l ta0reg ta1reg ta1reg and uc0 match ( interru p ut intta1 ) ta1out t t l t h when tmp91c829 2006-03-15 91c829-98 in this mode a programmable square wave is generated by inverting the timer output each time the 8-bit up counter (uc0) matches the value in one of the timer registers ta0reg or ta1reg. the value set in ta0reg must be smaller than the value set in ta1reg. although the up counter for tmra1 (u c1) is not used in this mode, ta01run tmp91c829 2006-03-15 91c829-99 example: to generate 1/4 duty 50khz pulses (at fc = 36 mhz): 20 s * clock state system clock: high frequency (fc) clock gear: 1 (fc) prescaler clock: f fph calculate the value which should be set in the timer register. to obtain a frequency of 50khz, the pulse cycle t should be: t = 1/50 khz = 20 s t1 = (2 3 /fc)s (at 36 mhz); 20 s (2 3 /fc)s 90 therefore set ta1reg to 90 (5ah) the duty is to be set to 1/4: t 1/4 = 20 s 1/4 = 5 s 5 s (2 3 /fc)s 22 therefore, set ta0reg = 22 = 16h. 7 6 5 4 3210 ta01run 0 x x x ?000 stop tmra0 and tmra01 and clear it to 0. ta01mod 1 0 x x xx01 set the 8-bit ppg mode, and select t1 as input clock. ta0reg 0 0 0 1 0110 write 16h. ta1reg 0 1 0 1 1010 write 5ah. ta1ffcr x x x x 011x set ta1ff, enabling both inversion and the double buffer. 10 generates a negative logic pulse. p7cr x x ? ? ??1? p7fc x x ? ? x?1x set p71 as the ta1out pin. ta01run 1 x x x ?111 start tmra0 and tmra01 counting. x: don?t care, ? : no change tmp91c829 2006-03-15 91c829-100 (4) 8-bit pwm output mode this mode is only valid for tmra0. in this mode, a pwm pulse with the maximum resolution of 8 bits can be output. when tmra0 is used the pwm pulse is output on the ta1out pin (which is also used as p71). tmra1 can also be used as an 8-bit timer. the timer output is inverted when the up counter (uc0) matches the value set in the timer register ta0reg or when 2 n counter overflow occurs (n = 6, 7, or 8 as specified by ta01mod tmp91c829 2006-03-15 91c829-101 in this mode the value of the register buffer will be shifted into ta0reg if 2 n overflow is detected when the ta0reg double buffer is enabled. use of the double buffer facilitates th e handling of low duty ratio waves. q 2 up counter = q 2 up counter = q 1 q 1 q 2 q 3 shift into ta0reg match with ta0reg 2 n overflow ta0reg (value to be compared) register buffe r ta0reg (register buffer) write figure 3.8.22 register buffer operation example: to output the following pwm waves on the ta1out pin at fc = 36 mhz: 16.0 s 28.4 s * clock state system clock: high frequency (fc) clock gear: 1 (fc) prescaler clock: f fph to achieve a 28.4 s pwm cycle by setting t1 to (2 3 /fc)s (at fc = 36 mhz): 28.4 s (2 3 /fc)s 128 = 2 n therefore n should be set to 7. since the low-level period is 16.0 s when t1 = (2 3 /fc)s, set the following value for ta0reg: 16.0 s (2 3 /fc)s 72 = 48h msb lsb 7 6 5 4 3210 ta01run ? x x x ???0 stop tmra0 and clear it to 0. ta01mod 1 1 1 0 ??01 select 8-bit pwm mode (cycle: 2 7 ) and select t1 as the input clock. ta0reg 0 1 0 0 1000 write 48h. ta1ffcr x x x x 101x clear ta1ff to 0, enable the inversion and double buffer. p7cr x x ? ? ??1? p7fc x x ? ? x?1x set p71 and the ta1out pin. ta01run 1 x x x ?111 start tmra0 counting. x: don?t care, ? : no change tmp91c829 2006-03-15 91c829-102 table 3.8.3 pwm cycle at fc = 36 mhz pwm cycle 2 6 2 2 8 select prescaler clock tmp91c829 2006-03-15 91c829-103 3.9 16-bit timer/event counters (tmrb) the tmp91c829 incorporates multifunctional 16-bit timer/event counter (tmrb0) which has the following operation modes: ? 16-bit interval timer mode ? 16-bit event counter mode ? 16-bit programmable pulse generation (ppg) mode the timer/event counter channel consists of a 16-bit up counter, two 16-bit timer registers (one of them with a double-buffer structure), two 16-bit capture registers, two comparators, a capture input controller, a timer flip-flop and a control circuit. the timer/event counter is controlled by an 11-byte control sfr. this chapter consists of the following items: table 3.9.1 differences between tmrb0 channel spec tmrb0 tb0in0 (also used as p93) external clock/capture trigger input pins tb0in1 (also used as p94) tb0out0 (also used as p95) external pins timer flip-flop output pins tb0out1 (also used as p96) timer run register tb0run (0180h) timer mode register tb0mod (0182h) timer flip-flop control register tb0ffcr (0183h) tb0rg0l (0188h) tb0rg0h (0189h) tb0rg1l (018ah) timer register tb0rg1h (018bh) tb0cp0l (018ch) tb0cp0h (018dh) tb0cp1l (018eh) sfr (address) capture register tb0cp1h (018fh) tmp91c829 2006-03-15 91c829-104 3.9.1 block diagrams intenal data bus internal data bus run/ clear match detection 16-bit comparator (cp0) 16-bit up counte r (uc0) 16-bit time register tb0rg1h/l match detection count clock tb0mod tmp91c829 2006-03-15 91c829-105 3.9.2 operation of each block (1) prescaler the 5-bit prescaler generates the source clock for tmrb0. the prescaler clock ( t0) is divided clock (divided by 4) from selected clock by the register syscr0 |