![]() |
|
If you can't view the Datasheet, Please click here to try to view without PDF Reader . |
|
Datasheet File OCR Text: |
8 bit microcontroller tlcs-870/c series TMP86FM48
the information contained herein is subject to change without notice. 021023_d toshiba is continually working to improve the qua lity and reliability of its products. nevertheless, semiconductor devices in general can malfunction or fail due to their inherent electrical sensitivity and vulnerability to physical stress. it is the responsibility of the buyer, when utiliz ing toshiba products, to comply with the standards of safety in making a safe design for the entire sy stem, and to avoid situations in which a malfunction or failure of such toshiba products could cause loss of human life, bodily injury or damage to property. in developing your designs, please ensure that toshiba products are used within specified operating ranges as set forth in the most r ecent toshiba products specifications. also, please keep in mind the precauti ons and conditions set forth in the ? handling guide for semiconductor devices, ? or ? toshiba semiconductor reliability handbook ? etc. 021023_a the toshiba products listed in this document are intended for usage in general electronics applications (computer, personal equipment, of fice equipment, measuring equipment, industrial robotics, domestic appliances, etc.). these toshiba products are neither intended nor warranted for usage in equipment that requires extraordinarily high quality and/or reliability or a malfunction or failure of which may cause loss of human life or bodily injury ( ? unintended usage ? ). unintended usage include atomic energy control instruments, airplane or spaceship instruments, transportation in struments, traffic signal instruments, combustion control instruments, medical instrument s, all types of safety devices, etc. unintended usage of toshiba products listed in this document shall be made at the customer's own risk. 021023_b the products described in this document shall not be used or embedded to any downstream products of which manufacture, use and/or sale are prohib ited under any applicable laws and regulations. 060106_q the information contained herein is presented only as a guide for the applications of our products. no responsibility is assumed by toshiba for any infring ements of patents or other rights of the third parties which may result from its use. no license is granted by implication or otherwise under any patents or other rights of toshiba or the third parties. 070122_c the products described in this document are subject to foreign exchange and foreign trade control laws. 060925_e for a discussion of how the reliability of microcontro llers can be predicted, please refer to section 1.3 of the chapter entitled quality and reliabil ity assurance/handling precautions. 030619_s ? 2007 toshiba corporation all rights reserved TMP86FM48 2007-08-24 86fm48-1 cmos 8-bit microcontroller TMP86FM48ug/fg the TMP86FM48 is the high-speed, high-per formance and low powe r consumption 8-bit microcomputer, including flash, ram, multi-func tion timer/counter, serial interface (uart, sio, i 2 c), a 10-bit ad converter and two clock generators on chip. product no. flash (program area) flash (data area) ram package emulation chip TMP86FM48ug lqfp64-p-1010-0.50e TMP86FM48fg 32256 8 bits 512 8 bits 2.0 k 8 bits qfp64-p-1414-0.80c tmp86c948xb features ? 8-bit single chip microc omputer tlcs-870/c series ? instruction execution time: 0.25 s (at 16 mhz) 122 s (at 32.768 khz) ? 132 types and 731 basic instructions ? 20 interrupt sources (external: 5, internal: 15) ? input/output ports (54 pins) ? 16-bit timer counter: 2 ch ? timer, event counter, pulse width measurement, external trigger timer, window, ppg output modes ? 8-bit timer counter: 2 ch ? timer, event counter, pwm output, programmable divider output, capture modes ? time base timer ? divider output function ? watchdog timer ? interrupt source/internal rese t generate (programmable) lqfp64-p-1010-0.50e TMP86FM48ug qfp64-p-1414-0.80c TMP86FM48fg ? the information contained herein is subject to change without notice. 021023_d ? toshiba is continually working to improve the quality and reli ability of its products. nevertheless, semiconductor devices in general can malfunction or fail due to their inherent electrical sensitivity and vulnerability to physical stress. it is the responsibi lity of the buyer, when utilizing toshiba products, to comply with the standar ds of safety in making a safe design for the entire system, a nd to avoid situations in which a malfunction or failure of such toshiba products could cause loss of human life, bodily injury or damage to property. in developing your designs, please ensure that toshiba products are used within specified operating ranges as set forth in the most recent toshiba products specificati ons. also, please keep in mind the precautions and conditions set forth in the "handlin g guide for semiconductor devices," or "toshiba semiconductor reliability handbook" etc. 021023_a ? the toshiba products listed in this document are intended for usage in general electronics applic ations (computer, personal equipment, office equipment, measuring equipmen t, industrial robotics, domestic applianc es, etc.). these toshiba products are neither intended nor warranted for usage in equipment that require s extraordinarily high quality and/or reliability or a malfun ction or failure of which may cause loss of human life or bodily inju ry ("unintended usage"). unintended usage include atomic energy control instruments, airplane or spaceshi p instruments, transportation instruments, traffic signal instruments, combustion cont rol instruments, medical instruments, all types of safety devices , etc. unintended usage of toshiba products listed in this documen t shall be made at the customer's own risk. 021023_b ? the products described in this document shall not be used or embedded to any downstream products of which manufacture, use and/or sale are prohibited under any applicable laws and regulations. 060106_q ? the information contained herein is pres ented only as a guide for the applications of our products. no responsibility is assum ed by toshiba for any infringements of patents or other rights of the th ird parties which may result from its use. no license is gran ted by implication or otherwise under any patents or othe r rights of toshiba or the third parties. 070122_c ? the products described in this document are subjec t to foreign exchange and foreign trade control laws. 060925_e ? for a discussion of how the reliability of microcontrollers can be predicted, please refer to section 1.3 of the chapter entit led quality and reliability assurance/handling precautions. 030619_s TMP86FM48 2007-08-24 86fm48-2 ? serial interface ? uart/sio: 1ch ? sio: 1ch ? i 2 c bus: 1ch ? 10-bit successive approximation type ad converter ? analog input: 16 ch ? four key-on wake-up pins ? dual clock operation ? single/dual-clock mode ? nine power saving operating modes ? stop mode: oscillation stops. battery/capacitor back-up. port output hold/high-impedance. ? slow 1, 2 mode: low-power consumption oper ation using low-frequency clock (32.768 khz) ? idle 0 mode: cpu stops, and peripherals operate using high-frequency clock of time-base-timer. release by falling edge of tbtcr < tbtck > setting. ? idle 1 mode: cpu stops, and peripherals operate using high-frequency clock. release by interruputs. ? idle 2 mode: cpu stops, and peripherals operate using high and low-frequency clock. release by interruputs. ? sleep 0 mode: cpu stops, and peripherals operate using low-frequency clock of time-base-timer. release by falling edge of tbtcr < tbtck > setting. ? sleep 1 mode: cpu stops, and peripherals operate using low-frequency clock. release by interrupts. ? sleep 2 mode: cpu stops, and peripherals oper ate using high- and lo w-frequency clock. release by interrupts. ? wide operating voltage: 1.8 to 3.6 v at 8 mhz/32.768 khz 2.7 to 3.6 v at 16 mhz/32.768 khz TMP86FM48 2007-08-24 86fm48-3 pin assignments (top view) lqfp64-p-1010-0.50e qfp64-p-1414-0.80c 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 p80 p81 p82 p83 p84 p85 p86 p87 p30 p31 p32 p33 p34 p35 p36 p37 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 p77(ain17) p76 (ain16) p75 (ain15) p74 (ain14) p73 (ain13) p72 (ain12) p71 (ain11) p70 (ain10) p67 (ain07/stop3) p66 (ain06/stop2) p65 (ain05/stop1) p64 (ain04/stop0) p63 (ain03) p62 (ain02) p61 (ain01) p60 (ain00) 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 a vdd varef a vss/vass boot p52 p51 ( dvo /sda) p50 ( ppg /scl) p07 ( sck1 ) p06 (so1/txd) p05 (si1/rxd) p04 p03 (tc2) p02 (int2) p01 (int1) p00 ( int0 ) p17 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 vss xin xout test vdd (xtin) p21 (xtout) p22 ( stop / int5 ) p20 (so2) p10 (si2) p11 ( sck2 ) p12 ( pwm5 / pdo5 /tc5) p13 (int3/tc3) p14 (tc1) p15 p16 reset TMP86FM48 2007-08-24 86fm48-4 block diagram analog reference pins xin xout power supply resonator connecting p ins vdd vss address/data bus system control circuit standby control circuit (key-on wake-up) timing generator high frequency low frequency clock generator tlcs-870/c cpu data memory (ram) program memory (flash) interrupt controller i/o ports i/o ports avdd varef avss/vass p67 (ain07) p60 (ain00) p2 10-bit ad converter p6 p0 sio2 uart address/data bus to p3 reset input reset test pin test tc3 8-bit timer/counter tc5 tc1 16-bit timer/counter time base timer watchdog timer p07 to p00 p22 to p20 tc2 p1 p17 to p10 sio1 sio p5 p52 to p50 p37 to p30 i/o ports i2c p8 p87 to p80 p7 p77 (ain17) p70 (ain10) to data memory (flash) TMP86FM48 2007-08-24 86fm48-5 pin functions (1/2) pin name input/output functions p07 ( sck1 ) i/o (i/o) serial clock input/output 1 p06 (txd, so1) i/o (output) uart data output, serial data output 1 p05 (rxd, si1) i/o (input) uart data input, serial data input 1 p04 i/o p03 (tc2) i/o (input) timer counter 2 input p02 (int2) i/o (input) external interrupt 2 input p01 (int1) i/o (input) external interrupt 1 input p00 ( int0 ) i/o (input) 8-bit input/output port with latch. when used as a serial interface output or uart output, respective output latch (p0dr) should be set to ?1?. when used as an input port, an serial interface input, uart input, timer counter input or an external interrupt input, respective output control (p0outcr) should be cleared to ?0? after setting p0dr to ?1?. external interrupt 0 input p17 i/o p16 i/o p15 (tc1) i/o (input) timer counter 1 input p14 (tc3,int3) i/o (input) timer counter 3 input, external interrupt 3 input p13 ( pwm5 , pdo5 , tc5) i/o (i/o) pwm5 output, pdo5 output, timer/counter 5 input p12 ( sck2 ) i/o (i/o) serial clock input/output 2 p11 (si2) i/o (input) serial data input 2 p10 (so2) i/o (output) 8-bit input/output port with latch. when used as a timer/counter output or serial interface output, respective output latch (p1dr) should be set to ?1?. when used as an input port, a timer counter input, an external interrupt input or serial interface input, respective output control (p1outcr) should be cleared to ?0? after setting p1dr to ?1?. serial data output 2 p22 (xtout) i/o (output) p21 (xtin) i/o (input) resonator connecting pins (32.768 khz) for inputting external clock, xtin is used and xtout is opened. p20 ( int5 , stop ) i/o (input) 3-bit input/output port with latch. when used as an input port or an external interrupt input, respective output control (p2outcr) should be cleared to ?0? after setting output latch (p2dr) to ?1?. external interrupt input 5 or stop mode release signal input p37 to p30 i/o 8-bit input/output port with latch (n-ch high-current output). when used as an input port, respective output control (p3outcr) should be cleared to ?0? after setting output latch (p3dr) to ?1?. p52 i/o p51 ( dvo , sda) i/o (output,i/o) divider output/i 2 c bus serial data input/output p50 ( ppg , scl) i/o (output,i/o) 3-bit input/output port with latch (n-ch high-current output). when used as an input port or i 2 c bus interface input/output, respective output control (p5outcr) should be cleared to ?0? after setting output latch (p5dr) to ?1?. when used as a ppg output or divider output, respective p5dr should be set to ?1?. ppg output/i 2 c bus serial clock input/output p67 (ain07, stop3) i/o (input) stop 3 input p66 (ain06, stop2) i/o (input) stop 2 input p65 (ain05, stop1) i/o (input) stop 1 input p64 (ain04, stop0) i/o (input) stop 0 input p63 (ain03) i/o (input) p62 (ain02) i/o (input) p61 (ain01) i/o (input) p60 (ain00) i/o (input) 8-bit programmable input/output port (tri-state). each bit of this port can be individually configured as an input or an output under software control. when used as an input port, respective input/output control (p6cr1) should be cleared to ?0? after setting input control (p6cr2) to ?1?. when used as an analog input or key on wake up input, respective p6cr1 should be cleared to ?0? after clearing p6cr2 to ?0?. when used as a key on wake up input, stopcr TMP86FM48 2007-08-24 86fm48-6 pin functions (2/2) pin name input/output functions pin name p77 (ain17) i/o (input) p76 (ain16) i/o (input) p75 (ain15) i/o (input) p74 (ain14) i/o (input) p73 (ain13) i/o (input) p72 (ain12) i/o (input) p71 (ain11) i/o (input) p70 (ain10) i/o (input) 8-bit programmable input/output port (tri-state). each bit of this port can be individually configured as an input or an output under software control. when used as an input port, respective input/output control (p7cr1) should be cleared to ?0? after setting input control (p7cr2) to ?1?. when used as an analog input, respective p7cr1 should be cleared to ?0? after clearing p7cr2 to ?0?. ad converter analog inputs p87 to p80 i/o 8-bit input/output port with latch (n-ch high-current output). when used as an input port, respective output control (p8outcr) should be cleared to ?0? after setting output latch (p8dr) to ?1?. xin, xout input output resonator connecting pins for high-frequency clock. for inputting external clock, xin is used and xout is opened. reset input reset signal input test input test pin for out-going test. be fixed to low. boot input serial prom mode control input. when wr iting to flash memory, boot pin should be fixed to high level. vdd, vss power supply for operation varef analog reference voltage for ad conversion avdd ad circuit power supply avss/vass power supply ad circuit power supply/analog re ference gnd for ad conversion TMP86FM48 2007-08-24 86fm48-7 operational description 1. cpu core functions the cpu core consists of a cpu, a system cl ock controller, and an interrupt controller. this section provides a description of the cpu core, the program memory, the data memory, the external memory interface, and the reset circuit. 1.1 memory address map the TMP86FM48 memory consists of 5 bl ocks: flash memory, boot rom, ram, dbr (data buffer register) and sfr (special function register). they are all mapped in 64-kbyte address space. figure 1.1.1 shows the tmp86f m48 memory address map. the general-purpose registers are not assigned to the ram a ddress space. figure 1.1.1 memory address maps 1.2 program memory (flash) the TMP86FM48 has a 32 k 8 bits (address 8000 h to ffff h ) of program memory (flash). the area of 8000h to 81ffh can be used as a 512 8 bits data memory of flash. flash memory: flash memory includes: program memory (the area of 8000 h to 81ff h can be used as data memory.) vector table boot rom: flash writing program ram: random access memory includes: data memory stack sfr: special function register includes: i/o ports peripheral control registers peripheral status registers system control registers interrupt control registers program status word dbr: data buffer register includes: peripheral control registers peripheral status registers vector table for vector call instructions (16 vectors) vector table for interrupts/reset (16 vectors) vector table for interrupts (8 vectors) 0000 h 64 bytes 2048 bytes 128 bytes sfr ram dbr flash memory (program memory) 32176 bytes 32 bytes 32 b y tes 003f h 0040 h 083f h 1f80 h 1fff h 8000 h ffbf h ffc0 h ffdf h ffe0 h ffff h 16 bytes ffb0 h 2048 bytes boot rom 3800 h 3fff h 512 b y tes 81ff h 8200 h flash memory (data memory) TMP86FM48 2007-08-24 86fm48-8 1.3 data memory (ram) the TMP86FM48 has 2048 bytes of in ternal ram. the first 192 bytes (0040 h to 00ff h ) of the internal ram are located in the direct area; instructions with shorten operations are available against such an area. the data memory contents become unstable when the power supply is turned on; therefore, the data memory should be initialized by an initialization routine. example: clears ram to ?00h?. ld hl, 0040h ; start address setup ld a, h ; initial value (00h) setup ld bc, 07ffh ; sramclr: ld (hl), a inc hl dec bc jrs f, sramclr TMP86FM48 2007-08-24 86fm48-9 1.4 system clock controller the system clock controller consists of a clock generator, a timing generator, and a standby controller. figure 1.4.1 system clock control 1.4.1 clock generator the clock generator generates the basic clock which provides the system clocks supplied to the cpu core and peripheral hardware. it co ntains two oscillation circuits: one for the high-frequency clock and one for the low-frequency clock. power consumption can be reduced by switching of the standby controller to low-power operation based on the low-frequency clock. the high-frequency (fc) and low-frequency (fs) clocks can easily be obtained by connecting a resonator between the xin/xout and xtin/xto ut pins respectively. clock input from an external oscillator is also possible. in th is case, external clock is applied to xin/xtin pin with xout/xtout pin not connected. figure 1.4.2 examples of resonator connection note: the function to monitor the basic clock directly at external is not provided for hardware, however, with disabling all interrupts and wa tchdog timers, the oscillation frequency can be adjusted by monitoring the pulse which the fixed frequency is outputted to the port by the program. the system to require the adjustment of the oscillation frequency should create the program for the adjustment in advance. 0036 h timing generator control register 0038 h fc xout xin system clocks timing generator high-frequency clock oscillator standby controller clock generator control system control registers 0039 h syscr2 syscr1 tbtcr clock generator fs xtout xtin low-frequency clock oscillator xout xin (open) xout xin (a) crystal/ceramic resonator (b) external oscillator high-frequency clock xtout xtin (open) xtout xtin (c) crystal (d) external oscillator low-frequency clock TMP86FM48 2007-08-24 86fm48-10 1.4.2 timing generator the timing generator generates the various system clocks supplied to the cpu core and peripheral hardware from the basic clock (fc or fs). the timing generator provides the following functions. a. generation of main system clock b. generation of divider output ( dvo ) pulses c. generation of source cl ocks for time base timer d. generation of source clocks for watchdog timer e. generation of internal source clocks for timer/counters and serial interface f. generation of warm-up cloc ks for releasing stop mode (1) configuration of timing generator the timing generator consists of a 2-stag e prescaler, a 21-stage divider, a main system clock generator, an d machine cycle counters. an input clock to the 7th stage of the divider depends on the operating mode, tbtcr TMP86FM48 2007-08-24 86fm48-11 7 6 5 4 3 2 1 0 tbtcr (0036 h ) (dvoen) (dvock) dv7ck (tbten) (tbtck) (initial value: 0000 0000) dv7ck selection of input to the 7th stage of the divider 0: fc/2 8 [hz] 1: fs r/w note 1: in single clock mode, do not set dv7ck to ?1?. note 2: do not set ?1? on dv7ck while the low-frequency clock is not operated stably. note 3: fc: high-frequency clock [h z], fc: low-frequency clock [hz], * : don?t care note 4: in slow1/2 and sleep1/2 modes, the dv7ck setting is ineffective, and fs is input to the 7th stage of the divider. note 5: when stop mode is entered from normal 1/ 2 mode, the dv7ck setting is ineffective during the warm-up period after release of stop mode, and the 6th stage of the divider is input to the 7th stage during this period. figure 1.4.4 timing generator control register (2) machine cycle instruction execution and peripheral hardware operation are synchronized with the main system clock. the minimum instruction execution unit is called an ?machine cycle?. there are a total of 10 different types of instructions for the tlcs-870/c series: ranging from 1-cycle instructions which require one machine cycle for execution to 10-cycle instructions which require 10 machine cycles for execution. a machine cycle consists of 4 states (s0 to s3), and each state consists of one main system clock. figure 1.4.5 machine cycle 1/fc or 1/fs [s] main system clock state machine cycle s3 s2 s1 s0 s3 s2 s1 s0 TMP86FM48 2007-08-24 86fm48-12 1.4.3 operation mode control circuit the operation mode control circuit starts and stops the oscillation circuits for the high-frequency and low-frequency clocks, and switches the main system clock. there are two operating modes: single-clock and dual-clock. these modes are controlled by the system control registers (syscr1 and syscr2). figure 1.4.6 shows the operating mode transition diagram and figure 1.4.7 shows the system control registers. (1) single-clock mode only the oscillation circuit for the high-frequency clock is used, and p21 (xtin) and p22 (xtout) pins are used as input/output ports. the main-system clock is obtained from the high-frequency clock. in the single-clock mode, the machine cycle time is 4/fc [s]. a. normal1 mode in this mode, both the cpu core and on-chip peripherals operate using the high-frequency clock. the TMP86FM48 is placed in this mode after reset. b. idle1 mode in this mode, the internal oscillation circuit remains active. the cpu and the watchdog timer are halted; however on-chi p peripherals remain active (operate using the high-frequency clock). idle1 mode is started by syscr2 TMP86FM48 2007-08-24 86fm48-13 (2) dual-clock mode both the high-frequency and low-frequency oscillation circuits are used in this mode. p21 (xtin) and p22 (xtout) pins cannot be used as input/output ports. the main system clock is obtained from the high-frequency clock in normal2 and idle2 modes, and is obtained from the low-frequency clock in slow and sleep modes. the machine cycle time is 4/fc [s] in the no rmal2 and idle2 modes, and 4/fs [s] (122 s at fs = 32.768 khz) in the slow and sleep modes. the tlcs-870/c is placed in the single-clock mode during reset. to use the dual-clock mode, the low-frequency oscillator should be turned on at the start of a program. a. normal2 mode in this mode, the cpu core operates with the high-frequency clock. on-chip peripherals operate using the high-frequency clock and/or low-frequency clock. b. slow2 mode in this mode, the cpu core operates with the low-frequency clock, while both the high-frequency clock and the low-frequency clock are operated. on-chip peripherals are triggered by the low-frequency clock. as the sysck on syscr2 becomes ?0?, the hardware changes into normal2 mode. as the xen on syscr2 becomes ?0?, the hardware ch anges into slow1 mode. do not clear xten to ?0? during slow2 mode. c. slow1 mode this mode can be used to reduce power- consumption by turning off oscillation of the high-frequency clock. the cpu core and on-chip peripherals operate using the low-frequency clock. switching back and forth between slow1 and slow2 modes are performed by xen bit on the system cont rol register 2 (syscr2). in slow1 and sleep mode, the input clock to the 1st stage of the divide r is stopped; output from the 1st to 6th stages is also stopped. d. idle2 mode in this mode, the internal oscillation circuit remain active. the cpu and the watchdog timer are halted; however, on-chip peripherals remain active (operate using the high-frequency clock and/or the low-frequency clock). starting and releasing of idle2 mode are the same as for idle1 mode, except that operation returns to normal2 mode. e. sleep1 mode in this mode, the internal oscillation circuit of the low-frequency clock remains active. the cpu, the watchdog timer, and the internal oscillation circuit of the high-frequency clock are halted; however, on-chip peripherals remain active (operate using the low-frequency clock). starting and releasing of sleep mode are the same as for idle1 mode, except that operation returns to slow mode. in slow and sleep mode, the input clock to the 1st stage of the divider is stopped; output from the 1st to 6th stages is also stopped. TMP86FM48 2007-08-24 86fm48-14 f. sleep2 mode the sleep2 mode is the idle mode corresponding to the slow2 mode. the status under the sleep2 mode is same as that under the sleep1 mode, except for the oscillation circuit of the high-frequency clock. g. sleep0 mode in this mode, all the circuit, except oscillator and the time-base-timer, stops operation. this mode is enabled by setting ?1? on bit tghalt on the system control register 2 (syscr2). when sleep0 mode starts, the cpu stops and the timing generator stops feeding the clock to the peripheral circuits other than tbt. then, upon detecting the falling edge of the source clock selected with tbtcr TMP86FM48 2007-08-24 86fm48-15 note 1: normal1 and normal2 modes are generically called normal; slow1 and slow2 are called slow; idle0, idle1 and idle2 are called idle; sleep0, sleep1 and sleep2 are called sleep. note 2: the mode is released by falling edge of tbtcr TMP86FM48 2007-08-24 86fm48-16 system control register 1 7 6 5 4 3 2 1 0 syscr1 (0038 h ) stop relm retm outen wut (initial value: 0000 00 ** ) stop stop mode start 0: cpu core and peripherals remain active 1: cpu core and peripherals are halted (start stop mode) relm release method for stop pin (p20) 0: edge-sensitive release 1: level-sensitive release retm operating mode after stop mode 0: return to normal1/2 mode 1: return to slow1 mode outen port output during stop mode 0: high impedance 1: output kept return to normal mode return to slow mode wut warm-up time at releasing stop mode (note 8) 00 01 10 11 3 2 16 /fc 2 16 /fc 3 2 14 /fc 2 14 /fc + (2 10 /fc) + (2 10 /fc) + (2 10 /fc) + (2 10 /fc) 3 2 13 /fs 2 13 /fs 3 2 6 /fs 2 6 /fs + (2 3 /fs) + (2 3 /fs) + (2 3 /fs) + (2 3 /fs) r/w note 1: always set retm to ?0? when transiting from normal mode to stop mode. always set retm to ?1? when transiting from slow mode to stop mode. note 2: when stop mode is released with reset pin input, a return is made to normal1 regardless of the retm contents. note 3: fc: high-frequency clock [h z], fs: low-frequency clock [hz], *: don?t care note 4: bits 1 and 0 in syscr1 are read as undefined data when a read instruction is executed. note 5: as the hardware becomes stop mode under outen = ?0?, input value is fixed to ?0?; therefore it may cause interrupt request on account of falling edge. note 6: when the key-on wake-up input (stop0 to stop3) is used, relm should be set to ?1?. note 7: port p20 is used as stop pin. therefore, when stop mode is started, outen does not affect to p20, and p20 becomes high-z mode. note 8: when the stop mode is started with the eepcr TMP86FM48 2007-08-24 86fm48-17 1.4.4 operating mode control (1) stop mode stop mode is controlled by the system control register 1, the stop pin input and key-on wake-up input (stop0 to stop3) which is controlled by the stop mode release control register (stopcr). the stop pin is also used both as a port p20 and an int5 (external interrupt input 5) pin. stop mode is started by setting syscr1 TMP86FM48 2007-08-24 86fm48-18 example 1: starting stop mode from normal mode by testing a port p20. ld (syscr1), 01010000b ; sets up the level-sensitive release mode sstoph: test (p2prd). 0 ; wait until the stop pin input goes low level jrs f, sstoph set (syscr1).7 ; starts stop mode example 2: starting stop mode from normal mode with an int5 interrupt. pint5: test (p2prd). 0 ; to reject noise, stop mode does not start if port p20 is at high jrs f, sint5 ld (syscr1), 01010000b ; sets up the level-sensitive release mode. set (syscr1). 7 ; starts stop mode sint5: reti note: when the stop mode is started with the eepcr TMP86FM48 2007-08-24 86fm48-19 note: when the stop mode is started with the eepcr TMP86FM48 2007-08-24 86fm48-20 table 1.4.1 warm-up time example (at fc = 16.0 mhz, fs = 32.768 khz) warm-up time [ms] (note 2) wut return to normal mode return to slow mode 00 12.288 + (0.064) 750 + (0.244) 01 4.096 + (0.064) 250 + (0.244) 10 3.072 + (0.064) 5.85 + (0.244) 11 1.024 + (0.064) 1.95 + (0.244) note 1: the warm-up time is obtained by dividing the basic clock by the divider: therefore, the warm-up time may include a certain amount of error if there is any fluctuation of the oscillation frequency when stop mode is released. thus, the warm-up time must be considered an approximate value. note 2: the cpu wait period for flash is shown in parentheses. TMP86FM48 2007-08-24 86fm48-21 figure 1.4.10 stop mode st art/release (when eepcr TMP86FM48 2007-08-24 86fm48-22 figure 1.4.11 stop mode st art/release (when eepcr TMP86FM48 2007-08-24 86fm48-23 (2) idle1/2 mode, sleep1/2 mode idle1/2 and sleep1/2 modes are controlled by the system control register 2 (syscr2) and maskable interrupts. the following status is maintained during these modes. a. operation of the cpu and watchdog ti mer (wdt) is halted. on-chip peripherals continue to operate. b. the data memory, cpu registers, progra m status word and port output latches are all held in the status in effect before these modes were entered. c. the program counter holds the address 2 ahead of the instruction which starts these modes. note 1: eepcr TMP86FM48 2007-08-24 86fm48-24 ? start the idle1/2 and sleep1/2 modes when idle1/2 and sleep1/2 modes st art, set syscr2 TMP86FM48 2007-08-24 86fm48-25 figure 1.4.13 idle1/2, sleep1/2 mode start/release main system clock (a) idle1/2, sleep1/2 mode start (example: starting with the set instruction located at address a) a + 2 set (syscr2).4 operate a + 3 halt a + 4 instruction address a + 2 operate a + 3 halt halt halt halt a + 3 operate acceptance of interrupt (1) normal release mode (eepcr TMP86FM48 2007-08-24 86fm48-26 (3) idle0, sleep0 mode (idle0, sleep0) idle0 and sleep0 modes are controlled by th e system control register 2 (syscr2) and the time base timer control register (tbt cr). the following status is maintained during idle0 and sleep0 modes. a. timing generator stops feeding clock to peripherals except tbt. b. the data memory, cpu registers, progra m status word and port output latches are all held in the status in effect be fore idle0 and sleep0 modes were entered. c. the program counter holds the address 2 ahead of the instruction which starts idle0 and sleep0 modes. note: before starting idle0 or sleep0 m ode, be sure to stop (disable) periperals. figure 1.4.14 idle0, sleep0 mode reset ?0? no yes starting idle0, sleep0 mode by instruction cpu, wdt are halted interrupt processing execution of the instruction which follows the idle0, sleep0 mode start instruction (normal release mode) no ?1? (interrupt release mode) reset input tbt source clock falling edge yes imf yes ?0? no ?1? tbtcr TMP86FM48 2007-08-24 86fm48-27 ? start the idle0 and sleep0 modes stop (disable) peripherals such as a timer counter. when idle0 and sleep0 modes start, set syscr2 TMP86FM48 2007-08-24 86fm48-28 figure 1.4.15 idle0, sleep0 mode start/release main system clock (a) idle0, sleep0 mode start (example: starting with the set instruction located at address a) a + 2 set (syscr2).2 operate a + 3 halt a + 4 instruction address a + 2 operate a + 3 halt halt halt halt a + 3 operate acceptance of interrupt (1) normal release mode (eepcr TMP86FM48 2007-08-24 86fm48-29 (4) slow mode slow mode is controlled by the sy stem control register 2 (syscr2). the following is the methods to switch the mode with the warm-up counter (tc2). a. switching from normal2 mode to slow1 mode first, set syscr2 TMP86FM48 2007-08-24 86fm48-30 b. switching from slow1 mode to normal2 mode first, set syscr2 TMP86FM48 2007-08-24 86fm48-31 figure 1.4.16 switching between the normal2 and slow modes high-frequency clock low-frequency clock main system clock sysck xen instruction execution (a) switching to the slow mode clr (syscr2).7 set (syscr2).5 normal2 mode set (syscr2).7 (b) switching to the normal2 mode clr (syscr2).5 normal2 mode slow1 mode slow1 mode turn off slow2 mode warm up during slow2 mode high-frequency clock low-frequency clock main system clock sysck xen instruction execution TMP86FM48 2007-08-24 86fm48-32 1.5 interrupt control circuit the TMP86FM48 has a total (reset is excluded ) of 20 interrupt source: 5 externals and 15 internals. 4 of the internal sources are non-maskable interrupt s, and the rest of them are maskable interrupts. interrupt sources are provided with interrupt la tches (il), which hold interrupt requests, and independent vectors. the interrupt latch is set to ?1? by the generation of its interrupt request which requests the cpu to accept its interrupts. interrupts are enabled or disabled by software using the interrupt master enable flag (imf) and interrupt enable flag (ef). if more than one interrupts are generated simultaneously, interrupts are accepted in order which is dominated by hardware. however, there are no prioritized interrupt factors among non-maskable interrupts. table 1.5.1 interrupt sources interrupt factors enable condition interrupt latch vector address priority internal/external (reset) non-maskable ? fffe h high 1 internal intswi (software interrupt) non-maskable ? fffc h 2 internal intundef (executed the undefined instruction interrupt) non-maskable ? fffc h 2 internal intatrap (address trap interrupt) non-maskable il 2 fffa h 2 internal intwdt (watchdog ti mer interrupt) non-maskable il 3 fff8 h 2 external int0 (external interrupt 0) imf?ef 4 = 1 il 4 fff6 h 5 internal inttc1 (tc1 interrupt) imf?ef 5 = 1 il 5 fff4 h 6 external int1 (external interrupt 1) imf?ef 6 = 1 il 6 fff2 h 7 internal inttbt (time base timer interrupt) imf?ef 7 = 1 il 7 fff0 h 8 external int2 (external interrupt 2) imf?ef 8 = 1 il 8 ffee h 9 internal inttc3 (tc3 interrupt) imf?ef 9 = 1 il 9 ffec h 10 internal intsio1 (serial interface 1 interrupt) imf?ef 10 = 1il 10 ffea h 11 internal intsio2 (serial interface 2 interrupt) imf?ef 11 = 1il 11 ffe8 h 12 internal inttc5 (tc5 interrupt) imf?ef 12 = 1il 12 ffe6 h 13 external int3 (external interrupt 3) imf?ef 13 = 1il 13 ffe4 h 14 internal intadc (ad converter interrupt) imf?ef 14 = 1il 14 ffe2 h 15 reserved imf?ef 15 = 1il 15 ffe0 h 16 reserved imf?ef 16 = 1il 16 ffbe h 17 internal intsbi (serial bus interface interrupt) imf?ef 17 = 1il 17 ffbc h 18 internal intrxd (uart received interrupt) imf?ef 18 = 1il 18 ffba h 19 internal inttxd (uart transmitted interrupt) imf?ef 19 = 1il 19 ffb8 h 20 internal inttc2 (tc2 interrupt) imf?ef 20 = 1il 20 ffb6 h 21 external int5 (external interrupt 5) imf?ef 21 = 1il 21 ffb4 h 22 reserved imf?ef 22 = 1il 22 ffb2 h 23 reserved imf?ef 23 = 1il 23 ffb0 h 24 note 1: to use the watchdog timer interrupt (intwdt) , clear wdtcr1 TMP86FM48 2007-08-24 86fm48-33 figure 1.5.1 interrupt controller block diagram s r instruction which imf to ?0? internal reset write strobe for il 2 imf individual interrupt enable flag priority encoder & vector table address generato r q r s il 23 to il 2 write data interrupt acceptance idle1/2, sleep1/2 mode releease request interrupt request vector table address il 2 s r il 3 q il 4 [di] instru ction ef 23 to ef 4 eintcr external interrupt control re g iste r digital noise reject circuit [reti] instruction during maskable interrupt service [retn] instruction only when imf was set before interrupt was accepted instruction which sets imf to ?1? int5 int3 intadc intsio1 inttc3 intrxd inttc1 edge selction, digital noise reject circuit int2es int2 inttbt edge selction, digital noise reject circuit int1nc, int1es digital noise reject circuit int1 int0 intwdt int0en intswi intundef intatrap q [ei] instruction il 5 il 6 il 7 il 8 il 9 il 10 il 11 il 12 il 13 il 14 il 15 il 16 il 17 il 18 il 19 il 20 il 21 il 22 il 23 intsio2 inttc5 edge selction, digital noise reject circuit int3es inttxd inttc2 22 20 intsbi TMP86FM48 2007-08-24 86fm48-34 (1) interrupt latches (il 24 to il 2 ) an interrupt latch is provided for each interrupt source, except for a software interrupt. when interrupt request is generated, the latch is set to ?1?, and the cpu is requested to accept the interrupt if its interrupt is enabled. all interrupt latches are initialized to ?0? during reset. the interrupt latches are located on address 002e h, 003c h and 003d h in sfr area. except for il 3 and il 2 , each latch can be cleared to ?0? individually by instruction. (however, the read-modify-write instructions such as bit manipulation or operation instructions cannot be used. interrupt request wo uld be cleared inadequately if interrupt is requested while such instructions are ex ecuted.) thus interrupt request can be canceled/initialized by software. interrupt latches are not set to ?1? by an inst ruction. since interrupt latches can be read, the status for interrupt requests can be monitored by software. note: when manipulating il, clear imf (to disable interrupts) beforehand. example 1: clears interrupt latches di ; imf 0 ld (ile), 11110011b ; il 19 , il 18 0 ldw (ill), 1110100000111111b ; il 12 , il 10 to il 6 0 ei ; imf 1 example 2: reads interrupt latches ld wa, (ill) ; w il h , a il l example 3: tests an interrupt latches test (il).7 ; il 7 = 1 then jump jr f, sset (2) interrupt enable register (eir) the interrupt enable register (eir) enables and disables the acceptance of interrupts, except for the non-maskable interrupts (software interrupt, undefined instruction interrupt, address trap interrupt and watchdog interrupt). non-maskable interrupt is accepted regardless of the contents of the eir. the eir consists of an interrupt master enab le flag (imf) and the individual interrupt enable flags (ef). these registers are located on address 002c h, 003a h and 003b h in sfr area, and they can be read and written by an instructions (including read-modify-write instructions such as bit manipulation or operation instructions). a. interrupt master enable flag (imf) the interrupt enable register (imf) enables and disables the acceptance of the whole maskable-interrupt. while imf = ?0?, all maskable interrupts are not accepted regardless of the status on each individual interrupt enable flag (ef). by setting imf to ?1?, the interrupt becomes acceptable if the individuals are enabled. when an interrupt is accepted, imf is cleared to ?0? after the latest status on imf is stacked. thus the maskable interrupts which follow are disabled. by executing return interrupt instruction [reti/retn], the stacked data, which was the status before interrupt acceptance, is loaded on imf again. the imf is located on bit0 in eirl (address: 003a h in sfr), and can be read and written by an instruction. the imf is no rmally set and cleared by [ei] and [di] instruction respectively. during reset, the imf is initialized to ?0?, and maskable interrupts are not accepted until it is set to ?1?. TMP86FM48 2007-08-24 86fm48-35 b. individual interrupt enable flags (ef 23 to ef 4 ) each of these flags enables and disables the acceptance of its maskable interrupt. setting the corresponding bit of an individu al interrupt enable flag to ?1? enables acceptance of its interrupt, and setting the bit to ?0? disables acceptance. the individual interrupt enable flags (ef 23 to ef 4 ) are located on eire, eirl to eirh (address: 002c h , 003a h to 003b h in sfr), and can be read and written by an instruction. during reset, all the individual interrupt enable flags (ef 23 to ef 4 ) are initialized to ?0? and all maskable interrupts are not accepted until they are set to ?1?. note: before manipulating ef, be sure to clear imf (interrupt disabled). then set imf newly again after operating on the interrupt enables flag (ef). normally, imf is clear to ?0? automatically on service routine. when imf is set to ?1? for using a multiple interrupt on service routine, be sure to process as is the case with ef. example 1: enables interrupts individually and sets imf di ; imf 0 ld (eire), 00001100b ; ef 19 , ef 18 ?1? ldw (eirl), 0110100010100000b ; ef 14 , ef 13 , ef 11 , ef 7 , ef 5 ?1? note: imf is not set. ei ; imf ?1? example 2: c compiler description example unsigned int _io (3ah) eirl; ; / * 3ah shows eirl address * / _di ( ); eirl = 10100000b; _ei ( ); TMP86FM48 2007-08-24 86fm48-36 interrupt latches 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 il 15 il 14 il 13 il 12 il 11 il 10 il 9 il 8 il 7 il 6 il 5 il 4 il 3 il 2 il h (003d h ) il l (003c h ) (initial value: 00000000 000000 ** ) 23 22 21 20 19 18 17 16 il 23 il 22 il 21 il 20 il 19 il 18 il 17 il 16 il e (002e h ) (initial value: 00000000) il 23 to il 2 interrupt latches at rd 0: no interrupt request 1: interrupt request at wr clears the interrupt request (note 1) (interrupt latch is not set.) r/w note 1: il 2 and il 3 are prohibited from clearing. note 2: when manipulating il, clear im f (to disable interrupts) beforehand. note 3: do not clear il with read-modify-w rite instructions such as bit operations. interrupt enable registers 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 ef 15 ef 14 ef 13 ef 12 ef 11 ef 10 ef 9 ef 8 ef 7 ef 6 ef 5 ef 4 imf eir h (003b h ) eir l (003a h ) (initial value: 00000000 00000 *** 0) 23 22 21 20 19 18 17 16 ef 23 ef 22 ef 21 ef 20 ef 19 ef 18 ef 17 ef 16 eir e (002c h ) (initial value: 00000000) ef 23 to ef 4 individual-interrupt enable flag (specified for each bit) 0: disable the acceptance of each maskable interrupt. 1: enable the acceptance of each maskable interrupt. imf interrupt master enable flag 0: disable the acceptance of all maskable interrupts. 1: enable the acceptance of all maskable interrupts. r/w note 1: * : don?t care note 2: when manipulating ef, clear im f (to disable interrupts) beforehand. note 3: do not set imf to 1 simultaneously with ef15 to ef4. figure 1.5.2 interrupt latch (il) , interrupt enable registers (eir) ilh, ill (003c h , 003d h ) eirh, eirl (003a h , 003b h ) ile (002e h ) eire (002c h ) TMP86FM48 2007-08-24 86fm48-37 1.5.1 interrupt sequence an interrupt request, which raised interrupt la tch, is held, until interrupt is accepted or interrupt latch is cleared to ?0? by resetting or an instruction. interrupt acceptance sequence requires 8-machine cycles (4 s at 8.0 mhz) after the completion of the current instruction. the interrupt service task terminates upon execution of an interrupt return instruction [reti] (for maskable interrupts) or [retn] (for non-maskable interrupts). figure 1.5.3 shows the timing chart of interrupt acceptance processing. (1) interrupt acceptance proce ssing is packaged as follows. 1. the interrupt master enable flag (imf) is cleared to ?0? in order to disable the acceptance of any following interrupt. 2. the interrupt latch (il) for the interrupt source accepted is cleared to ?0?. 3. the contents of the program counter (pc) and the program status word, including the interrupt master enable flag (imf), are saved (pushed) on the stack in sequence of psw + imf, pch, pcl. meanwhile, the stack pointer (sp) is decremented by 3. 4. the entry address (interrupt vector) of the corresponding interrupt service program, loaded on the vector table, is transferred to the program counter. 5. the instruction stored at the entry address of the interrupt service program is executed. note: when the contents of psw are saved on the stack, the contents of imf are also saved. note 1: a: return address entry address, b: entry addr ess, c: address which reti instructrion is stored note 2: on condition that interrupt is enabled, it takes 38/fc [s ] or 38/fs [s] at maximum (if the interrupt latch is set at the first machine cycle on 10 cycle instruction) to st art interrupt acceptance processing since its interrupt latch is set. figure 1.5.3 timing chart of interrupt acceptance/return interrupt instruction execute instruction interrupt request interrupt latch (il) imf execute instruction pc sp 1-machine cycle interrupt service task interrupt acceptance execute reti instruction a ? 1 a a + 1 a b b + 1 b + 2 b + 3 c + 2 a a + 1 a + 2 c + 1 n n ? 1 n ? 2 n ? 3 n ? 2 n ? 1 n execute instruction TMP86FM48 2007-08-24 86fm48-38 example: correspondence between vector table address for inttbt and the entry address of the interrupt service program a maskable interrupt is not accepted until the imf is set to ?1? even if the maskable interrupt higher than the level of current servicing interrupt is requested. in order to utilize nested interrupt servic e, the imf is set to ?1? in the interrupt service program. in this case, acceptable interrupt sources are selectively enabled by the individual interrupt enable flags. to avoid overloaded nesting, clear the individual interrupt enable flag whose interrupt is currently serviced, before setting imf to ?1?. as for non-maskable interrupt, keep interrupt service shorter compared with length between interrupt requests; otherwise the status cannot be recovered as non-maskable interrupt would simply nested. (2) saving/restoring ge neral-purpose registers during interrupt acceptance processing, the program counter (pc) and the program status word (psw, includes imf) are automatically saved on the stack, but the accumulator and others are not. these regi sters are saved by so ftware if necessary. when multiple interrupt services are nested, it is also necessary to avoid using the same data memory area for saving registers. the following methods are used to save/restore the general-purpose registers. a. using push and pop instructions to save only a specific register, push and pop instructions are available. example: save/store register us ing push and pop instructions pintxx: push wa ; save wa register (interrupt processing) pop wa ; restore wa register reti ; return address (example) sp 023a h a 023b sp w sp 023c pc l pc l pc l 023d pc h pc h pc h 023e psw psw psw sp 023f at acceptance of an interrupt at execution of push instructin at execution of pop instructin at execution of an reti instruction 03 h d2 h vector table address fff0 h fff1 h 0f h 06 h entry address d203 h d204 h vecto r interrupt service program TMP86FM48 2007-08-24 86fm48-39 b. using data transfer instructions to save only a specific register without nested interrupts, data transfer instructions are available. example: save/store register us ing data transfer instructions pintxx: ld (gsava), a ; save a register (interrupt processing) ld a, (gsava) ; restore a register reti ; return figure 1.5.4 saving/restoring general-purpo se registers under interrupt processing (3) interrupt return interrupt return instructions [ reti]/[retn] perform as follows. [reti]/[retn] interrupt return 1. program counter (pc) and program status word (psw, includes imf) are restored from the stack. 2. stack pointer (sp) is incremented by 3. as for address trap interrupt (intartap), it is required to alter stacked data for program counter (pc) to restarting addr ess, during interrupt service program. otherwise returning interrupt causes inta trap again. when interrupt acceptance processing has complete d, stacked data for pc l and pc h are located on address (sp + 1) and (sp + 2) respectively. note: if [retn] is executed with the abov e data unaltered, the program returns to the address trap area and intatrap occurs again. saving registers restoring registers interrupt service task interrupt acceptance interrupt return main task saving/restoring general-purpose regist ers using push/pop instruction TMP86FM48 2007-08-24 86fm48-40 example 1: returning from address trap interrupt (intatrap) service program pintxx: pop wa ; recover sp by 2 ld wa, return address ; push wa ; alter stacked data (interrupt processing) retn ; return example 2: restarting without returning interrupt (i n this case, psw (includes imf) before interrupt acceptance is discarded.) pintxx inc sp ; recover sp by 3 inc sp ; inc sp ; (interrupt processing) ld eirl, data ; set imf to ?1? or clear it to ?0? jp restart address ; jump into restarting address note: it is recommended that stack pointer be return to rate before intatrap (increment 3 times), if return interrupt instruction [r etn] is not utilized during interrupt service program under intatrap (such as example 2). interrupt requests are sampled during th e final cycle of the instruction being executed. thus, the next interrupt can be accepted immediately after the interrupt return instruction is executed. note: when the interrupt processing time is longer than the interrupt request generation time, the interrupt service task is performed but not the main task. TMP86FM48 2007-08-24 86fm48-41 1.5.2 software interrupt (intsw) executing the [swi] instruction generates a software interrupt and immediately starts interrupt processing (intsw is highest prioritized interrupt). use the [swi] instruction only for detection of the address error or for debugging. (1) address error detection ff h is read if for some cause such as nois e the cpu attempts to fetch an instruction from a non-existent memory address during single chip mode. code ff h is the swi instruction, so a software interrupt is gene rated and an address error is detected. the address error detection range can be further expanded by writing ff h to unused areas of the program memory. address trap reset is generated in case that an instruction is fetched from ram or sfr areas. (2) debugging debugging efficiency can be increased by placing the swi instruction at the software break point setting address. 1.5.3 undefined instruction interrupt (intundef) taking code which is not defined as authorized instruction for instruction causes intundef. intundef is generated when th e cpu fetches such a code and tries to execute it. intundef is accepted even if non-maskable interrupt is in process. contemporary process is broken and intundef interrupt process starts , soon after it is requested. note: the undefined instruction in terrupt (intundef) forces cpu to jump into vector address, as software interrupt (swi) does. 1.5.4 address trap interrupt (intatrap) fetching instruction from unauthorized area for instructions (address trapped area) causes reset-output or address trap interrupt (intatrap). intatrap is accepted even if non-maskable interrupt is in process. contemporary process is broken and intatrap interrupt process starts, soon after it is requested. note: the operating mode under address trappe d, whether to be reset-output or interrupt processing, is selected on watchdog timer control register (wdtcr). 1.5.5 external interrupts the TMP86FM48 has five external interrupt inputs. these inputs are equipped with digital noise reject circuits (p ulse inputs of less than a certain time are eliminated as noise). edge selection is also possible with int1 to int3. int0 /p00 pin can be configured as either an external interrupt input pin or an input/output port, and is configured as an input port during reset. edge selection, noise reject control and int0 /p00 pin function selection are performed by the external interrupt control register (eintcr). TMP86FM48 2007-08-24 86fm48-42 table 1.5.2 external interrupts source pin secondary function pin enable conditions edge digital noise reject int0 0 int p00 imf = 1, ef 4 = 1, int0en = 1 falling edge pulses of less than 2/fc [s] are eliminated as noise. pulses of 7/fc [s] or more are considered to be signals. in the slow or the sleep mode, pulses of less than 1/fs [s] are eliminated as noise. pulses of 3.5/fs [s] or more are considered to be signals. int1 int1 p01 imf?ef 6 = 1 pulses of less than 15/fc or 63/fc [s] are eliminated as noise. pulses of 49/fc or 193/fc [s] or more are considered to be signals. in the slow or the sleep mode, pulses of less than 1/fs [s] are eliminated as noise. pulses of 3.5/fs [s] or more are considered to be signals. int2 int2 p02 imf?ef 8 = 1 int3 int3 p14/tc3 imf?ef 13 = 1 falling edge or rising edge pulses of less than 7/fc [s] are eliminated as noise. pulses of 25/fc [s] or more are considered to be signals. in the slow or the sleep mode, pulses of less than 1/fs [s] are eliminated as noise. pulses of 3.5/fs [s] or more are considered to be signals. int5 5 int p20/ stop imf?ef 21 = 1 falling edge pulses of less than 2/fc [s] are eliminated as noise. pulses of 7/fc [s] or more are considered to be signals. in the slow or the sleep mode, pulses of less than 1/fs [s] are eliminated as noise. pulses of 3.5/fs [s] or more are considered to be signals. note 1: if a noiseless signal is input to the external interrupt pin in the normal 1/2 or idle 1/2 mode, the maximum time from the edge of input signal until the il is set is as follows: (1) int1 pin 55/fc [s] (int1nc = 1), 199/fc [s] (int1nc = 0) (2) int2, int3 pin 31/fc [s] note 2: even if the falling edge of int0 pin input is detected at int0en = 0, the interrupt latch il 4 is not set. note 3: when data changed and did a change of i/o when used external interrupt ports as a normal ports, interrupt request signal occurs incorrectly. handling of prohibition of interrupt enable register (eir) is necessary. note 4: the maximum time from modifying int1 nc until a noise reject time is changed is 2 6 /fc. external interrupt control register 7 6 5 4 3 2 1 0 eintcr (0037 h ) int1nc int0en int3es int2es int1es (initial value: 00 ** 000 * ) int1nc noise reject time select 0: pulses of less than 63/fc [s] are eliminated as noise 1: pulses of less than 15/fc [s] are eliminated as noise int0en p00/ 0 int pin configuration 0: p00 input/output port 1: 0 int pin (port p00 should be set to an input mode) int3es int2es int1es int3 to int1 edge select 0: rising edge 1: falling edge r/w note 1: fc: high-frequency clock [hz], *: don?t care note 2: when the system clock frequency is switched betwe en high and low or when the external interrupt control register (eintcr) is overwritten, the noise cance ller may not operate normally. it is recommended that external interrupts are disabled using the interrupt enable register (eir). figure 1.5.5 external interrupt control register TMP86FM48 2007-08-24 86fm48-43 1.6 reset circuit the TMP86FM48 has four types of reset generation procedures: an external reset input, an address trap reset, a watchdog timer reset and a system clock re set. table 1.6.1 shows on-chip hardware initialization by reset action. since the reset circuit has an 11-stage counter fo r generation of flash reset, which is the reset counter for stabilizing of the power suppl y for flash, the reset period is 2 10 /fc [s] (64 s at 16.0 mhz). because the malfunction reset circuit such as watchdog timer reset, address trap reset and system clock reset is not initia lized when power is turned on, the reset operation occur for the maximum 24/fc [s] (1.5 s at 16.0 mhz). therefore, the maximum reset period is 24/fc [s] + 2 10 /fc [s] (65.5 s at 16.0 mhz). table 1.6.1 shows on-chip hardware initialization by reset action. table 1.6.1 initializing internal status by reset action on-chip hardware initial value on-chip hardware initial value program counter (pc) (fffe h ) stack pointer (sp) not initialized general-purpose registers (w, a, b, c, d, e, h, l, ix, iy) not initialized prescaler and divider of timing generator 0 jump status flag (jf) not in itialized watchdog timer enable zero flag (zf) not initialized carry flag (cf) not initialized half carry flag (hf) not initialized sign flag (sf) not initialized overflow flag (vf) not initialized interrupt master enable flag (imf) 0 output latches of i/o ports refer to i/o port circuitry interrupt individual enable flags (ef) 0 interrupt latches (il) 0 control registers refer to each of control register ram not initialized 1.6.1 external reset input the reset pin contains a schmitt trigger (hysteresi s) with an internal pull-up resistor. when the reset pin is held at ?l? level for at least 3 machine cycles (12/fc [s]) with the power supply voltage within the operating voltage range and oscillation stable, a reset is applied and the internal state is initialized. when 2 10 /fc (65.5 s at 16 mhz) period passes after the reset pin input goes high, the reset operation is released and the program execution starts at the vector address stored at addresses fffe h to ffff h . figure 1.6.1 reset circuit reset input reset vdd malfunction reset output circuit watchdog timer reset adddress trap reset system clock reset flash reset counter TMP86FM48 2007-08-24 86fm48-44 1.6.2 address-trap-reset if the cpu should start looping for some cause such as noise and an attempt be made to fetch an instruction from the on-chip ram (whe n wdtcr1 TMP86FM48 2007-08-24 86fm48-45 2. on-chip peripherals functions 2.1 special function register (sfr) the TMP86FM48 adopts the memory mapped i/o system, and all peripheral control and data transfers are performed through the special function register (sfr). the sfr is mapped on address 0000 h to 003f h , dbr is mapped on address 1f80 h to 1fff h . figure 2.1.1 to figure 2.1.2 indicate the special function register (sfr) and data buffer register (dbr) for TMP86FM48. address read write address read write 0000 h p0dr (p0 port output latch) 0020 h tc1dral (timer register 1a) 01 p1dr (p1 port output latch) 21 tc1drah (timer register 1a) 02 p2dr (p2 port output latch) 22 tc1drbl (timer register 1b) 03 p3dr (p3 port output latch) 23 tc1drbh (timer register 1b) 04 reserved 24 tc2drl (timer register 2) 05 p5dr (p5 port output latch) 25 tc2drh (timer register 2) 06 p6dr (p6 port output latch) 26 adcdr2 (ad result register 2) ? 07 p7dr (p7 port output latch) 27 adcdr1 (ad result register 1) ? 08 p8dr (p8 port output latch) 28 p6cr2 (p6 port input control) 09 reserved 29 reserved 0a p0outcr (p0 port output control) 2a p3outcr (p3 port output control) 0b p1outcr (p1 port output control) 2b reserved 0c p6cr1 (p6 port input/output control) 2c eir e (interrupt enable register) 0d p5outcr (p5 port output control) 2d reserved 0e adccr1 (ad control register 1) 2e il e (interrupt latch) 0f adccr2 (ad control register 2) 2f reserved 10 tc3dra (timer register 3a) 30 reserved 11 tc3drb (timer register 3b) ? 31 reserved 12 tc3cr (timer counter 3 control) 32 reserved 13 tc2cr (timer counter 2 control) 33 reserved 14 tc5cr (timer counter 5 control) 34 ? wdtcr1 (watchdog timer control) 15 tc5dr (timer register 5) 35 ? wdtcr2 (watchdog timer control) 16 reserved 36 tbtcr (tbt/tg/dvo control) 17 sio1cr (sio1 control) 37 eintcr (external interrupt control) 18 sio1sr (sio1 status) ? 38 syscr1 (system control 1) 19 sio1buf (sio1 data buffer) 39 syscr2 (system control 2) 1a reserved 3a eir l (interrupt enable register) 1b sio2cr (sio2 control) 3b eir h (interrupt enable register) 1c sio2sr (sio2 status) ? 3c il l (interrupt latch) 1d sio2buf (sio2 data buffer) 3d il h (interrupt latch) 1e reserved 3e reserved 1f tc1cr (timer counter 1 control) 3f psw (program status word) note 1: do not access reserved areas by the program. note 2: ? : cannot be accessed. note 3: write-only registers and interrupt latches cannot us e the read-modify-write instructions (bit manipulation instructions such as set, clr, etc. and logical op eration instructions such as and, or, etc.). figure 2.1.1 the special function register (sfr) for TMP86FM48 (1/2) TMP86FM48 2007-08-24 86fm48-46 address read write 1f80 h reserved d8 reserved d9 ? sbicra (sbi control 1) da sbidbr (sbi data buffer) db ? i2car (i2c address) dc sbisr (sbi status) sbicrb (sbi control 2) dd uartsr (uart status) uartcr1 (uart control 1) de ? uartcr2 (uart control 2) df rdbuf (uart received data buffer) tdbuf (uart transmit data buffer) e0 eepcr (flash control) e1 eepsr (flash status) ? e2 eepeva (flash write emulation time control) e3 reserved e4 p2outcr (p2 port output control) e5 p7cr1 (p7 port input/output control) e6 p7cr2 (p7 port input control) e7 p8cr (p8 port input/output control) e8 reserved e9 reserved ea reserved eb reserved ec reserved ed p0prd (p0 terminal input) ? ee p1prd (p1 terminal input) ? ef p2prd (p2 terminal input) ? f0 p3prd (p3 terminal input) ? f1 reserved f2 p5prd (p5 terminal input) ? f3 reserved f4 reserved f5 reserved f6 reserved f7 reserved f8 reserved f9 reserved fa reserved fb reserved fc reserved fd reserved fe ? stopcr (key-on wake-up control) ff reserved note 1: do not access reserved areas by the program. note 2: ? : cannot be accessed. note 3: write-only registers and interrupt latches cannot us e the read-modify-write instructions (bit manipulation instructions such as set, clr, etc. and logical op eration instructions such as and, or, etc.). figure 2.1.2 the special function register (sfr) for TMP86FM48 (2/2) TMP86FM48 2007-08-24 86fm48-47 2.2 i/o ports the TMP86FM48 has 8 parallel input/ou tput ports (54 pins) as follows. primary function secondary functions port p0 8-bit i/o port external interrupt input, serial interface input/output, uart input/output and timer/counter input . port p1 8-bit i/o port external interrupt inpu t, serial interface input/output and timer/counter input/output. port p2 3-bit i/o port low-frequency resonator c onnections, external interrupt input, stop mode release signal input. port p3 8-bit i/o port port p5 3-bit i/o port divider output, timer/c ounter output and serial bus interface input/output. port p6 8-bit i/o port analog input and stop mode release signal input. port p7 8-bit i/o port analog input. port p8 8-bit i/o port each output port contains a latch, which holds the output data. all input ports do not have latches, so the external input data should be externally held until the input data is read from outside or reading should be performed several times before processing. figure 2.2.1 shows input/output timing examples. external data is read from an i/o port in the s1 state of the read cycle during execution of the read instruction. this timing cannot be recognized from outside, so that transient input such as chattering must be processed by the program. output data changes in the s2 state of the write cycle during execution of the instruction which writes to an i/o port. note: the positions of the read and write cy cles may vary, depending on the instruction. figure 2.2.1 input/output timing (example) ex: ld a, (x) fetch cycle read cycle fetch cycle s0 s1 s2 s3 s0 s1 s2 s3 s0 s1 s2 s3 instruction execution cycle input strobe data input (a) input timing (b) output timing ex: ld (x), a fetch cycle read cycle fetch cycle s0 s1 s2 s3 s0 s1 s2 s3 s0 s1 s2 s3 instruction execution cycle output strobe data output old new TMP86FM48 2007-08-24 86fm48-48 2.2.1 port p0 (p07 to p00) port p0 is an 8-bit input/output port which is also used as an external interrupt input, serial interface input/output, timer/counter input and uart input/output. it can be selected whether output circuit of p0 port is cmos output or a sink open drain individually, by setting the output circuit control (p0out cr). when a corresponding bit of p0outcr is cleared to ?0?, the output circuit is selected to a sink open drain and when a corresponding bit of p0outcr is set to ?1?, the output circuit is selected to a cmos output. when used as an input port or a secondar y function input (external interrupt input, serial interface input, timer/counter input or uart input), the respective output latch (p0dr) should be set to ?1? and its corresponding p0outcr bit should be cleared to ?0?. when used as a secondary function output (serial interface output or uart output), the respective p0dr should be set to ?1?. during reset, the p0dr is initialized to ?1? and p0outcr is initialized to ?0?. p0 port output latch (p0dr) and p0 port terminal input (p0prd) are located on their respective address. when read the output latch data, the p0dr should be read and when read the terminal input data, the p0prd register should be read. 7 6 5 4 3 2 1 0 p0dr (0000 h ) r/w p07 sck1 p06 txd so1 p05 rxd si1 p04 p03 tc2 p02 int2 p01 int1 p00 int0 (initial value: 1111 1111) p0outcr (000a h ) (initial value: 0000 0000) p0outcr port p0 output circuit control (set for each bit individually) 0: sink open-drain output 1: cmos output r/w p0prd (1fed h ) p07 p06 p05 p04 p03 p02 p01 p00 read only figure 2.2.2 port 0 d q p0outcri p0i note: i = 7 to 0 d q output latch data input (p0prd) p0outcri input stop outen control output data output (p0dr) control input data input (p0dr) TMP86FM48 2007-08-24 86fm48-49 2.2.2 port p1 (p17 to p10) port p1 is a 8-bit input/output port which is also used as an external interrupt input, serial interface input/output and timer/counte r input/output. it can be selected whether output circuit of p1 port is cmos output or a sink open drain individually, by setting the output circuit control (p1outcr ). when a corresponding bit of p1outcr is cleared to ?0?, the output circuit is selected to a sink open drain and when a corresponding bit of p1outcr is set to ?1?, the output ci rcuit is selected to a cmos output. when used as an input port or a secondar y function input (external interrupt input, serial interface input, timer/counter input), th e respective output latch (p1dr) should be set to ?1? and its corresponding p1outcr bit should be cleared to ?0?. when used as a secondary function output (serial interface output or timer/counter output), the respective p1dr should be set to ?1?. during reset, the p1dr is initialized to ?1? and p1outcr is initialized to ?0?. p1 port output latch (p1dr) and p1 port terminal input (p1prd) are located on their respective address. when read the output latch data, the p1dr should be read and when read the terminal input data, the p1prd register should be read. 7 6 5 4 3 2 1 0 p1dr (0001 h ) r/w p17 p16 p15 tc1 p14 tc3 int3 p13 tc5 pwm5 pdo5 p12 sck2 p11 si2 p10 so2 (initial value: 1111 1111) p1outcr (000b h ) (initial value: 0000 0000) p1outcr port p1 output circuit control (set for each bit individually) 0: sink open-drain output 1: cmos output r/w p17 p16 p15 p14 p13 p12 p11 p10 p1prd (1feeh) read only figure 2.2.3 port 1 dq p1outcri p1i note: i = 7 to 0 dq output latch data input (p1prd) p1outcri input stop outen control output data output (p1dr) control input data input (p1dr) TMP86FM48 2007-08-24 86fm48-50 2.2.3 port p2 (p22 to p20) port p2 is a 3-bit input/output port. it is al so used as an external interrupt, a stop mode release signal input, and low-frequency crystal oscillator connection pins. it can be selected whether output circuit of p2 port is cmos (p21 and p22 have a pull-up resistor) output or a sink open drain individually, by setting the output circuit control (p2outcr). when a corresponding bit of p2outcr is cl eared to ?0?, the output circuit is selected to a sink open drain and when a corresponding bit of p2outcr is set to ?1?, the output circuit is selected to a cmos output. (in case of p21 and p 22, the pull-up resistor is connected.) when used as an input port or an external interrupt input, the respective output latch (p2dr) should be set to ?1?. during reset, the p2dr initialized to ?1? and p2outcr is initialized to ?0?. a low-frequency crystal oscillator (32.768 khz) is connected to pins p21 (xtin) and p22 (xtout) in the dual-clock mode. in the single-c lock mode, pins p21 and p22 can be used as normal input/output ports. it is recommended that pin p20 should be used as an external interrupt input, a stop mode release signal input, or an input port. if it is used as an output port, the interrupt latch is set on the falling edge of the output pulse. p2 port output latch (p2dr) and p2 port terminal input (p2prd) are located on their respective address. when read the output latch data, the p2dr should be read and when read the terminal input data, the p2prd register should be read. if a read instruction is executed for port p2 dr, p2outcr and p2prd, read data of bits 7 to 3 are unstable. note: when xten TMP86FM48 2007-08-24 86fm48-51 note: port p20 is used as stop pin. therefore, when stop mode is started, outen does not affect to p20, and p20 becomes high-z state. 7 6 5 4 3 2 1 0 p2dr (0002 h ) r/w p22 xtout p21 xtin p20 int5 stop (initial value: **** * 111) * : don?t care p2outcr (1fe4 h ) (initial value: **** * 000) * : don?t care 0: sink open-drain output p20 pin p21, p22 ports p2outcr port p2 output circuit control (set for each bit individually) 1: cmos output cmos output with pull-up resistor r/w p2prd (1fef h ) p22 p21 p20 read only figure 2.2.5 port 2 (p20) data input (p20prd) p20 ( int5 , stop ) dq data input (p20) data output (p20) output latch dq p2outcr p2outcr input int5 , stop input stop TMP86FM48 2007-08-24 86fm48-52 2.2.4 port p3 (p37 to p30) port p3 is an 8-bit input/output port. it can be selected whether outp ut circuit of p3 port is cmos output or a sink open drain individu ally, by setting p3outcr. (n-ch high current output) when a corresponding bit of p3outcr is cleared to ?0?, the output circuit is selected to a sink open drain and when a corr esponding bit of p3outcr is set to ?1?, the output circuit is selected to a cmos output. when used as an input port, the respective output latch (p3dr) should be set to ?1? and its corresponding p3outcr bit should be cleared to ?0?. during reset, the p3dr is initialized to ?1?, and the p3outcr is initialized to ?0?. p3 port output latch (p3dr) and p3 port terminal input (p3prd) are located on their respective address. when read the output latch data, the p3dr should be read and when read the terminal input data, the p3prd register should be read. 7 6 5 4 3 2 1 0 p3dr (0003 h ) r/w p37 p36 p35 p34 p33 p32 p31 p30 (initial value: 1111 1111) p3outcr (002a h ) (initial value: 0000 0000) p3outcr port p3 output circuit control (set for each bit individually) 0: sink open-drain output 1: cmos output r/w p3prd (1ff0 h ) p37 p36 p35 p34 p33 p32 p31 p30 read only figure 2.2.6 port 3 d q p3outcri p3i note: i = 7 to 0 output latch data input (p3prd) p3outcri input stop outen data output (p3dr) data input (p3dr) d q TMP86FM48 2007-08-24 86fm48-53 2.2.5 port p5 (p52 to p50) port p5 is an 3-bit input/output port which is also used as a timer/counter output, divider output and serial bus interface input/output. (n-ch high current output) it can be selected whether output circuit of p5 port is cmos output or a sink open drain individually, by setting the output circuit control (p5outcr). when a corresponding bit of p5outcr is cleared to ?0?, the output circuit is selected to a sink open drain and when a corresponding bit of p5outcr is set to ?1?, the output circuit is selected to a cmos output. when used as an input port or a serial bus interface input/output, the respective output latch (p5dr) should be set to ?1? and its corresponding p5outcr bit should be cleared to ?0?. when used as a secondary function output (timer/counter output or divider output), the respective p5dr should be set to ?1?. when used as a serial bus interface input/output, p5dr of p50 and p51 should be set to ?1? and p5outcr of p50 and p51 should be cleared to ?0? as a sink open drain output. during reset, the p5dr is initialized to ?1? and p5outcr is initialized to ?0?. p5 port output latch (p5dr) and p5 port terminal input (p5prd) are located on their respective address. when read the output latch data, the p5dr should be read and when read the terminal input data, the p5prd register should be read. if a read instruction is executed for p5dr, p5outcr and p5prd, read data of bits 7 to 3 are unstable. 7 6 5 4 3 2 1 0 p5dr (0005 h ) r/w p52 p51 dvo sda p50 ppg scl (initial value: **** * 111) * : don?t care p5outcr (000d h ) (initial value: **** * 000) * : don?t care p5outcr port p5 output circuit control (set for each bit individually) 0: sink open-drain output 1: cmos output r/w p5prd (1ff2 h ) p52 p51 p50 read only figure 2.2.7 port 5 d q p5outcri p5i note: i = 2 to 0 d q output latch data input (p5prd) p5outcri input stop outen control output data output (p5dr) data input (p5dr) TMP86FM48 2007-08-24 86fm48-54 2.2.6 port p6 (p67 to p60) port p6 is an 8-bit input/output port which can be configured as an input or an output in one-bit unit. port p6 is also used as an analog input and key-on wake-up input. input/output mode is specified by the p6 co ntrol register (p6cr1). p6 port input is controlled by the input co ntrol register (p6cr2). when used as an output port, respec tive p6cr1 should be set to ?1?. when used as an input port, respective p6cr 1 should be cleared to ?0? and respective p6cr2 should be set to ?1?. when used as an analog input, respective p6cr2 should be cleared to ?0? after respective p6cr1 is cleared to ?0?. when used as a key on wake up input, respective stopken TMP86FM48 2007-08-24 86fm48-55 7 6 5 4 3 2 1 0 p6dr (0006 h ) r/w p67 ain07 stop3 p66 ain06 stop2 p65 ain05 stop1 p64 ain04 stop0 p63 ain03 p62 ain02 p61 ain01 p60 ain00 (initial value: 0000 0000) p6cr1 (000c h ) (initial value: 0000 0000) p6cr1 port p6 i/o control (set for each bit individually) 0: input mode or analog input 1: output mode r/w p6cr2 (0028 h ) (initial value: 1111 1111) p6cr2 port p6 input control (set for each bit individually) 0: input disable 1: input enable r/w note 1: do not set output mode to pin which is used for an analog input. note 2: if both p6cr1 and p6cr2 are cleared to ?0?, the read value of p6dr is always ?0?. figure 2.2.9 port 6 (p67 to p64) note 1: j = 7 to 4, k = 3 to 0 note 2: sain is bit0 to 3 in adccr1 note 3: stopken is bit 7 to 4 in stopcr. stopken d q p6cr1j p6cr1j input p6 j d q data input (p6dr) data output (p6dr) analog input stopk input ainds sain stop outen p6cr2j p6cr2j input d q TMP86FM48 2007-08-24 86fm48-56 2.2.7 port p7 (p77 to p70) port p7 is an 8-bit input/output port which can be configured as an input or an output in one-bit unit. port p7 is also used as an analog input. input/output mode is specified by the p7 control register (p7cr1). p7 port input is controlled by the input control register (p7cr2). when used as an output port, respec tive p7cr1 should be set to ?1?. when used as an input port, respective p7cr 1 should be cleared to ?0? and respective p7cr2 should be set to ?1?. when used as an analog input, respective p7cr2 should be cleared to ?0? after respective p7cr1 is cleared to ?0?. during reset, the p7cr1 and p7dr are initialized to ?0?, and the p7cr2 is initialized to ?1?. table 2.2.3 shows a p7 state. table 2.2.3 p7 port state p7cr1 p7cr2 p7dr p7dr read output remark 0 0 * ?0? high-z ? 0 1 * terminal input high-z input mode 1 * 0 ?0? (output latch) low output mode 1 * 1 ?1? (output latch) high output mode * : don?t care. TMP86FM48 2007-08-24 86fm48-57 7 6 5 4 3 2 1 0 p7dr (0007 h ) r/w p77 ain17 p76 ain16 p75 ain15 p74 ain14 p73 ain13 p72 ain12 p71 ain11 p70 ain10 (initial value: 0000 0000) p7cr1 (1fe5 h ) (initial value: 0000 0000) p7cr1 port p7 i/o control (set for each bit individually) 0: input mode 1: output mode r/w p7cr2 (1fe6 h ) (initial value: 1111 1111) p7cr2 port p7 input control (set for each bit individually) 0: input disable 1: input enable r/w note 1: do not set output mode to pin which is used for an analog input. note 2: if both p7cr1 and p7cr2 are cleared to ?0?, the read value of p7dr is always ?0?. figure 2.2.10 port 7 d q p7cr1i p7cr1i input p7i d q data input (p7dr) data output (p7dr) analog input ainds sain stop outen p7cr2i p7cr2i input d q note 1: i = 7 to 0 note 2: sain is bit0 to 3 in adccr1 TMP86FM48 2007-08-24 86fm48-58 2.2.8 port p8 (p87 to p80) port p8 is an 8-bit input/output port which can be configured as an input or an output in one-bit unit. input/output mode is specified by the p8 control register (p8cr). when used as an output port, respec tive p8cr should be set to ?1?. when used as an input port, respective p8cr should be cleared to ?0?. during reset, the p8cr and p8dr are initialized to ?0?. table 2.2.4 shows a p8 state. table 2.2.4 p8 port state p8cr p8dr p8dr re ad output remark 0 * terminal input high-z input mode 1 0 ?0? (output latch) low output mode 1 1 ?1? (output latch) high output mode * : don?t care. 7 6 5 4 3 2 1 0 p8dr (0008 h ) r/w p87 p86 p85 p84 p83 p82 p81 p80 (initial value: 0000 0000) p8cr (1fe7 h ) (initial value: 0000 0000) p8cr port p8 i/o control (set for each bit individually) 0: input mode or analog input 1: output mode r/w figure 2.2.11 port 8 d q p8cri p8cri input p8i d q data input (p8dr) data output (p8dr) stop outen note: i = 7 to 0 TMP86FM48 2007-08-24 86fm48-59 2.3 time base timer (tbt) the time base timer generates time base for key scanning, dynamic displa ying, etc. it also provides a time base timer interrupt (inttbt). an inttbt is generated on the first falling edge of source clock (the divider output of the timing generator) after the time base timer has b een enabled. the divider is not cleared by the program; therefore, only the first interrupt may be generated ahead of the set interrupt period (figure 2.3.1 (b)). the interrupt frequency (tbtck) must be selected with the time base timer disabled (the interrupt frequency must not be changed with the disable from the enable state). both frequency selection and enabling can be performed simultaneously. figure 2.3.1 time base timer example: sets the time base timer frequency to fc/2 16 [hz] and enables an inttbt interrupt. ld (tbtcr), 00000010b ; tbtck 010 ld (tbtcr), 00001010b ; tbten 1 di ; imf 0 set (eirl). 6 interrupt period source clock enable tbt tbten inttbt (b) time base timer interrupt 3 tbtcr a b c d e f g h idle0/sleep0 release request fc/2 23 or fs/2 15 fc/2 21 or fs/2 13 fc/2 16 or fs/2 8 fc/2 14 or fs/2 6 fc/2 13 or fs/2 5 fc/2 12 or fs/2 4 fc/2 11 or fs/2 3 fc/2 9 or fs/2 time base timer control register tbtck tbten (a) configuration source clock falling edge detector inttbt interrupt request y s mpx: multiplexer mpx TMP86FM48 2007-08-24 86fm48-60 7 6 5 4 3 2 1 0 tbtcr (0036 h ) (dvoen) (dvock) (dv7ck) tbten tbtck (initial value: 0000 0000) tbten time base timer enable/disable 0: disable 1: enable normal1/2, idle1/2 mode dv7ck = 0dv7ck = 1 slow, sleep mode tbtck time base timer interrupt frequency select [hz] 000 001 010 011 100 101 110 111 fc/2 23 fc/2 21 fc/2 16 fc/2 14 fc/2 13 fc/2 12 fc/2 11 fc/2 9 fs/2 15 fs/2 13 fs/2 8 fs/2 6 fs/2 5 fs/2 4 fs/2 3 fs/2 fs/2 15 fs/2 13 ? ? ? ? ? ? r/w note: fc: high-frequency clock [hz ], fs: low-frequency clock [hz], * : don?t care figure 2.3.2 time base timer control register table 2.3.1 time base timer interrupt frequency (example: fc = 16 mhz, fs = 32.768 khz) time base timer interrupt frequency [hz] normal1/2, idle1/2 mode tbtck dv7ck = 0 dv7ck = 1 slow, sleep mode 000 1.91 1 1 001 7.63 4 4 010 244.14 128 ? 011 976.56 512 ? 100 1953.13 1024 ? 101 3906.25 2048 ? 110 7812.5 4096 ? 111 31250 16384 ? TMP86FM48 2007-08-24 86fm48-61 intwdt r s q q fc/2 23 or fs/2 15 fc/2 21 or fs/2 13 fc/2 19 or fs/2 11 fc/2 17 or fs/2 9 clock overflow interrupt request wdtout writing clear code writing disable code wdten wdtt 2 s r 0035 h 0034 h watchdog timer control registers reset release signal from t.g clea r wdt output internal reset a b c d 1 2 binary counters wdtcr2 controller wdtcr1 s y mpx mpx: multiplexer reset request 2.4 watchdog timer (wdt) the watchdog timer is a fail-safe system to rapidly detect the cpu malfunctions such as endless looping caused by noise or the like, or deadlock and resume the cpu to the normal state. the watchdog timer signal for detecting malfunction can be selected either a ?reset request? or a non-maskable ?interrupt request?. however, selection is possible only once after reset. at first the ?reset request? is selected. when the watchdog timer is not being used for malfunction detection, it can be used as a timer to generate an inte rrupt at fixed intervals. note: care must be given in system design so as to protect the watchdog timer from disturbing noise. otherwise the watchdog timer may not fully exhibit its functionality. 2.4.1 watchdog timer configuration figure 2.4.1 watchdog timer configuration TMP86FM48 2007-08-24 86fm48-62 2.4.2 watchdog timer control figure 2.4.2 shows the watchdog timer co ntrol registers (wdt cr1, wdtcr2). the watchdog timer is automati cally enabled after reset. (1) malfunction detection methods using the watchdog timer the cpu malfunction is detected as follows. 1. setting the detection time, selecting ou tput, and clearing the binary counter. 2. repeatedly clearing the binary count er within the setting detection time if the cpu malfunctions such as endless looping or deadlock occur for any cause, the watchdog timer output will become active at the rising of an overflow from the binary counters unless the binary counters ar e cleared. at this time, when wdtcr1 TMP86FM48 2007-08-24 86fm48-63 watchdog timer register 1 7 6 5 4 3 2 1 0 wdtcr1 (0034 h ) (atas) (atout) wdten wdtt wdtout (initial value: ** 11 1001) wdten watchdog timer enable/disable 0: disable (it is necessary to write the disable code to wdtcr2) 1: enable normal1/2 mode dv7ck = 0dv7ck = 1 slow mode wdtt watchdog timer detection time [s] 00 01 10 11 2 25 /fc 2 23 /fc 2 21 /fc 2 19 /fc 2 17 /fs 2 15 /fs 2 13 /fs 2 11 /fs 2 17 /fs 2 15 /fs 2 13 /fs 2 11 /fs wdtout watchdog timer output select 0: interrupt request 1: reset request write only note 1: wdtout cannot be set to ?1? by program after clearing wdtout to ?0?. note 2: fc: high-frequency clock [h z], fs: low-frequency clock [hz], * : don?t care note 3: wdtcr1 is a write-only register and must not be used with any of read-modify-write instructions. note 4: the watchdog timer must be disabled or the coun ter must be cleared immediately before entering to the stop mode. when the counter is cleared, the counter must be cleared again immediately after releasing the stop mode. note 5: to disable the watchdog timer, always write ?4e h ? (clear code) to wdtcr2 for clearing the binary counter before writing ?0? to wdten, and then write ?b1 h ? (disable code) to wdtcr2. also, immediately before these proc edure, disable the interrupt mater flag (imf) by di instruction. watchdog timer register 2 7 6 5 4 3 2 1 0 wdtcr2 (0035 h ) (initial value: **** **** ) wdtcr2 watchdog timer control code write register 4e h : watchdog timer binary counter clear (clear code) b1 h : watchdog timer dis able (disable code) d2 h : enable assigning address trap area others: invalid write only note 1: the disable code is invali d unless written when wdtcr1 TMP86FM48 2007-08-24 86fm48-64 example: disables watchdog timer di ; imf 0 ld (wdtcr2), 4eh ; clear the binary counter ldw (wdtcr1), 0b101h ; wdten 0, wdtcr2 disable code table 2.4.1 watchdog timer detection time (example: fc = 16 mhz, fs = 32.768 khz) watchdog timer detection time [s] normal1/2 mode wdtt dv7ck = 0 dv7ck = 1 slow mode 00 01 10 11 2.097 524.288 m 131.072 m 32.768 m 4 1 250 m 62.5 m 4 1 250 m 62.5 m 2.4.3 watchdog timer interrupt (intwdt) this is a non-maskable interrupt which can be accepted regardless of the contents of the eir. if a watchdog timer interrupt or a softwa re interrupt is already accepted, however, the new watchdog timer interrupt waits until the pr evious interrupt processing is completed (the end of the [retn] instruction execution). the stack pointer (sp) should be initialized before using the watchdog timer output as an interrupt source with wdtout. example: watchdog timer interrupt setting up ld sp, 023fh ; sets the stack pointer ld (wdtcr1), 00001000b ;wdtout 0 2.4.4 watchdog timer reset if the watchdog timer reset request occur, a reset is generated and the internal hardware is reseted. when the watchdog timer reset is generated, the flash reset is also generated. therefore, the maximum reset period is 24/fc [s] + 2 10 /fc [s] (65.5 s at 16.0 mhz). note: the high-frequency clock oscillator also immediately turns on when a watchdog timer reset is generated in slow mode. in this case, the reset time may include a certain amount of error if there is any fluctuation of the oscilla tion frequency at starting the high-frequency clock oscillation. therefor e, the reset time must be considered an approximated value. figure 2.4.3 watchdog timer interrupt/reset (wdtt = 11 b ) clock binary counter overflow intwdt interrupt (wdtcr1 TMP86FM48 2007-08-24 86fm48-65 2.5 address trap the watchdog timer control register 1, 2 shares its addresses with the control registers in case of address trap. these control registers for address trap are shown on figure 2.5.1. watchdog timer control register 1 7 6 5 4 3 2 1 0 wdtcr1 (0034 h ) ? ? atas atout (wdten) (wdtt) (wdtout) (initial value: ** 11 1001) atas selection of address trap in internal ram 0: no address trap 1: address trap (after setting atas to ?1?, it is necessary to write the control code d2 h to wdtcr2) atout selection of operation at address trap 0: interrupt request 1: reset request write only watchdog timer control register 2 7 6 5 4 3 2 1 0 wdtcr2 (0035 h ) (initial value: **** **** ) wdtcr2 watchdog timer control code and address trapped area control code d2 h : address trapped area valid to set (atrap control code) 4e h : watchdog timer binary counter clear (wdt clear code) b1 h : watchdog timer disable (wdt disable code) others: invalid write only figure 2.5.1 watchdog timer control registers (1) selection of address trap in internal ram (atas) using wdtcr1 TMP86FM48 2007-08-24 86fm48-66 2.6 divider output (dvo) approximately 50% duty pulse can be output using the divider output circuit, which is useful for piezoelectric buzzer drive. divider output is from pin p51 ( dvo ). the p51 output latch should be set to ?1?. note: selection of divider output frequency must be made while divider output is disabled. also, in other words, when changing the stat e of the divider output frequency from enabled to disable, do not change the setting of the divider output frequency. 7 6 5 4 3 2 1 0 tbtcr (0036 h ) dvoen dvock (dv7ck) (tbten) (t btck) (initial value: 0000 0000) dvoen divider output enable/disable 0: disable 1: enable normal1/2 mode dv7ck = 0 dv7ck = 1 slow, sleep mode 00 fs/2 5 01 fs/2 4 10 fs/2 3 dvock divider output ( dvo ) frequency selection [hz] 11 fc/2 13 fc/2 12 fc/2 11 fc/2 10 fs/2 5 fs/2 4 fs/2 3 fs/2 2 fs/2 2 r/w note: fc: high-frequency clock [hz ], fs: low-frequency clock [hz], * : don?t care figure 2.6.1 divider output control register example: 1.95 khz pulse output (at fc = 16.0 mhz) set (p5dr).1 ; p51 output latch ?1? ld (tbtcr), 00000000b ; dvock ?00? ld (tbtcr), 10000000b ; dvoen ?1? table 2.6.1 divider output frequency (example: at fc = 16.0 mhz, fs = 32.768 khz) divider output frequency [hz] normal1/2, idle1/2 mode dvock dv7ck = 0 dv7ck = 1 slow, sleep mode 00 01 10 11 1.953 k 3.906 k 7.813 k 15.625 k 1.024 k 2.048 k 4.096 k 8.192 k 1.024 k 2.048 k 4.096 k 8.192 k figure 2.6.2 divider output data output output latch p51 ( dvo ) mpx d q fc/2 13 or fs/2 5 fc/2 12 or fs/2 4 fc/2 11 or fs/2 3 fc/2 10 or fs/2 2 a b c d s y 2 dvock dvoen tbtcr divider output control register (a) configuration (b) timing chart p51 output latch dvoen dvo pin output mpx: multiplexer TMP86FM48 2007-08-24 86fm48-67 2.7 16-bit timer/counter 1 2.7.1 configuration figure 2.7.1 timer/counter 1 (tc1) clear q set toggle 16-bit timer re g ister 1a, b edge detector pulse width measurement mode pulse width measurement mode tc1cr tc1 control registe r mcap1 external trigge r command start external trigger start tc1ck tc1 pin a cap1 mpx source clock mpx risin g falling window mode capture note 1: mpx: multiplexer cmp: comparator note 2: when control input /output is us ed, i/o port setting should be set correctly. for details, refer to ?2.2 i/o ports?. fc/2 11 or fs/2 3 fc/2 7 fc/2 3 mett1 mppg1 cmp tff1 tc1cr write strobe internal reset clea r inttc1 interrupt ppg output mode start match ppg out p ut mode toggle q set clear port (note 2) ppg p in b y a s tc1drb tc1dra b y a s s a y b port (note 2) d a b y c s 16-bit up counter tc1s clea r set clear 2 decoder tc1s mpx 2 TMP86FM48 2007-08-24 86fm48-68 2.7.2 control the timer/counter 1 is controlled by a time r/counter 1 control register (tc1cr) and two 16-bit timer registers (tc1dra and tc1drb). 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 tc1drah (0021h) tc1dral (0020h) (initial value: 1111 1111 1111 1111) tc1drbh (0023h) tc1drbl (0022h) (initial value: 1111 1111 1111 1111) note: tc1drb should not be written except ppg mode. 7 6 5 4 3 2 1 0 tc1cr (001fh) tff1 acap1 mcap1 mett1 mppg1 tc1s tc1ck tc1m (initial value: 0000 0000) tc1m tc1 operating mode select 00: timer/external trigger timer/event counter mode 01: window mode 10: pulse width measurement mode 11: ppg (programmable pulse generate) output mode normal1/2, idle1/2 mode dv7ck = 0 dv7ck = 1 slow1/2, sleep1/2 mode fc/2 11 fc/2 7 fc/2 3 fs/2 3 fc/2 7 fc/2 3 fs/2 3 ? ? tc1ck tc1 source clock select [hz] 00 01 10 11 external clock (tc1 pin input) timer extend event window pulse ppg 00: stop and counter clear 01: command start 10: external trigger start at the rising edge tc1s tc1 start control 11: external trigger start at the falling edge acap1 auto capture control 0: auto-capture disable 1: auto-capture enable mcap pulse width measurement mode control 0: double edge capture 1: single edge capture mett1 external trigger timer mode control 0: trigger start 1: trigger start and stop mppg1 ppg output control 0: continuous pulse generation 1: one-shot tff1 time f/f1 control 0: clear 1: set r/w note 1: fc: high-frequency clock [hz], fs: low-frequency clock [hz] note 2: the timer register consists of tw o shift registers. a value set in the timer register is put in effect at the rising edge of the first source clock pulse that occurs after the upper data (tc1drah and tc1drbh) are written. therefore, the lower byte must be written before the upper byte (it is recommended that a 16-bit access instruction be used in writing). writing only the lower data (tc1dral and tc1drbl) does not put the setting of the timer register in effect. note 3: set the mode, source clock, ppg control and timer f/f control when tc1 stops (tc1s = 00). note 4: auto-capture can be used in only timer, event counter, and window modes. note 5: values to be loaded to timer registers must satisfy the following condition. tc1dra > tc1drb > 1 (ppg output mode), tc1dra > 1 (others) note 6: always write ?0? to tff1 except ppg output mode. note 7: writing to the tc1drb is not possible unless tc1 is set to the ppg output mode. note 8: on entering stop mode, the tc1 start control (tc1 s) is cleared to ?00? automatically. so, the timer stops. once the stop mode has been released, to star t using the timer counter, set tc1s again. note 9: use the auto-capture function in the operative condi tion of tc1. a captured value may not be fixed if it's read after the execution of the timer stop or auto-c apture disable. read the capture value in a capture enabled condition. tc1dra (0021,0020h) r/w tc1drb (0023,0022h) r/w TMP86FM48 2007-08-24 86fm48-69 note 10: since the up-counter value is captured into tc 1drb by the source clock of up-counter after setting tc1cr TMP86FM48 2007-08-24 86fm48-70 figure 2.7.3 timer mode timing chart source clock up counte r match detect counter clea r (a) timer mode command start 1 2 3 0 n ? ? -2 tc1drb a cap1 m ? 1 m m + + ? + 1 n m ? 1 m m + + ? + 1 n ? ca p ture ca p ture (b) auto capture TMP86FM48 2007-08-24 86fm48-71 (2) external trigger timer mode in this mode, counting up is started by an external trigger. this trigger is the edge of the tc1 pin input. either the rising or falling edge can be selected with tc1s. source clock is an internal clock. the contents of tc1dra is compared with the contents of up counter. if a match is found, an inttc1 interrupt is generated, and the counter is cleared to ?0? and halted. the counter is rest arted by the selected edge of the tc1 pin input. when tc1cr TMP86FM48 2007-08-24 86fm48-72 figure 2.7.4 external trigger timer mode timing chart (3) event counter mode in this mode, events are counted at the edge of the tc1 pin input (either the rising or falling edge can be selected with the external trigger tc1cr TMP86FM48 2007-08-24 86fm48-73 table 2.7.2 timer/counter 1 external clock source minimum input pulse width [s] normal1/2, idle1/2 mode slow1/2, sleep1/2 mode ?h? width 2 3 /fc 2 3 /fs ?l? width 2 3 /fc 2 3 /fs (4) window mode in this mode, counting up is performed on the rising edge of the pulse that is the logical and-ed product of the tc1 pin input (window pulse) and an internal clock. the contents of tc1dra are compared with the contents of up counter. if a match is found, an inttc1 interrupt is generated, and the coun ter is cleared. it is possible to select either positive logic or negative logic for the tc1 pin input (by using the tc1 start control tc1cr TMP86FM48 2007-08-24 86fm48-74 (5) pulse width measurement mode in this mode, counting is started by the exte rnal trigger (set to external trigger start by tc1cr TMP86FM48 2007-08-24 86fm48-75 figure 2.7.7 pulse measurement mode timing chart (b) double edge capture (mcap1 = = ? = ? = + + + ? 2 m ? 1 m 0 m capture TMP86FM48 2007-08-24 86fm48-76 (6) programmable pulse generate (ppg) output mode the ppg output mode is intended to output pulses having an arbitrary duty cycle selected using two timer registers. the timer starts at an edge (rising or falling edge, that is, the same edge type as selected with the external trigger edge select bits (tc1cr TMP86FM48 2007-08-24 86fm48-77 figure 2.7.8 ppg output figure 2.7.9 ppg output mode timing chart d q r set clear q toggle tff1 tc1cr write strobe internal reset match with tc1drb match with tc1dra inttc1 interrupt mppg1 tc1s clea r timer f/f1 data output p50 output latch p50 ( ppg ) pin mpx: multiplexe r command start up counte r tc1drb (a) continuous pulse generation (with tc1s = = TMP86FM48 2007-08-24 86fm48-78 2.8 16-bit timer/counter 2 2.8.1 configuration figure 2.8.1 timer/counter 2 (tc2a) port h a b c d y e f s mpx timer/event counte r b y a s window fc/2 23 or fs/2 15 fc/2 13 or fs/2 5 fc/2 8 fc/2 3 fc fs 3 tc2cr tc2s tc2ck tc2 control re g iste r cmp 16-bit up counter tc2dr 16-bit timer re g ister 2 tc2s clea r match match detect control tc2drh write strobe tc2drl write strobe inttc2 interru p t note 1: mpx: multiplexer cmp: comparator note 2: when control input/output is used, i/o port setting s hould be set correctly. for details, refer to ?2.2 i/o ports?. enable tc2 pin (note 2) tc2m source clock TMP86FM48 2007-08-24 86fm48-79 2.8.2 control the timer/counter 2 is controlled by a time r/counter 2 control register (tc2cr) and a 16-bit timer register 2 (tc2dr). reset does not affect tc2dr. 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 tc2drh (0025h) tc2drl (0024h) 7 6 5 4 3 2 1 0 tc2cr (0013h) tc2s tc2ck tc2m (initial value: ** 00 00 * 0) tc2m tc2 operating mode select 0: timer/event counter mode 1: window mode normal1/2, idle1/2 mode dv7ck = 0dv7ck = 1 slow1/2 mode sleep1/2 mode fc/2 23 fc/2 13 fc/2 8 fc/2 3 ? fs fs/2 15 fs/2 5 fc/2 8 fc/2 3 ? fs fs/2 15 fs/2 5 ? ? fc (note 7) ? fs/2 15 fs/2 5 ? ? ? ? reserved tc2ck tc2 source clock select [hz] 000 001 010 011 100 101 110 111 external clock (tc2 pin input) tc2s tc2 start control 0: stop and counter clear 1: start r/w note 1: fc: high-frequency clock [h z], fs: low-frequency clock [hz], * : don?t care note 2: when writing to the timer register 2 (tc2dr), always write to the lower side (tc2drl) and then the upper side (tc2drh) in that order. writing to only the lo wer side (tc2drl) or the upper side (tc2drh) has no effect. note 3: the timer register 2 (tc2dr) uses the value previ ously set in it for coincidence detection until data is written to the upper side (tc2drh) after writing data to the lower side (tc2drl). note 4: set the mode and source clock when the tc2 stops (tc2s = 0). note 5: values to be loaded to the timer r egister must satisfy the following condition. tc2dr > 1 (tc2dr 15 to tc2dr 11 > 1 at warm up) note 6: if a read instruction is executed for tc2cr, read data of bit 7, 6 and 1 are unstable. note 7: the high-frequency clock(fc) can be selected only when the timer mode at slow2 mode is selected. note 8: on entering stop mode, the tc2 start control (tc2 s) is cleared to ?0? automatically. so, the timer stops. once the stop mode has been released, to star t using the timer counter, set tc2s again. figure 2.8.2 timer register 2 and tc2 control register tc2dr (0025, 0024h) r/w TMP86FM48 2007-08-24 86fm48-80 2.8.3 function the timer/counter 2 has three operating modes: timer, event counter and window modes. (1) timer mode in this mode, the internal clock is used for counting up. the contents of tc2dr are compared with the contents of up counter . if a match is found, a timer/counter 2 interrupt (inttc2) is generated, and the co unter is cleared. counting up is resumed after the counter is cleared. when fc is selected for source clock at slow2 mode, lower 11-bits of tc2dr are ignored and generated a interrupt by matching upper 5-bits. though, in this situation, it is necessary to set tc2drh only. table 2.8.1 source clock (internal clock) for timer/counter 2 (at fc = 16 mhz) normal1/2, idle1/2 mode slow1/2 mode sleep1/2 mode dv7ck = 0 dv7ck = 1 tc2ck resolution maximum time setting resolution maximum time setting resolution maximum time setting resolution maximum time setting 000 001 010 011 100 101 524.29 ms 512.00 s 16.00 s 0.50 s ? 30.52 s 9.54 h 33.55 s 1.05 s 32.77 ms ? 2.00 s 1.00 s 0.98 ms 16.00 s 0.50 s ? 30.52 s 18.20 h 1.07 min 1.05 s 32.77 ms ? 2.00 s 1.00 s 0.98 ms ? ? 62.5 ns (note) ? 18.20 h 1.07 min ? ? ? ? 1.00 s 0.98 ms ? ? ? ? 18.20 h 1.07 min ? ? ? ? note: when fc is selected as the source clock in ti mer mode, it is used at warm-up for switching from slow2 mode to normal2 mode. example: sets the timer mode with source clock fc/2 3 [hz] and generates an interrupt every 25 ms (at fc = 16 mhz). ldw (tc2dr), 0c350h ; sets tc2dr (25 ms 2 3 /fc = c350h) di ; imf = ?0? set (eire). 4 ; enables inttc2 interrupt ei ; imf = ?1? ld (tc2cr), 00001100b ; tc2ck ?011?, tc2m ?0? ld (tc2cr), 00101100b ; starts tc2 TMP86FM48 2007-08-24 86fm48-81 (2) event counter mode in this mode, events are counted on the rising edge of the tc2 pin input. the contents of tc2dr are compared with the contents of the up counter. if a match is found, an inttc2 interrupt is generated, and the counter is cleared. the minimum input pulse width of tc2 pin is shown in table 2.8.2. two or more machine cycles are required for both the ?h? and ?l? levels of th e pulse width. match detect is executed on the falling edge of the tc2 pin. a match can not be detected and inttc2 is not generated when the pulse is still in a falling state. example: sets the event counter mode and generates an inttc2 interrupt 640 counts later. ldw (tc2dr), 640 ; sets tc2dr di ; imf = ?0? set (eire). 4 ; enables inttc2 interrupt ei ; imf = ?1? ld (tc2cr), 00011100b ; tc2ck ?111?, tc2m ?0? ld (tc2cr), 00111100b ; starts tc2 table 2.8.2 timer/counter 2 external clock source minimum input pulse width [s] normal1/2, idle1/2 mode slow1/2, sleep1/2 mode ?h? width 2 3 /fc 2 3 /fs ?l? width 2 3 /fc 2 3 /fs TMP86FM48 2007-08-24 86fm48-82 (3) window mode in this mode, counting up performed on the rising edge of an internal clock during tc2 external pin input (window pulse) is ?h? level. the contents of tc2dr are compared with the contents of up counter. if a match found, an inttc2 interrupt is generated, and the up-counter is cleared. the maximum applied frequency (tc2 input) must be considerably slower than the selected internal clock. note: in the window mode, before the slow /sleep mode is entered, the timer should be halted by setting tc2cr TMP86FM48 2007-08-24 86fm48-83 2.9 8-bit timer/counter 3 2.9.1 configuration note 1: mpx: multiplexer cmp: comparator note 2: when control input/output is used, i/o port setting s hould be set correctly. for details, refer to ?2.2 i/o ports?. figure 2.9.1 timer/counter 3 (tc3) ( note 2 ) overflow tc3 pin clea r tc3s port tc3cr 1 y 0 s fc/2 13 or fs/2 5 fc/2 12 or fs/2 4 fc/2 11 or fs/2 3 fc/2 10 or fs/2 2 fc/2 9 or fs fc/2 8 fc/2 7 inttc3 interrupt tc3s h a y b c d e f g s edge detector mpx fallin g risin g tc3m tc3s tc3ck 3 tc3 control re g iste r tc3drb acap ca p ture ca p ture cmp tc3dra 8-bit timer re g ister 3a, b match 8-bit up counter source clock TMP86FM48 2007-08-24 86fm48-84 2.9.2 control the timer/counter 3 is controlled by a time r/counter 3 control register (tc3cr) and two 8-bit timer registers (tc3dra and tc3drb). 7 6 5 4 3 2 1 0 (initial value: 1111 1111) 7 6 5 4 3 2 1 0 (initial value: 1111 1111) 7 6 5 4 3 2 1 0 acap tc3s tc3ck tc3m (initial value: * 0 * 0 0000) tc3m tc3 operation mode set 0: timer/event counter 1: capture normal1/2, idle1/2 mode dv7ck = 0 dv7ck = 1 slow1/2, sleep1/2 mode fc/2 13 fc/2 12 fc/2 11 fc/2 10 fc/2 9 fc/2 8 fc/2 7 fs/2 5 fs/2 4 fs/2 3 fs/2 2 fs/2 fc/2 8 fc/2 7 fs/2 5 fs/2 4 fs/2 3 fs/2 2 fs/2 ? ? tc3ck tc3 source clock select [hz] 000 001 010 011 100 101 110 111 external clock (tc3 pin input) tc3s tc3 start select 0: stop and clear 1: start acap auto-capture control 0: ? 1: auto capture enable r/w note 1: fc: high-frequency clock [h z], fs: low-frequency clock [hz], * : don?t care note 2: set the mode and the source clock when the tc3 stops (tc3s = 0). note 3: values to be loaded into timer regist er 3a must satisfy the following condition. tc3dra > 1 (in the timer and event counter mode) note 4: auto-capture can be used only in the timer and event counter mode. note 5: if a read instruction is executed for tc 3cr, read data for bits 7 and 5 are unstable. note 6: during tc3 operation, do not change tc3dra. note 7: on entering stop mode, tc3 start control (tc3 s) is cleared to ?0? automatically, so the timer stops. once the stop mode has been released, to star t using the timer counter, set tc3s again. figure 2.9.2 timer register 3 and tc3 control register tc3dra (0010h) r/w tc3drb (0011h) read only tc3cr (0012h) TMP86FM48 2007-08-24 86fm48-85 2.9.3 function the timer/counter 3 has three operating modes: timer, event counter, and capture mode. (1) timer mode in this mode, the internal clock is used fo r counting up. the contents of tc3dra are compared with the contents of up counter. if a match is found, a timer/counter 3 interrupt (inttc3) is generated, and the up counter is cleared. the current contents of up counter are loaded into tc3drb by setting tc3cr TMP86FM48 2007-08-24 86fm48-86 (2) event counter mode in this mode, events are counted on the edge of the tc3 pin input. the counter counts up on the rising edge of the tc3 pin input and when its value matches the tc3dra set value, it is cleared while at the same time generating an inttc3 interrupt. the detection of match is executed at the falling edge of the tc3 pin. therefore, if the tc3 pin keeps high level afte r the rising, the detection of match is not executed and inttc3 is not generated until the level of tc3 pin becomes low. the minimum input pulse width of the tc3 pin is shown in table 2.9.2. one or more machine cycles are required for both the ?h? and ?l? levels of the pulse width. the current contents of up counter are loaded into tc3drb by setting tc3cr TMP86FM48 2007-08-24 86fm48-87 (3) capture mode in this mode, the pulse width, period and duty of the tc3 pin input are measured in this mode, which can be used in decoding the remote control signals or distinguishing ac 50/60 hz, etc. once command operation has started, the counter free-runs on an internal source clock. when the falling edge of the tc3 pin input is detected, the counter value is loaded into tc3drb. when the rising edge is detected, the counter value is loaded into tc3dra, and the counter is cleared, generating an inttc3 interrupt. if the rising edge is detected right after command operation has started, no capture to tc3drb and an inttc3 interrupt occurs only on capture to tc3dra. if a read instruction is executed for tc3drb, the value that exists at the end of the previous capture (immediately after a reset, ?ff?) is read. the minimum acceptable input pulse width is equal to the length of one source clock period selected by tc3cr TMP86FM48 2007-08-24 86fm48-88 figure 2.9.3 capture mode timing chart overflow ff (overflow) capture tc3s source clock up counte r tc3 pin input tc3dra tc3drb inttc3 interrupt reading tc3dra command start capture 0 1 i ? 1 i i + 1 k ? 1 1 k 0 m m + 1 n ? 1 m ? 1 n 0 1 2 3 fe ff 1 2 3 k i m n fe TMP86FM48 2007-08-24 86fm48-89 2.10 8-bit timer/counter 5 2.10.1 configuration note 1: mpx: multiplexer cmp: comparator note 2: when control input/output is used, i/o port setting s hould be set correctly. for details, refer to ?2.2 i/o ports?. figure 2.10.1 timer/counter 5 (tc5) overflow clea r tc5s tc5cr tc5dr ( note 2 ) tc5 pin port tc5 control registe r tc5s tc5m tc5s tc5ck 3 8-bit timer re g ister 5 timer f/f5 inttc5 interrupt match cmp 8-bit up counter source clock ( note 2 ) port toggle clear pdo mode fc/2 11 or fs/2 3 fc/2 7 fc/2 5 fc/2 3 fc/2 2 fc/2 fc a b c d y e f g h s mpx 2 a y b s a b ys pwm output mode pwm5 / pdo5 pin TMP86FM48 2007-08-24 86fm48-90 2.10.2 control the timer/counter 5 is controlled by a time r/counter 5 control register (tc5cr) and an 8-bit timer register 5 (tc5dr). reset does not affect tc5dr. 7 6 5 4 3 2 1 0 (initial value: 1111 1111) tc5dr (0015h) r/w 7 6 5 4 3 2 1 0 tc5s tc5ck tc5m (initial value: ** 00 0000) tc5cr (0014h) tc5s tc5 start control 0: stop and counter clear 1: start normal1/2, idle1/2 mode dv7ck = 0 dv7ck = 1 slow1/2, sleep1/2 mode fc/2 11 fc/2 7 fc/2 5 fc/2 3 fc/2 2 fc/2 fc fs/2 3 fc/2 7 fc/2 5 fc/2 3 fc/2 2 fc/2 fc fs/2 3 ? ? ? ? ? ? tc5ck tc5 source clock select [hz] 000 001 010 011 100 101 110 111 external clock (tc5 pin input) tc5m tc5 operating mode select 00: timer/event counter mode 01: reserved 10: programmable divider output (pdo) mode 11: pulse width modulation (pwm) output mode r/w note 1: fc: high-frequency clock [h z], fs: low-frequency clock [hz], * : don?t care note 2: values to be loaded to the timer r egister must satisfy the following condition. 1 tc5dr 255 note 3: when tc5 operation is started (tc5s = ?0? ?1?) or tc5 operation is stopped (tc5s = ?1? ?0?), do not change tc5cr TMP86FM48 2007-08-24 86fm48-91 2.10.3 function the timer/counter 5 has four operating modes: timer, event counter, programmable divider output, and pwm output mode. (1) timer mode in this mode, the internal clock is used for counting up. the contents of tc5dr is compared with the contents of up counter. if a match is found, an inttc5 interrupt is generated and the up-counter is cleared to ?0?. counting up resumes after the up-counter is cleared. table 2.10.1 source clock (internal cloc k) for timer/counter 5 (example: at fc = 16 mhz) normal1/2, idle1/2 mode slow1/2 mode dv7ck = 0 dv7ck = 1 tc5ck resolution [ s] maximum time setting [ms] resolution [ s] maximum time setting [ms] resolution [ s] maximum time setting [ms] 000 001 010 011 128.0 8.0 2.0 0.5 32.6 2.0 0.510 0.128 244.14 8.0 2.0 0.5 62.3 2.0 0.510 0.128 244.14 ? ? ? 62.3 ? ? ? (2) event counter mode in this mode, events are counted on the rising edge of the tc5 pin input (external clock). the contents of the tc5dr is compared with the contents of the up counter. if a match is found, an inttc5 interrupt is generated and the counter is cleared. counting up resumes after the up counter is cleared. the minimum input pulse width of the tc5 pin is shown in table 2.10.2. two or more machine cycles are required for both the ?h? and ?l? levels of the pulse width. match detect is executed on the falling edge of the tc5 pin. a match can not be detected and inttc5 interrupt is not generated when the pulse is still in a falling state. table 2.10.2 timer/counter 5 external clock source minimum input pulse width [s] normal1/2, idle1/2 mode slow1/2, sleep1/2 mode ?h? width 2 3 /fc 2 3 /fs ?l? width 2 3 /fc 2 3 /fs TMP86FM48 2007-08-24 86fm48-92 (3) programmable divider output (pdo) mode the programmable divider output (pdo) mode is intended to output a pulse having a duty cycle of about 50%. the counter counts up on an internal source clock. if the timer value matches tc5dr, the timer f/f5 is inverted, and the counter is cleared, generating an inttc5 interrupt. the counter keeps counting up, and the timer f/f5 is inverted each time the timer value matches tc5dr. the p13 ( pdo5 ) pin outputs an inversion of the timer f/f5 output level. at a reset or when the timer stops, the timer f/f5 is cleared to ?0?. so, stopping the timer when the pdo output is low may cause the duty cycle to become smaller than the set value. to use the programmable divider output mode, set the output latch of the p13 port to ?1?. example: output a 1024 hz pulse (at fc = 16 mhz) ld (tc5cr), 00000110b ; sets pdo mode (tc5m = 10, tc5ck = 001) set (p1dr). 3 ; p13 output latch 1 ld (tc5dr), 3dh ; 1/1024 2 7 /fc 2 = 3dh ld (tc5cr), 00100110b ; starts tc5 figure 2.10.3 pdo mode timing chart 1 0 1 n 0 internal clock up counter tc5dr timer f/f5 pdo5 pin output inttc5 interrupt 0 n match detect 1 2 n 2 0 n 2 12 1 n 0 TMP86FM48 2007-08-24 86fm48-93 (4) pulse width modulation (pwm) output mode the pulse width modulation (pwm) output mode is intended to output pulses at constant intervals with a resolution of 8 bits. the counter counts up on the internal source clock. if the timer value matches tc5dr, the timer f/f5 is inverted, and the counter keeps-up counting. if an overflow is detected, the timer f/f5 is inverted again, generating an inttc5 interrupt. the p13 ( pwm5 ) pin outputs an inversion of the timer f/f5 output level. at a reset or when the timer stops, the timer f/f5 is cleared to ?0?. so, stopping the timer when the pwm output is low may cause one cycle to become smaller than the set value. to use the pulse width modulation (pwm) output mode, set the output latch of the p13 port to ?1?. tc5dr is configured a 2-stage shift register and, during pulse width, will not switch until one output cycle is completed even if tc5dr is overwritten; therefore, pulse width can be altered continuously. also, the first time, tc5dr is shifted by setting tc5cr TMP86FM48 2007-08-24 86fm48-94 2.11 uart (asynchronous serial interface) the TMP86FM48 has 1 channel of uart (asynchronous serial interface). the uart is connected to external devices via rxd and txd. rxd is also used as p05; txd, as p06. to use p05 or p06 as the rxd or tx d pin, set p0 port output latches to ?1?. 2.11.1 configuration figure 2.11.1 uart parity bit intrxd inttxd 2 2 transmit data buffer uart control register 1 receive data buffer 3 rxd txd stop bit uart control register 2 2 uart status register 4 baud rate generator a b c m d p e x f g h s y fc/13 2 transmit/receive clock uartcr1 tdbuf rdbuf shift register counter uartsr shift register receive control circuit noise rejection circuit uartcr2 y m a p b x c s transmit control circuit fc/2 6 fc/2 7 fc/2 8 fc/26 fc/52 fc/104 fc/208 fc/416 inttc5 fc/96 mpx TMP86FM48 2007-08-24 86fm48-95 2.11.2 control uart is controlled by the uart control registers (uartcr1, uartcr2). the operating status can be monitored usin g the uart status register (uartsr). uart control register 7 6 5 4 3 2 1 0 uartcr1 (1fdd h ) txe rxe stbt even pe brg (initial value: 0000 0000) txe transfer operation 0: disable 1: enable rxe receive operation 0: disable 1: enable stbt transmit stop bit length 0: 1 bit 1: 2 bits even even-numbered parity 0: odd-numbered parity 1: even-numbered parity pe parity addition 0: no parity 1: parity brg transmit clock select 000: fc/13 [hz] 001: fc/26 010: fc/52 011: fc/104 100: fc/208 101: fc/416 110: tc5 (inttc5) 111: fc/96 write only note 1: when operations are disabled by setting txe and rxe bit to ?0?, the setting becomes valid when data transmit or receive complete. when the transmit data is stored in the transmit data buffer, the data are not transmitted. even if data transmit is enabled, until new data are written to the transmit data buffer, the current data are not transmitted. note 2: the transmit clock and the parity are common to transmit and receive. note 3: uartcr1 TMP86FM48 2007-08-24 86fm48-96 7 6 5 4 3 2 1 0 uartsr (1fdd h ) perr ferr oerr rbfl tend tbep (initial value: 0000 11 ** ) perr parity error flag 0: no parity error 1: parity error ferr framing error flag 0: no framing error 1: framing error oerr overrun error flag 0: no overrun error 1: overrun error rbfl receive data buffer full flag 0: receive data buffer empty 1: receive data buffer full tend transmit end flag 0: transmitting 1: transmit end tbep transmit data buffer empty flag 0: transmit data buffer full 1: transmit data buffer empty read only note: when an inttxd is generated tbep is set to ?1? automatically. uart receive data buffer 7 6 5 4 3 2 1 0 rdbuf (1fdf h ) read only (initial value: 0000 0000) uart transmit data buffer 7 6 5 4 3 2 1 0 tdbuf (1fdf h ) write only (initial value: 0000 0000) figure 2.11.3 uart status register and data buffer registers TMP86FM48 2007-08-24 86fm48-97 2.11.3 transfer data format in uart, a one-bit start bit (low level), stop bit (bit length selectable at high level, by uartcr1 TMP86FM48 2007-08-24 86fm48-98 2.11.4 transfer rate the baud rate of uart is set of uartcr1 TMP86FM48 2007-08-24 86fm48-99 2.11.6 stop bit length select a transmit stop bit length (1 or 2 bits) by uartcr1 TMP86FM48 2007-08-24 86fm48-100 2.11.9 status flag/interrupt signal (1) parity error when parity determined using the receive data bits differs from the received parity bit, the parity error flag uartsr TMP86FM48 2007-08-24 86fm48-101 (3) overrun error when all bits in the next data are received while unread data are still in rdbuf, overrun error flag uartsr TMP86FM48 2007-08-24 86fm48-102 (5) transmit data buffer empty when no data is in the transmit buffer tdbuf, uartsr TMP86FM48 2007-08-24 86fm48-103 2.12 serial bus interface (sbi-ver. d) the TMP86FM48 has a 1-channel serial bus interface which employs an i 2 c bus (a bus system by philips). the serial interface is connected to external devices through p51 (sda) and p50 (scl). the serial bus interface pins are also used for the p5 port. when used for se rial bus interface pins, set the p5 output latches of these pins to ?1?. wh en not used as serial bus interface pins, the p5 port is used as a normal i/o port. note 1: when p5 is used as serial bus interface pins, p50 and p51 should be set as a sink open drain output by clearing p5outcr to ?0?. note 2: the serial bus interface can be used on ly in normal1/2 and idle1/2 mode. it can not be used in idle0, slow1/2 and sleep0/1/2 mode. note 3: the i 2 c of TMP86FM48 can be used only in the standard mode of i 2 c. the fast mode and the high-speed mode can not be used. 2.12.1 configuration figure 2.12.1 serial bus interface (sbi) 2.12.2 control the following registers are used for contro l the serial bus interface and monitor the operation status. ? serial bus interface control register a (sbicra) ? serial bus interface control register b (sbicrb) ? serial bus interface data buffer register (sbidbr) ? i 2 c bus address register (i2car) ? serial bus interface status register (sbisr) intsbi interrupt request transfer control circuit i 2 c bus clock sync. + control shift register i 2 c bus data control scl input/ output control sbicrb/ sbisr sbidbr sbicra sbi control register b/ sbi status register i 2 c bus address register sbi data buffer register sbi control register a sda p50 (sda) (scl) p51 divider noise canceller noise canceller i2car fc/4 TMP86FM48 2007-08-24 86fm48-104 2.12.3 software reset a serial bus interface circuit has a software reset function, when a serial bus interface circuit is locked by an external noise, etc. to reset the serial bus interface circuit, write ?01?, ?10? into the swrst (bit1, 0 in sbicrb). 2.12.4 the data format of the i 2 c bus the data format of the i 2 c bus is shown in as below. s: start condition r/ w : direction bit ack: acknowledge bit p: stop condition figure 2.12.2 data format of i 2 c bus 1 1 or more 1 or more 1 or more 1 a c k a c k a c k a c k a c k data 1 1 slave address a c k a c k r / w r / w r / w p p p a c k a c k a c k s s s s (a) addressing format (b) addressing format (with restart) (c) free data format data 8 bits 1 to 8 bits 1 or more 1 data 1 to 8 bits slave address slave address data data data data 8 bits 8 bits 1 to 8 bits 1 to 8 bits 1 to 8 bits 8 bits 1 to 8 bits 1 1 1 1 1 1 1 1 1 TMP86FM48 2007-08-24 86fm48-105 2.12.5 i 2 c bus control the following registers are used to control the serial bus interface (sbi) and monitor the operation status of the i 2 c bus. serial bus interface control register a 7 6 5 4 3 2 1 0 sbicra (1fd9h) bc ack sck (initial value: 0000 * 000) ack = 0 ack = 1 bc number of clock bits number of clock bits 000 8 8 9 8 001 1 1 2 1 010 2 2 3 2 011 3 3 4 3 100 4 4 5 4 101 5 5 6 5 110 6 6 7 6 bc number of transferred bits 111 7 7 8 7 write only ack master mode slave mode 0: not generate a clock pulse for an acknowledgement. not count a clock pulse for an acknowledgement. ack acknowledgement mode specification 1: generate a clock pulse for an acknowledgement. count a clock pulse for an acknowledgement. r/w sck n at fc = 16 mhz at fc = 8 mhz at fc = 4 mhz 000: 001: 010: 011: 100: 101: 110: 4 5 6 7 8 9 10 reserved reserved reserved 60.6 khz 30.8 khz 15.5 khz 7.8 khz reserved reserved 58.8 khz 30.3 khz 15.4 khz 7.8 khz 3.9 khz 100.0 khz 55.6 khz 29.4 khz 15.2 khz 7.7 khz 3.9 khz 1.9 khz sck serial clock (fscl) selection (output on scl pin) [fscl = 1/(2 n + 1 /fc + 8/fc)] 111: reserved write only note 1: fc: high-frequency clock [hz], * : don?t care note 2: set the bc to ?000? before switching to 8-bit sio bus mode. note 3: sbicra cannot be used with any of read-modify-w rite instructions such as bit manipulation, etc. note 4: this i 2 c bus circuit does not support the fast mode . it supports the standar d mode only. although the i 2 c bus circuit itself allows the setting of a baud rate over 100 kbps, the compliance with the i2c specification is not guaranteed in that case. serial bus interface data buffer register 7 6 5 4 3 2 1 0 sbidbr (1fdah) (initial value: **** **** ) r/w note 1: for writing transmitted data, start from the msb (bit7). note 2: the data which was written into sbidbr can not be read, since a write data buffer and a read buffer are independent in sbidbr. therefore, sbidbr cannot be used with any of read-modify-write instructions such as bit manipulation, etc. note 3: * : don?t care i 2 c bus address register 7 6 5 4 3 2 1 0 slave address i2car (1fdbh) sa6 sa5 sa4 sa3 sa2 sa1 sa0 als (initial value: 0000 0000) sa slave address selection als address recognition mode specification 0: slave address recognition 1: non slave address recognition write only note 1: i2car is write-only register, which cannot be used with any of read-modify-write instruction such as bit manipulation, etc. note 2: do not set i2car to ?00h? to avoid the incorrect response of acknowledgment in slave mode. if ?00h? is set to i2car as the slave address and received ?01h ? in slave mode, the device might transmit the acknowledgment incorrectly. figure 2.12.3 serial bus interface control regi ster a, serial bus interface data buffer register and i 2 c bus address register TMP86FM48 2007-08-24 86fm48-106 serial bus interface control register b 7 6 5 4 3 2 1 0 sbicrb (1fdch) mst trx bb pin sbim swrst1 s wrst0 (initial value: 0001 0000) mst master/slave selection 0: slave 1: master trx transmitter/receiver selection 0: receiver 1: transmitter bb start/stop generation 0: generate a stop condition when mst, trx and pin are ?1? 1: generate a start condition when mst, trx and pin are ?1? pin cancel interrupt service request 0: ? 1: cancel interrupt service request sbim serial bus interface operating mode selection 00: port mode (serial bus interface output disable) 01: reserved 10: i 2 c bus mode 11: reserved swrst1 swrst0 software reset start bit software reset starts by first writing ?10? and next writing ?01? write only note 1: switch a mode to port after confirming that the bus is free. note 2: switch a mode to i 2 c bus mode after confiming that the port is high level. note 3: sbicrb has write-only register and must not be used wi th any of read-modify-write instructions such as bit manipulation, etc. note 4: when the swrst (bit1, 0 in sbicrb) is written to ?01?, ?10? in i 2 c bus mode, software reset is occurred. in this case, the sbicra, i2car and sbisr registers ar e initialized and the bits of sbicrb except the sbim (bit3, 2 in sbicrb) are also initialized. serial bus interface status register 7 6 5 4 3 2 1 0 sbisr (1fdch) mst trx bb pin al aas ad0 lrb (initial value: 0001 0000) mst master/slave selection status monitor 0: slave 1: master trx transmitter/receiver selection status monitor 0: receiver 1: transmitter bb bus status monitor 0: bus free 1: bus busy pin interrupt service requests status monitor 0: requesting interrupt service 1: releasing interrupt service request al arbitration lost detection monitor 0: ? 1: arbitration lost detected aas slave address match detection monitor 0: not detect slave address match or ?general call? 1: detect slave address match or ?general call? ad0 ?general call? detection monitor 0: not detect ?general call? 1: detect ?general call? lrb last received bit monitor 0: last receive bit is ?0? 1: last receiv bit is ?1? read only figure 2.12.4 serial bus interface control regist er b and serial bus interface status register TMP86FM48 2007-08-24 86fm48-107 (1) acknowledgement mode specification a. acknowledgment mode (ack = ?1?) to set the device as an acknowledgment mode, the ack (bit4 in sbicra) should be set to ?1?. when a serial bus interface circuit is a master mode, an additional clock pulse is generated for an acknowledge signal. in a slave mode, a clock is counted for the acknowledge signal. in the master transmitter mode, the sda pi n is released in order to receive an acknowledge signal from the receiver during additional clock pulse cycle. in the master receiver mode, the sda pin is set to low level generation an acknowledge signal during additional clock pulse cycle. in a slave mode, when a received slav e address matches to a slave address which is set to the i2car or when a ?general call? is received, the sda pin is set to low level generating an acknowle dge signal. after the matching of slave address or the detection of ?general call?, in the transmitter, the sda pin is released in order to receive an acknowledge signal from the receiver during additional clock pulse cycle. in a receiver, the sda pin is set to low level generation an acknowledge signal during additional clock pulse cycle after the matching of slave address or the detection of ?general call? the table 2.12.1 shows the scl and sda pins status in acknowledgment mode. table 2.12.1 scl and sda pins status in acknowledgement mode mode pin transmitter receiver scl an additional clock pulse is generated. master sda released in order to receive an acknowledge signal. set to low level generating an acknowledge signal scl a clock is counted for the acknowledge signal. when slave address matches or a general call is detected ? set to low level generating an acknowledge signal. slave sda after matching of slave address or general call released in order to receive an acknowledge signal. set to low level generating an acknowledge signal. b. non-acknowledgment mode (ack = ?0?) to set the device as a non-acknowledgem ent mode, the ack should be cleared to ?0?. in the master mode, a clock pulse for an acknowledge signal is not generated. in the slave mode, a clock for a acknowledge signal is not counted. (2) number of transfer bits the bc (bits7 to 5 in sbicra) is used to select a number of bits for next transmitting and receiving data. since the bc is cleared to ?000? as a start condition, a slave address and direction bit transmissions are always executed in 8 bits. other than these, the bc retains a specified value. (3) serial clock a. clock source the sck (bits2 to 0 in sbicra) is used to select a maximum transfer frequency output from the scl pin in the master mode. set a communication baud rate that meets the i 2 c bus specification, such as the shortest pulse width of t low , based on the equations shown below. TMP86FM48 2007-08-24 86fm48-108 four or more machine cycles are required for both high and low levels of pulse width in the external clock which is input from scl pin. note: since the i 2 c of TMP86FM48 can not be used as the fast mode and the high-speed mode, do not set sck as the frequency that is over 100 khz. figure 2.12.5 clock source b. clock synchronization in the i 2 c bus, in order to drive a bus with a wired and, a master device which pulls down a clock pulse to low will, in th e first place, invalidate a clock pulse of another master device which gene rates a high-level clock pulse. the serial bus interface circuit has a clock synchronization function. this function ensures normal transfer even if there are two or more masters on the same bus. the example explains clock synchronization procedures when two masters simultaneously exist on a bus. figure 2.12.6 clock synchronization as master 1 pulls down the scl pin to the low level at point ?a?, the scl line of the bus becomes the low level. after detecting this situation, master 2 resets counting a clock pulse in the high level and sets the scl pin to the low level. master 1 finishes counting a clock pulse in the low level at point ?b? and sets the scl pin to the high level. since master 2 holds the scl line of the bus at the low level, master 1 waits for counting a clock pulse in the high level. after master 2 sets a clock pulse to the high level at po int ?c? and detects the scl line of the bus at the high level, master 1 starts counting a clock pulse in the high level. then, the master, which has finished the counting a clock pulse in the high level, pulls scl pin (master 1) scl pin (master 2) scl (bus) wait count start count reset a b c count restart sck (bits2 to 0 in the sbicra) n 000 001 010 011 100 101 110 4 5 6 7 8 9 10 1/fscl t low = 2 n /fc t high = 2 n /fc + 8/fc fscl = 1/(t low + t high ) fc: high-frequency clock t high t low t sckl t sckh t sckl , t sckh > 4 tcyc note: tcyc = 4/fc (in normal mode, idle mode) TMP86FM48 2007-08-24 86fm48-109 down the scl pin to the low level. the clock pulse on the bus is determined by the master device with the shortest high-level period and the master device with the longest low-level period from among those master devices connected to the bus. (4) slave address and address re cognition mode specification when the serial bus interface circuit is used with an addressing format to recognize the slave address, clear the als (bit0 in i2car) to ?0?, and set the sa (bits7 to 1 in i2car) to the slave address. when the serial bus interface circuit is used with a free data format not to recognize the slave address, set the als to ?1?. with a free data format, the slave address and the direction bit are not recognized, and they are processed as data from immediately after start condition. (5) master/slave selection to set a master device, the mst (bit7 in sbi crb) should be set to ?1?. to set a slave device, the mst should be cleared to ?0?. when a stop condition on the bus or an arbitration lost is detected, the mst is cleared to ?0? by the hardware. (6) transmitter/receiver selection to set the device as a transmitter, the trx (bit6 in sbicrb) should be set to ?1?. to set the device as a receiver, the trx should be cleared to ?0?. when data with an addressing format is transferred in the slav e mode, the trx is set to ?1? by a hardware if the direction bit (r/ w ) sent from the master device is ?1?, and is cleared to ?0? by a hardware if the bit is ?0?. in the master mo de, after an acknowledge signal is returned from the slave device, the trx is cleared to ?0? by a hardware if a transmitted direction bit is ?1?, and is set to ?1? by a hardware if it is ?0?. when an acknowledge signal is not returned, the current condition is maintained. when a stop condition on the bus or an arbitration lost is detected, the trx is cleared to ?0? by the hardware. table 2.12. 2 shows trx changing conditions in each mode and trx value after changing. table 2.12.2 trx changing conditions in each mode mode direction bit conditions trx after changing ?0? ?0? slave mode ?1? a received slave address is the same value set to i2car ?1? ?0? ?1? master mode ?1? ack signal is returned ?0? when a serial bus interface circuit operates in the free data format, a slave address and a direction bit are not recognized. they are handled as data just after generating a start condition. the trx is not changed by a hardware. TMP86FM48 2007-08-24 86fm48-110 (7) start/stop condition generation when the bb (bit5 in sbisr) is ?0?, a sl ave address and a direction bit which are set to the sbidbr are output on a bus after gene rating a start condition by writing ?1? to the mst, trx, bb and pin. it is necessary to set transmitted data to the sbidbr and set ack to ?1? beforehand. figure 2.12.7 start condition generation and slave address generation when the bb is ?1?, sequence of generating a stop condition is started by writing ?1? to the mst, trx and pin, and ?0? to the bb. do not modify the contents of mst, trx, bb and pin until a stop condition is generated on a bus. figure 2.12.8 stop condition generation when a stop condition is generated and the scl line on a bus is pulled-down to low level by another device, a stop condition is generated after releasing the scl line. the bus condition can be indicated by reading the contents of the bb (bit5 in sbisr). the bb is set to ?1? when a start condition on a bus is detected and is cleared to ?0? when a stop condition is detected. (8) interrupt service request and cancel when a serial bus interface circuit is in the master mode and transferring a number of clocks set by the bc and the ack is complete, a serial bus interface interrupt request (intsbi) is generated. in the slave mode, the conditions of generating intsbi are follows: ? at the end of acknowledge signal when the received slave address matches to the value set by the i2car ? at the end of acknowledge signal when a ?general call? is received ? at the end of transferring or receiving after matching of slave address or receiving of ?general call? when a serial bus interface interrupt request occurs, the pin (bit4 in sbisr) is cleared to ?0?. during the time that the pi n is ?0?, the scl pin is pulled-down to low level. either writing data to sbidbr or reading data from the sbidbr sets the pin to ?1?. the time from the pin being set to ?1? until the scl pin is released takes t low . although the pin (bit4 in sbicrb) can be set to ?1? by the program, the pin can not be cleared to ?0? by the program. note: if the arbitration lost occurs, when the slave address does not match, the pin is not cleared to ?0? even though intsbi is generated. scl pin sda pin start condition slave address and the direction bit a cknowledge si g nal 1 2 345678 9 a6 a5 a4 a3 a2 a1 a0 r/ w sda pin scl pin stop condition TMP86FM48 2007-08-24 86fm48-111 (9) setting of i 2 c bus mode the sbim (bit3 and 2 in sbicrb) is used to set i 2 c bus mode. set the sbim to ?10? in order to set i 2 c bus mode. before setting of i 2 c bus mode, confirm serial bus interface pins in a high level, and then, write ?10? to sbim. and switch a port mode after confirming that a bus is free. (10) arbitration lost detection monitor since more than one master device can exist simultaneously on a bus, a bus arbitration procedure is implemented in order to guarantee the contents of transferred data. data on the sda line is used for bus arbitration of the i 2 c bus. the following shows an example of a bus arbitration procedure when two master devices exist simultaneously on a bus. master 1 and master 2 output the same data until point ?a?. after that, when master 1 outputs ?1? and master 2 outputs ?0?, since the sda line of a bus is wired and, the sda line is pulled-down to the low level by master 2. when the scl line of a bus is pulled-up at point ?b?, the slave device reads data on the sda line, that is data in master 2. data transmitted from master 1 becomes invalid. the state in master 1 is called ?arbitration lost?. a master device which loses arbitration releases the sda pin an d the scl pin in order not to effect data transmitted from other masters with arbitration. when more than one master sends the same data at the first word, arbitration occurs continuously after the second word. figure 2.12.9 arbitration lost the serial bus interface circuit compares le vels of a sda line of a bus with its sda pin at the rising edge of the scl line. if the levels are unmatched, arbitration is lost and the al (bit3 in sbisr) is set to ?1?. when the al is set to ?1?, the mst and trx are cleared to ?0? and the mode is switched to a slave receiver mode. thus, the serial bus interface circuit stops output of clock pulses during data transfer after the al is set to ?1?. the al is cleared to ?0? by writing data to the sbidbr, reading data from the sbidbr or writing data to the sbicrb. sda (bus) sda pin becomes ?1? after losing arbitration. a b scl (bus) sda pin (master 2) sda pin (master 1) TMP86FM48 2007-08-24 86fm48-112 figure 2.12.10 example of when a serial bus interface circuit is a master b (11) slave address match detection monitor in the slave mode, the aas (bit2 in sbisr) is set to ?1? when the received data is ?general call? or the received data ma tches the slave addre ss setting by i2car with an address recognition mode (als = 0). when a serial bus interface circuit operates in the free data format (als = 1), the aas is set to ?1? after receiving the first 1-word of data. the aas is cleared to ?0? by writing data to the sbidbr or reading data from the sbidbr. (12) general call detection monitor the ad0 (bit1 in sbisr) is set to ?1? when all 8-bit received data is ?0? immediately after a start condition in a slave mode. the ad0 is cleared to ?0? when a start or stop condition is detected on a bus. (13) last received bit monitor the sda value stored at the rising edge of the scl is set to the lrb (bit0 in sbisr). in the acknowledge mode, immediately after an intsbi interrupt request is generated, an acknowledge signal is read by reading the contents of the lrb. releasing sda pin and scl pin to hi gh level as losing arbitration. 1 2 3 4 5 6 7 8 9 1 2 3 d7a d6a d5a d4a d3a d2a d1a d0a d7a? d6a? d5a? d7b d6b scl pin sda pin scl pin sda pin a l mst trx a ccessed to sbidbr or sbicrb master a master b 1 2 3 4 56789 stop clock output intsbi TMP86FM48 2007-08-24 86fm48-113 2.12.6 data transfer of i 2 c bus (1) device initialization for initialization of device, set the ack in sbicra to ?1? and the bc to ?000?. specify the data length to 8 bits to count clocks for an acknowledge signal. set a transfer frequency to the sck in sbicra. next, set the slave address to the sa in i2car and clear the als to ?0? to set an addressing format. after confirming that the serial bus interface pin is high level, for specifying the default setting to a slave receiver mode, cl ear ?0? to the mst, trx and bb in sbicrb, set ?1? to the pin, ?10? to the sbim, and ?00? to bits swrst1 and swrst0. note: the initialization of a serial bus interf ace circuit must be complete within the time from all devices which are connected to a bus have initialized to and device does not generate a start condition. if not, the dat a can not be received correctly because the other device starts transferring before an end of the initialization of a serial bus interface circuit. (2) start condition and slave address generation confirm a bus free status (bb = 0). set the ack to ?1? and specify a slave addre ss and a direction bit to be transmitted to the sbidbr. by writing ?1? to the mst, trx, bb and pin, the start condition is generated on a bus and then, the slave address and the direction bit which are set to the sbidbr are output. an intsbi interrupt request occurs at the 9th falling edge of a scl clock cycle, and the pin is cleared to ?0?. the scl pin is pulled-down to the low level while the pin is ?0?. when an interrupt request occurs, the trx changes by the hardware according to the direction bit only when an acknowledge signal is returned from the slave device. note 1: do not write a slave addr ess to be output to the sbidbr while data is transferred. if data is written to the sbidbr, data to been outputting may be destroyed. note 2: the bus free must be confirmed by software within 98.0 s (the shortest transmitting time according to the i 2 c bus standard) after setting of the slave address to be output. only when the bus free is confirmed, set ?1? to the mst, trx, bb, and pin to generate the start conditi ons. if the writing of slave address and setting of mst, trx, bb and pin doesn?t finish within 98.0 s, the other masters may start the transferring and the slave address data written in sbidbr may be broken. figure 2.12.11 start condition generation and slave address transfer scl pin sda pin start condition slave address + direction bit a cknowledge signal from a slave device 1 2 345678 9 a6 a5 a4 a3 a2 a1 a0 r/ w pin intsbi interrupt request TMP86FM48 2007-08-24 86fm48-114 (3) 1-word data transfer check the mst by the intsbi interrupt process after an 1-word data transfer is completed, and determine whether the mode is a master or slave. a. when the mst is ?1? (master mode) check the trx and determine whether the mode is a transmitter or receiver. 1. when the trx is ?1? (transmitter mode) test the lrb. when the lrb is ?1?, a receiver does not request data. implement the process to generate a stop condition (described later) and terminate data transfer. when the lrb is ?0?, the receiver requests next data. when the next transmitted data is other than 8 bits, set the bc, set the ack to ?1?, and write the transmitted data to the sbidbr. after writing the data, the pin becomes ?1?, a serial clock pulse is generated fo r transferring a next 1 word of data from the scl pin, and then the 1 word of data is transmitted. after the data is transmitted, and an intsbi interrupt request occurs. the pin become ?0? and the scl pin is set to low level. if the data to be transferred is more than one word in length, repeat the procedure from the lrb test above. figure 2.12.12 example of when bc = ?000?, ack = ?1? 2. when the trx is ?0? (receiver mode) when the next transmitted data is other than of 8 bits, set the bc again. set the ack to ?1? and read the received data from the sbidbr (reading data is undefined immediately after a slave addr ess is sent). after the data is read, the pin becomes ?1?. a serial bus interface circuit outputs a serial clock pulse to the scl to transfer next 1-word of data and sets the sda pin to ?0? at the acknowledge signal timing. an intsbi interrupt request occurs an d the pin becomes ?0?. then a serial bus interface circuit outputs a clock pulse for 1-word of data transfer and the acknowledge signal each time that rece ived data is read from the sbidbr. figure 2.12.13 example of when bc = ?000?, ack = ?1? scl pin sda pin a cknowledge signal from a receiver 1 2 3456789 d7 d6 d5 d4 d3 d2 d1 pin intsbi interrupt request d0 write to sbidbr scl pin sda pin a cknowledge signal to a transmitter 1 2 3456789 d7 d6 d5 d4 d3 d2 d1 pin intsbi interrupt d0 read sbidbr new d7 TMP86FM48 2007-08-24 86fm48-115 to make the transmitter terminate transmit, clear the ack to ?0? before reading data which is 1-word before the last data to be received. a serial bus interface circuit does not generate a clock pulse for the acknowledge signal by clearing ack. in the interrupt routine of end of transmission, when the bc is set to ?001? and read the data, pin is se t to ?1? and generates a clock pulse for a 1-bit data transfer. in this case, since the master device is a receiver, the sda line on a bus keeps the high-level. the transmitter receives the high-level signal as an ack signal. th e receiver indicates to the transmitter that data transfer is complete. after 1-bit data is received and an interrupt request has occurred, generates the stop condition to terminate transmit, generate the stop condition to terminate data transfer. figure 2.12.14 termination of data transfer in master receiver mode b. when the mst is ?0? (slave mode) in the slave mode, a serial bus interface circuit operates either in normal slave mode or in slave mode after losing arbitration. in the slave mode, the conditions of generating intsbi are follows: ? when the received slave address matches to the value set by the i2car ? when a ?general call? is received ? at the end of transferring or receiving after matching of slave address or receiving of ?general call? a serial bus interface circuit changes to a slave mode if arbitration is lost in the master mode. and an intsbi interrupt request occurs when word data transfer terminates after losing arbitration. the behavior of intsbi and pin after losing arbitration are shown in table 2.12.3. table 2.12.3 the behavior of intsbi and pin after losing arbitration when the arbitration lost occurs during transmission of slave address as a master when the arbitration lost occurs during transmission of data as a master transmit mode intsbi intsbi is generated at the termination of word data. pin when the slave address matches the value set by i2car, the pin is cleared to ?0? by generating of intsbi. when the slave address doesn't match the value set by i2car, the pin keeps ?1?. pin keeps ?1?. scl pin sda pin a cknowledge signal sent to a transmitter 1 2 345678 1 d7 d6 d5 d4 d3 d2 d1 pin intsbi interrupt request d0 ?0? ack read sbidbr ?001? bc read sbidbr TMP86FM48 2007-08-24 86fm48-116 check the al (bit3 in the sbisr), the trx (bit6 in the sbisr), the aas (bit2 in the sbisr), and the ad0 (bit1 in the sbisr) and implements processes according to conditions listed in table 2.12.4. table 2.12.4 operation in the slave mode trx al aas ad0 conditions process 1 1 0 a serial bus interfac e circuit loses arbitration when transmitting a slave address. and receives a slave address of which the value of the direction bit sent from another master is ?1?. 1 0 in the slave receiver mode, a serial bus interface circuit receives a slave address of which the value of the direction bit sent from the master is ?1?. set the number of bits in 1 word to the bc and write transmitted data to the sbidbr. 1 0 0 0 in the slave transmitter mode, 1-word data is transmitted. test the lrb. if the lrb is set to ?1?, set the pin to ?1? since the receiver does not request next data. then, clear the trx to ?0? to release the bus. if the lrb is set to ?0?, set the number of bits in 1 word to the bc and write transmitted data to the sbidbr since the receiver requests next data. 1 1/0 a serial bus interfac e circuit loses arbitration when transmitting a slave address. and receives a slave address of which the value of the direction bit sent from another master is ?0? or receives a ?general call?. read the sbidbr for setting the pin to ?1? (reading dummy data) or write ?1? to the pin. 1 0 0 a serial bus interfac e circuit loses arbitration when transmitting a slave address or data. and terminates transferring word data. a serial bus interface circuit is changed to slave mode. to clear al to ?0?, read the sbidbr or write the data to sbidbr. 1 1/0 in the slave receiver mode, a serial bus interface circuit receives a slave address of which the value of the direction bit sent from the master is ?0? or receives ?general call?. read the sbidbr for setting the pin to ?1? (reading dummy data) or write ?1? to the pin. 0 0 0 1/0 in the slave receiver mode, a serial bus interface circuit term inates receiving of 1-word data. set the number of bits in 1-word to the bc and read received data from the sbidbr. note: in the slave mode, if the slave address set in i2car is ?00000000b?, the trx changes to ?1? by receiving the start byte data ?00000001b?. (4) stop condition generation when the bb is ?1?, a sequence of generating a stop condition is started by setting ?1? to the mst, trx and pin, and clear ?0? to the bb. do not modify the contents of the mst, trx, bb, pin until a stop condition is generated on a bus. when a scl line on a bus is pulled-down by other devices, a serial bus interface circuit generates a stop conditio n after they release a scl line. figure 2.12.15 stop condition generation ?1? mst ?1? trx ?0? bb ?1? pin scl pin stop condition sda pin bb (read) pin TMP86FM48 2007-08-24 86fm48-117 (5) restart restart is used to change the direction of data transfer between a master device and a slave device during transferring data. the following explains how to restart a serial bus interface circuit. clear ?0? to the mst, trx and bb and set ?1? to the pin. the sda pin retains the high-level and the scl pin is released. since a stop condition is not generated on a bus, a bus is assumed to be in a busy state from othe r devices. test the bb until it becomes ?0? to check that the scl pin a serial bus interface circuit is released. test the lrb until it becomes ?1? to check that the scl line on a bus is not pulled-down to the low level by other devices. after confirming that a bus stays in a free state, generate a start condition with procedure (2). in order to meet setup time when restarting, take at least 4.7 s of waiting time by software from the time of restarting to confir m that a bus is free until the time to generate a start condition. note: when restarting after receiving in master recever mode, because the device doesn?t send an acknowledgment as a last data, the level of scl line can not be confirmed by reading lrb. therefore, co nfirm the status of scl line by reading p5prd register. figure 2.12.16 timing diagram when restarting start condition sda (pin) scl pin ?0? mst ?0? trx ?0? bb ?1? pin scl (bus) lrb bb pin ?1? mst ?1? trx ?1? bb ?1? pin 4.7 s (min) TMP86FM48 2007-08-24 86fm48-118 2.13 sio (synchronous serial interface) the TMP86FM48 contains two channels of sio (s ynchronous serial interface). these serial interfaces connect to an external device via si1, si2, so1, so2, sck1 and sck2 pins. the si1, si2, so1, so2, sck1 and sck2 pins respectively are shared wi th p05, p11, p06, p10, p07 and p12. when these pins are used as serial interface, the output latches for each port of p0 and p1 must be set to ?1?. because sio1 and sio2 are the same except that the registers and the function pin for each sio are assigned as different specification, explanation here is made of only sio1. the registers for sio1 and sio2 are listed in table below. table 2.13.1 the registers for sio1 and sio2 sio1 sio2 register address register address sio control register sio1cr 0017h sio2cr 001bh sio status register sio1sr 0018h sio2sr 001ch sio receive buffer register sio1rdb 0019h sio2rdb 001dh sio transmit buffer register sio1tdb 0019h sio2tdb 001dh 2.13.1 configuration note: set the register of port correctly for the port assigned as serial interface pins. for details, see the description of the input/output port control register. figure 2.13.1 synchronous serial interface sck1 pin so1 pin (serial data output) si1 pin (serial data input) port ( note ) shift register on transmitte r shift register on receive r internal data bus shift clock intsio1 interrupt sio1sr sio1cr control circuit sio1tdb sio1rdb msb/lsb selection port ( note ) to bus port ( note ) internal clock input TMP86FM48 2007-08-24 86fm48-119 2.13.2 control the sio is controlled using the serial interface control register (sio1cr). the operating status of the serial interface can be inspected by reading the status register (sio1sr). serial interface control register 1 7 6 5 4 3 2 1 0 sios sioinh siom siodir sck (initial value: 0000 0000) sios specify start/stop of transfer 0: stop 1: start sioinh forcibly stops transfer (note 1) 0: ? 1: forcibly stop (automatically cleared to ?0? after stopping) siom selects transfer mode 00: transmit mode 01: receive mode 10: transmit/receive mode 11: reserved siodir selects direction of transfer 0: msb (transfer beginning with bit7) 1: lsb (transfer beginning with bit0) normal 1/2 or idle 1/2 mode tbtcr TMP86FM48 2007-08-24 86fm48-120 serial interface status register 7 6 5 4 3 2 1 0 siof sef txf rxf txerr rxerr (initial value: 0010 00 ** ) siof serial transfer operation status monitor 0: transfer finished 1: transfer in progress sef number of clocks monitor 0: 8 clocks 1: 1 to 7 clocks txf transmit buffer empty flag 0: data exists in transmit buffer 1: no data exists in transmit buffer rxf receive buffer full flag 0: no data exists in receive buffer 1: data exists in receive buffer read only txerr transfer operation error flag read 0: ? (no error exist) 1: transmit buffer under run occurs in an external clock mode. write 0: clear the flag 1: ? (a write of ?1? to this bit is ignored) rxerr receive operation error flag read 0: ? (no error exist) 1: receive buffer over run occurs in an external clock mode. write 0: clear the flag 1: ? (a write of ?1? to this bit is ignored) r/w note 1: the operation error flag (txerr and rxerr) ar e not automatically cleared by stopping transfer with sio1cr TMP86FM48 2007-08-24 86fm48-121 2.13.3 functional description (1) serial clock a. clock source the serial clock can be selected by using sio1cr TMP86FM48 2007-08-24 86fm48-122 2. external clock when an external clock is selected by setting sio1cr TMP86FM48 2007-08-24 86fm48-123 (2) transfer bit direction transfer data direction can be selected by using sio1cr TMP86FM48 2007-08-24 86fm48-124 2. lsb transmit/receive mode lsb transmit/receive mode are selected by setting sio1cr TMP86FM48 2007-08-24 86fm48-125 (3) transfer modes transmit, receive and transmit/receive mode are selected by using sio1cr TMP86FM48 2007-08-24 86fm48-126 3. stopping the transmit operation there are two ways for stopping transmits operation. ? the way of clearing sio1cr TMP86FM48 2007-08-24 86fm48-127 figure 2.13.10 example of external clock and msb transmit mode figure 2.13.11 hold time of the end of transmit mode t sodh sck1 pin sio1sr |