Part Number Hot Search : 
1500A PT226 BU2515DX HBL21000 58786 00104 PCK2001 31202G
Product Description
Full Text Search
 

To Download SN8P27142 Datasheet File

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


  Datasheet File OCR Text:
  sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 1 v1.4 sn8p2714x_2715 user?s manual v1.4 sn8p2714 SN8P27142 sn8p27143 sn8p2715 s s o o n n i i x x 8 8 - - b b i i t t m m i i c c r r o o - - c c o o n n t t r r o o l l l l e e r r sonix reserves the right to make change without further notice to any products herein to improv e reliability, function or desig n. sonix does not assume any liability arising out of the application or use of any product or circuit described herei n; neither does it convey a ny license under its patent rights nor the rights of others. sonix products are not designed, intended, or authorized for us as components in systems inten ded, for surgical implant into the body, or other applications intended to support or sustain life, or for any other application in which the fai lure of the sonix product could create a situation where personal injury or death may occu r. should buyer purchase or use sonix products for any such uni ntended or unauthorized application. buyer shall indemnify and hold sonix and its officers, employees, subs idiaries, affiliates and distri butors harmless against all claims, cost, damages, and expenses, and reas onable attorney fees arising out of, dire ctly or indirectly, any claim of pers onal injury or death associated with such unintended or unauthorized use even if such claim alleges that sonix was negligent regarding the design or manufacture of the part.
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 2 v1.4 amendment history version date description ver 0.1 aug. 2004 preliminary version first issue ver 0.2 jan. 2005 1. add SN8P27142/ sn8p27143 relative data. 2. fix adc clock and timer clock description. 3. add lvd36 relative information. 4. correct the lvd24 bit location from bit 3 to bit 4 in pflag register description. 5. modify lvd code option related description 6. modify tc0rate and tc1rate table. 7. add tc0x8 and tc1x8 notice. 8. release the rom address 0x04 ~ 0x07 as general-purpose area. 9. remove the instruction limitation at interrupt vector address (0x08) 10. change ide support version to m2ide v1.04 11. modify pin circuit diagram. 12. there is no schmitt trigger input in port 4. 13. add description of p0.3 without wakeup function ver 0.3 mar. 2005 1. modify zero flag description. 2. in instruction set table, change ?s = 0?, ot herwise ?s = 1? to ?s = 1?, otherwise ?s = 0? 3. fix adc conversion time formula. 4. remove ?note:for 12-bit resoluti on the conversion time is 16 steps?. 5. remove ?note: please use "@rst_wd t" macro to clear the watchdog timer successfully both in s8kd-2 ice emulation and real chip.? 6. modify watchdog reset section 7. fixed the slow mode current of electrical characteristic table. sept 2005 1. modify programming pin mapping. 2. modify program check list. 3. modify p13 avref pin description 4. modify 27142/143 pin assignment. 5. modify p57,p66 tc0rate tc1rate. 6. modify p57,p66:tc0x8=1 fosc/2~fosc/256 to fosc/1~fosc/128 7. modify p107 slow mode current. 8. add p97 ?note?. ver 1.0 nov.2005 1. add brown-out reset circuit. 2. working voltage vs. frequency graphs. ver 1.1 nov.2005 1. add adc current. 2. modify topr value. ver 1.2 dec.2005 1. remove 32k mode. 2. modify p108 sn8p271xaxd to sn8p271xxd. 3. modify p52 wakeup trigger signal. 4. remove characteristic graphs. 5. modify reset section. 6. limit fcpu=fosc/4~./8 when noise filter enable 7. remove pc ver 1.3 sep.2006 1. modify 15.2 standard el ectrical characteristic. 2. add 15.3 characteristic graphs. 3. add chapter17 marking definition. ver 1.4 feb 2007 1. modify electrical characteristic. 2. modify rst/p0.3/vpp pin discription.
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 3 v1.4 table of contents amendment history .............................................................................................................. 2 1 product overvi ew............................................................................................................. .... 8 1.1 features of sn8p2710 s eries ........................................................................................... 8 1.2 system block diagram ................................................................................................. 10 1.3 pin assignme nt................................................................................................................ 11 1.3.1 SN8P27142 pi n assignm ent .......................................................................................... 11 1.3.2 sn8p27143 pi n assignm ent .......................................................................................... 11 1.3.3 sn8p2714k pi n assignm ent .......................................................................................... 12 1.3.4 sn8p2715p pi n assignm ent .......................................................................................... 12 1.4 pin descript ions............................................................................................................. 13 1.5 pin circuit diagra ms ..................................................................................................... 14 2 code opt ion t able............................................................................................................ ... 15 3 address sp aces ............................................................................................................... .... 16 3.1 program memory (rom) ............................................................................................... 16 3.1.1 o vervi ew ................................................................................................................. ... 16 3.1.2 user reset vec tor address (0000h)................................................................. 17 3.1.3 interrupt vecto r address ( 0008h) ................................................................... 17 3.1.4 general purpose pr ogram memory area ..................................................... 19 3.1.5 lookup tabl e descri ption................................................................................... 19 3.1.6 jump tabl e descri ption ........................................................................................ 21 3.2 data memory (ram)......................................................................................................... 23 3.2.1 o vervi ew ................................................................................................................. ... 23 3.3 working registe rs ....................................................................................................... 24 3.3.1 y, z registe rs ........................................................................................................... 24 3.3.2 r re giste rs .............................................................................................................. .25 3.4 program flag.................................................................................................................. 25 3.4.1 reset flag ............................................................................................................... .. 25 3.4.2 lvd 2. 4v fl ag............................................................................................................ .. 25 3.4.3 lvd 3. 6v fl ag............................................................................................................ .. 25 3.4.4 carry flag............................................................................................................... .. 26 3.4.5 decimal carry fl ag................................................................................................ 26 3.4.6 zero flag ................................................................................................................ ... 26 3.5 accumulat or................................................................................................................... 2 7 3.6 stack operation s .......................................................................................................... 28 3.6.1 o vervi ew ................................................................................................................. ... 28
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 4 v1.4 3.6.2 stack registe rs...................................................................................................... 29 3.6.3 stack oper ation exam ple.................................................................................... 30 3.7 program counter ......................................................................................................... 31 3.7.1 one addr ess skippi ng ........................................................................................... 32 3.7.2 multi-addr ess jumpin g ......................................................................................... 33 4 addressing mode .............................................................................................................. ... 34 4.1 overvi ew....................................................................................................................... .... 34 4.1.1 immediate a ddressing mode ............................................................................... 34 4.1.2 directly a ddressing mode ................................................................................. 34 4.1.3 indirectly addressing mode.............................................................................. 34 4.1.4 to access data in ram bank 0 .............................................................................. 35 5 system re gister.............................................................................................................. ..... 36 5.1 overvi ew....................................................................................................................... .... 36 5.2 system register arrangement (bank 0) ................................................................ 36 5.2.1 bytes of syst em regis ter..................................................................................... 36 5.2.2 bits of syst em regis ter ........................................................................................ 37 6 r eset........................................................................................................................ ................. 39 6.1 overvi ew....................................................................................................................... .... 39 6.2 power on reset .............................................................................................................. 40 6.3 watchdog reset ............................................................................................................ 40 6.4 brown out reset ........................................................................................................... 41 6.4.1 brown out descript ion........................................................................................ 41 6.4.2 the system operatin g voltage de csript ion ............................................... 42 6.4.3 brown out reset improvem ent......................................................................... 42 6.5 external reset ............................................................................................................... 44 6.6 external reset circuit ............................................................................................... 44 6.6.1 simply rc reset cir cuit ................................................................................................. 4 4 6.6.2 diode & rc re set circu it ............................................................................................... 45 6.6.3 zener diode reset cir cuit .............................................................................................. 45 6.6.4 voltage bias reset cir cuit.............................................................................................. 4 6 6.6.5 external reset ic ........................................................................................................ ... 47 7 oscilla tors.................................................................................................................. ......... 48 7.1 overvi ew....................................................................................................................... .... 48 7.1.1 oscm registe r descri ption ................................................................................ 49 7.1.2 external high- speed oscilla tor...................................................................... 49 7.1.3 high clock osci llator code option ............................................................... 49 7.1.4 system osci llator ci rcuits ............................................................................... 50
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 5 v1.4 7.1.5 external rc oscilla tor frequency m easurem ent............................................................ 51 7.2 internal low-speed oscillato r............................................................................... 52 7.3 system mode descript ion........................................................................................... 53 7.3.1 o vervi ew ................................................................................................................. ... 53 7.3.2 normal mode ............................................................................................................ 53 7.3.3 slow mode ................................................................................................................ .53 7.3.4 power down (sleep) mode ................................................................................... 53 7.4 system mode control.................................................................................................. 54 7.4.1 sn8p2710 system mode block di agram ............................................................ 54 7.4.2 system mode switchi ng ....................................................................................... 55 7.5 wakeup time ..................................................................................................................... 56 7.5.1 o vervi ew ................................................................................................................. ... 56 7.5.2 hardwar e wakeu p .................................................................................................. 56 8 timers counter s .............................................................................................................. .... 57 8.1 watchdog timer (wdt).................................................................................................. 57 8.2 timer counter 0 (tc0) .................................................................................................... 58 8.2.1 o vervi ew ................................................................................................................. ... 58 8.2.2 tc0m mode registe r............................................................................................... 59 8.2.3 tc0c count ing regis ter....................................................................................... 61 8.2.4 tc0r auto-l oad regis ter ..................................................................................... 63 8.2.5 tc0 timer counter operation sequence ....................................................... 64 8.2.6 tc0 clock frequency output (b uzzer) ........................................................... 66 8.3 timer counter 1 (tc1) .................................................................................................... 67 8.3.1 o vervi ew ................................................................................................................. ... 67 8.3.2 tc1m mode registe r............................................................................................... 68 8.3.3 tc1c count ing regis ter....................................................................................... 70 8.3.4 tc1r auto-l oad regis ter ..................................................................................... 72 8.3.5 tc1 timer counter operation sequence ....................................................... 73 8.3.6 tc1 clock frequency output (b uzzer) ........................................................... 75 8.4 pwm function descript ion ......................................................................................... 76 8.4.1 o vervi ew ................................................................................................................. ... 76 8.4.2 pwm program descri ption.................................................................................. 77 8.4.3 pwm duty wit h tcxr c hanging ..................................................................................... 78 8.4.4 tcxirq and pwm du ty ................................................................................................. 79 9 inte rrupt .................................................................................................................... ............ 80 9.1 overvi ew....................................................................................................................... .... 80 9.2 inten interrupt enable registe r ............................................................................ 80 9.3 intrq interrupt request registe r......................................................................... 81
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 6 v1.4 9.4 p0.0 interrupt trigger edge control registe r ................................................ 81 9.5 interrupt operation descript ion........................................................................... 82 9.5.1 gie global in terrupt oper ation ...................................................................... 82 9.5.2 int0 (p0.0) interrupt o peration ......................................................................... 83 9.5.3 int1 (p0.1) interrupt o peration ......................................................................... 83 9.5.4 tc0 interrup t operat ion ..................................................................................... 85 9.5.5 tc1 interrup t operat ion ..................................................................................... 86 9.5.6 multi-inte rrupt oper ation ................................................................................. 87 10 i/o po rt.................................................................................................................... ............... 89 10.1 overvi ew....................................................................................................................... .. 89 10.2 i/o port function table ............................................................................................. 90 10.3 pull-up resister s ........................................................................................................ 91 10.4 i/o port data registe r ............................................................................................... 94 11 8-channel analog to digit al conver ter................................................................. 96 11.1 overvi ew....................................................................................................................... .. 96 11.2 adm registe r ................................................................................................................. 97 11.3 adr registe rs ............................................................................................................... 97 11.4 adb registe rs ............................................................................................................... 97 11.5 p4con registe rs .......................................................................................................... 98 11.6 adc converting time................................................................................................... 99 11.7 adc circuit ................................................................................................................... 100 12 7-bit digital to analog conver ter .......................................................................... 101 12.1 overvi ew....................................................................................................................... 101 12.2 dam register ............................................................................................................... 102 12.3 d/a converter operation ....................................................................................... 102 13 coding issue ................................................................................................................ ...... 103 13.1 template code ............................................................................................................ 103 13.2 program check list .................................................................................................. 107 14 instruction set table ................................................................................................... 108 15 electrical charact eristic ......................................................................................... 109 15.1 absolute maximum rating ....................................................................................... 109 15.2 standard electrical characteris tic................................................................ 109 15.3 characteristic graphs ........................................................................................... 110 16 development tools ........................................................................................................ 114 16.1 d evelopment t ool v ersion ............................................................................................. 114
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 7 v1.4 16.1.1 ice (in circ uit emulat ion) ............................................................................................ 11 4 16.1.2 otp writer .............................................................................................................. ... 114 16.1.3 ide (integrated devel opment envir onment) ............................................................... 114 16.2 sn8p2715/sn8p2714 ev-kit .......................................................................................... 115 16.2.1 pcb des cription................................................................................................... 115 16.3 sn8p2715/14 ev-kit connnect to sn8ice 2k .......................................................... 116 16.4 transition board for otp progtrammi ng........................................................ 117 16.4.1 sn8p2715/2715 rev. b tr ansition bo ard ......................................................... 117 16.4.2 connnect rev. b transit ion board to easy writer ................................ 117 16.5 otp p rogramming p in to t ransition b oard m apping ..................................................... 118 16.5.1 the pin assignment of easy and mp ez writer transiti on board socke t: .................... 118 16.5.2 the pin assignment of writer v3.0 transition board socke t: ....................................... 118 16.5.3 sn8p2710 series progr amming pin m apping: ........................................................... 119 17 marking de finition .......................................................................................................... 120 17.1 introduct ion............................................................................................................... 120 17.2 marking indetification system ............................................................................. 120 17.3 marking example ........................................................................................................ 121 17.4 datecode system ....................................................................................................... 121 18 package info rmation .................................................................................................... 122 18.1 p-dip18 pin...................................................................................................................... 122 18.2 sop18 pin........................................................................................................................ 123 18.3 p-dip 20 pin ..................................................................................................................... 124 18.4 sop 20 pin ....................................................................................................................... 125 18.5 ssop20 pin ..................................................................................................................... 126 18.6 sk-dip28 pin ................................................................................................................... 127 18.7 sop28 pin........................................................................................................................ 128 18.8 p-dip 32 pin ..................................................................................................................... 129 18.9 sop 32 pin ....................................................................................................................... 129
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 8 v1.4 1 product overview 1.1 features of sn8p2710 series ? memory configuration ? four interrupt sources otp rom size: 2k * 16 bits. two internal interrupts: tc0, tc1 ram size: 128 * 8 bits two external interrupts: int0, int1 eight levels stack buffer ? two 8-bit timer/counter ? i/o pin configuration tc0: auto-reload timer/counter/pwm0/buzzer output input only pin: p0 tc1: auto-reload timer/counter/pwm1/buzzer output bi-directional: p2, p4, p5 ? on chip watchdog timer. wakeup: p0.0, p0.1, p0.2 external interrupt: p0.0, p0.1 ? system clocks and operating modes pull-up resisters: p0, p2, p4, p5 external high clock: rc type up to 10 mhz p4 pins shared with adc inputs. external high clock: crystal type up to 16 mhz ? max 8-channel 12-bit adc. internal low clock: rc type 16khz(3v), 32khz(5v) normal mode: both high and low clock active ? one channel 7-bit dac. slow mode: low clock only sleep mode: both high and low clock stop ? powerful instructions one clocks per instruction cycle (1t) most of instructions are one cycle only ? package (chip form support) all rom area lookup table function (mov c) SN8P27142: p-dip 18 pins, sop 18pins sn8p27143:p-dip 20 pins, sop 20 pins, ssop 20 pins sn8p2714: sk-dip 28 pins, sop 28pins sn8p2715: p-dip 32 pins, sop 32 pins features selection table timer pwm chip rom ram stack t0 tc0 tc1 i/o adc dac buzzer sio wakeup pin no. package SN8P27142 2k*16 128 8 - v v 15 5ch - 2 - 2 dip18/sop18 sn8p27143 2k*16 128 8 - v v 16 6ch - 2 - 2 dip20/sop20/ssop20 sn8p2714 2k*16 128 8 - v v 23 8ch 1ch 2 - 3 skdip28/sop28 sn8p2715 2k*16 128 8 - v v 27 8ch 1ch 2 - 3 dip32/sop32 sn8p2704a 4k*16 256 8 v v v 18 5ch 1ch 2 1 8 skdip28/sop28 sn8p2705a 4k*16 256 8 v v v 23 8ch 1ch 2 1 9 dip32/sop32 note: for sn8p27143 and SN8P27142 must configure p02r (b it 2 of p0ur) as ?1? to avoid sleep mode fail.
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 9 v1.4 compare sn8p2714/15 to sn8p2704a/05a item sn8p2714/15 sn8p2704a/05a ac noise immunity capability excellent (add an 47uf bypass capacitor between vdd and gnd) excellent (add an 47uf bypass capacitor between vdd and gnd) memory rom: 2k x 16 ram: 128 x 8 rom: 4k x 16 ram: 256 x 8 maximum i/o pins 23 i/o in 28 pins package 27 i/o in 32 pins package 18 i/o in 28 pins package 23 i/o in 32 pins package high speed pwm pwm resolution: 8bit/6bit/5bit/4bit 8bit pwm up to 62.5k at 16mhz 4bit pwm up to 1000k at 16mhz pwm resolution: 8bit/6bit/5bit/4bit 8bit pwm up to 7.8125k at 16mhz 4bit pwm up to 125k at 16mhz programmable open-drain output n/ a p1.0 / p1.1 / p5.2 (so) b0mov m, i no limitation ?i? can?t be 0e6h or 0e7h b0xch a, m no limitation the address of m can?t be 80h ~ ffh valid instruction in rom address 8 no limitation jmp or nop adc interrupt no yes adc clock frequency four kinds of setting (configuration by adcks [1:0]) seven kinds of setting (configuration by adcks [2:0]) valid range of tc0c/tc1c/tc0r/tc1r 0x00 ~ 0xff 0x00 ~ 0xfe green mode no yes sio function no yes lvd level: 2.0v always on 1.8v always on port 0 input only port bi-direction port interrupt vector instruction no limitation nop/jmp only push/pop instruction no yes
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 10 v1.4 1.2 system block diagram figure 1-1.simplified system block diagram pc ir otp rom h-osc timing generator ram system register alu acc interrup t control timer & counter port 0 port 2 port 4 port 5 flags dac adc dao ain0~ain7 internal clk pwm1 pwm0 pwm0/bu zzer0 pwm1/bu zzer1 lo w vo lt detector watch-dog timer pc ir otp rom h-osc timing generator ram system register alu acc interrup t control timer & counter port 0 port 2 port 4 port 5 flags dac adc dao ain0~ain7 internal clk pwm1 pwm0 pwm0/bu zzer0 pwm1/bu zzer1 lo w vo lt detector watch-dog timer
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 11 v1.4 1.3 pin assignment format description sn8p271xy y = k > sk-dip p > p-dip s> sop 1.3.1 SN8P27142 pin assignment p0.1 1 u 18 p0.0 p2.0 2 17 p5.0 p2.1 3 16 p5.1 p5.6/xout 4 15 p5.3/bz1/pwm1 xin 5 14 p5.4/bz0/pwm0 vss 6 13 p0.3/rst/vpp p4.4/ain4 7 12 vdd p4.3/ain3 8 11 p4.0/ain0 p4.2/ain2 9 10 p4.1/ain1 SN8P27142p SN8P27142s 1.3.2 sn8p27143 pin assignment p2.0 1 u 20 p0.1 p2.1 2 19 p0.0 p5.6/xout 3 18 p5.0 xin 4 17 p5.1 vss 5 16 p5.3/bz1/pwm1 p4.5/ain5 6 15 p5.4/bz0/pwm0 p4.4/ain4 7 14 p0.3/rst/vpp p4.3/ain3 8 13 vdd p4.2/ain2 9 12 avrefh p4.1/ain1 10 11 p4.0/ain0 sn8p27143p sn8p27143s sn8p27143x ? note: for sn8p27143 and SN8P27142 must configure p02r (bit 2 of p0ur) as ?1? to avoid sleep mode fail. ? note: the adc reference voltage (avrefh) of SN8P27142/sn8p27143 is vdd.
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 12 v1.4 1.3.3 sn8p2714k pin assignment p5.3/bz1/pwm1 1 u 28 p5.4/bz0/pwm0 p5.2 2 27 dac p5.1 3 26 p0.3/rst/vpp p5.0 4 25 vdd p0.0/int0 5 24 avrefh p0.1/int1 6 23 p4.0/ain0 p0.2 7 22 p4.1/ain1 p2.0 8 21 p4.2/ain2 p2.1 9 20 p4.3/ain3 p2.2 10 19 p4.4/ain4 p2.3 11 18 p4.5/ain5 p2.4 12 17 p4.6/ain6 p5.6/xout 13 16 p4.7/ain7 xin 14 15 vss sn8p2714k sn8p2714s 1.3.4 sn8p2715p pin assignment p5.5 1 u 32 dao p5.4/bz0/pwm0 2 31 p0.3/rst/vpp p5.3/bz1/pwm1 3 30 vdd p5.2 4 29 avrefh p5.1 5 28 p4.0/ain0 p5.0 6 27 p4.1/ain1 p0.0/int0 7 26 p4.2/ain2 p0.1/int1 8 25 p4.3/ain3 p0.2 9 24 p4.4/ain4 p2.0 10 23 p4.5/ain5 p2.1 11 22 p4.6/ain6 p2.2 12 21 p4.7/ain7 p2.3 13 20 vss p2.4 14 19 xin p2.5 15 18 p5.6/xout p2.6 16 17 p2.7 sn8p2715p sn8p2715s
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 13 v1.4 1.4 pin descriptions pin name type description p0 [1:0] / int [1:0] i p0 [1:0]: input onl y pin/ wakeup/pull-up/schmitt trigger input int [1:0]: external interrupt p0 .2 i p0.2: input only pin/wake up/pull-up/schmitt trigger input p2 [7:0] i/o p2 [7:0] bi-direction pins/pull-up/schmitt trigger input p4 [7:0] / ain [7:0] i/o bi-direction pins/pull-up /adc input/ without schmitt trigger input p5 [5:0] i/o bi-direction pins /pull-up/schmitt trigger input p5.4: pwm0/bz0, p5.3: pwm1/bz1 avrefh i adc highest reference voltage input (note : the adc reference voltage (avrefh) of SN8P27142 and sn8p27143 are vdd.) dao o current type dac output p0.3/rst/vpp i/p p0.3: schm itt trigger input pin / no pull-up, no wakeup / in rc mode p0.3 is input only pin without pull-up re sistor under p0.3 mode. add the 100 ohm external resistor on p0.3, when it is set to be input pin. rst: external reset, active ?low? vpp: otp programming pin xin i external oscillator input pin. / external rc oscillator input xout/p5.6 i/o xout: external oscillator output pin. p5.6: bi-direction pin/pull-up/schmitt trigger input in rc mode vdd, vss p power supply pins. table 1-1. sn8p2714/15 pin description
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 14 v1.4 1.5 pin circuit diagrams port 0.1 and p0.2 structure: pin int. bus int. rst pull-up pnur port 0.3 structure: pin ext. reset code option int. bus int. rst port 2, 5 structure: pull-up pin output latch pnm, pnur input bus pnm output bus port 4 structure: gchs int. adc p4con pull-up output latch pnm, pnur input bus pnm output bus pin figure 1-2. pin circuit diagram
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 15 v1.4 2 code option table code option content function description ext_rc low cost external rc oscillato r for high clock oscillator. output the fcpu clock from xout pin. 12m_x?tal high speed crystal /resonator (e.g. 12mhz ~ 16mhz) for high clock oscillator. high_clk 4m_x?tal middle speed crystal /resonator (e.g . 4mhz ~ 10mhz) for high clock oscillator. enable enable noise filter and the fcpu is fosc/4~fosc/8. noise_filter disable disable noise filter and the fcpu is fosc/1~fosc/8. always_on watchdog timer always on even in sleep (power down) mode. enable normal mode: enable watchdog timer sleep mode: stop watchdog timer stop watch_dog disable disable watchdog function. fosc/1 instruction cycle is oscillator clock. notice: in fosc/1, noise filter must be disabled. fosc/2 instruction cycle is 2 oscillator clocks. notice: in fosc/2, noise filter must be disabled. fosc/4 instruction cycle is 4 oscillator clocks. fcpu fosc/8 instruction cycle is 8 oscillator clocks. enable enable rom code security function. security disable disable rom code security function. reset enable external reset pin rst_p0.3 p0.3 enable p0.3 input only pin without pull-up register lvd_l lvd will reset chip if vdd is below 2.0v lvd_m lvd will reset chip if vdd is below 2.0v enable lvd24 bit of pflag register for 2.4v low voltage indicator. lvd lvd_h lvd will reset chip if vdd is below 2.4v enable lvd36 bit of pflag register for 3.6v low voltage indicator. table 2-1. code option table of sn8p2714x/2715 notice: ? in high noisy environment, enable ?noise filter? and set watch_dog as ?always_on? is strongly recommended. ? enable ?noise filter? will limit the fcpu = fosc/4 or fosc/8 ? fcpu code option is only available for high clock ? fosc = fhosc (external high clock) in normal mode. ? fosc = flosc (internal low rc clock) in slow mode. ? in slow mode, fcpu = fosc / 4.
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 16 v1.4 3 address spaces 3.1 program memory (rom) 3.1.1 overview rom maps for sn8p2710 devices provide 2k x 16-bit ot p programmable memory. the sn8p2710 program memory is able to fetch instructions through 12-bit wide pc (pr ogram counter) and can look up rom data by using rom code registers (r, x, y, z). in standard configuration, t he device?s 2,048 x 16-bit program memory has four areas: ? 1-word reset vector addresses ? 1-word interrupt vector addresses ? 4-words reserved area ? 2k words all of the program memory is parti tioned into three coding areas. the 1 st area is located from 00h to 07h(the reset vector area), the 2 nd area is for the interrupt vector (0008h) and the 3 ed area is user code area from 0009h to 07fbh. rom 0000h reset vector user reset vector 0001h jump to user start address 0002h jump to user start address 0003h jump to user start address 0004h jump to user start address 0005h jump to user start address 0006h jump to user start address 0007h general purpose area jump to user start address 0008h interrupt vector user interrupt vector 0009h user program . . 000fh 0010h 0011h . . 07fbh general purpose area end of user program 07fch . 07ffh code option figure 3-1 rom address structure
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 17 v1.4 3.1.2 user reset vector address (0000h) a 1-word vector address area is used to execute system re set. after power on reset or watchdog timer overflow reset, then the chip will restart the program from address 0000h and all system registers will be set as default values. the following example shows the way to define t he reset vector in the program memory. a example: after power on reset, external reset active or reset by watchdog timer overflow. org 0 ; 0000h jmp start ; jump to user program address. . ; org 10h start: ; 0010h, the head of user program. . ; user program . . . endp ; end of program 3.1.3 interrupt vector address (0008h) a 1-word vector address area is used to execute interrupt request. if any interrupt servic e is executed, the program counter (pc) value is stored in stack buffer and points to 0008h of program memory to execute the vectored interrupt. users have to define the interrupt vector and the following example shows the way to define the interrupt vector in the program memory. a example 1: this demo program includes interrupt ser vice routine and the user program is behind the interrupt service routine. org 0 ; 0000h jmp start ; jump to user program address. . org 8 ; interrupt service routine b0xch a, accbuf ; b0xch doesn?t change c, z flag b0mov a, pflag b0mov pflagbuf, a ; save pflag register in a buffer . ; user code . ; user code b0mov a, pflagbuf b0mov pflag, a ; restore pflag register from buffer b0xch a, accbuf reti ; end of interrupt service routine start: ; the head of user program. . ; user program . . jmp start ; end of user program endp ; end of program
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 18 v1.4 a example 2: the demo program includes interrupt service routine and the address of interrupt service routine is in a special address of general-purpose area. org 0 ; 0000h jmp start ; jump to user program address. . ; 0001h ~ 0007h are reserved org 08 jmp my_irq ; 0008h, jump to interrupt service routine address org 10h start: ; 0010h, the head of user program. . ; user program . . . jmp start ; end of user program my_irq: ;the head of interrupt service routine b0xch a, accbuf ; b0xch doesn?t change c, z flag b0mov a, pflag b0mov pflagbuf, a ; save pflag register in a buffer . ; user code . ; user code b0mov a, pflagbuf b0mov pflag, a ; restore pflag register from buffer reti ; end of interrupt service routine endp ; end of program ? note: it is easy to get the rules of sonix program from demo programs given above. these points are as following. 1.the address 0000h is a ?jmp? instruction to make the program go to general-purpose rom area. 2. the interrupt service starts from 0008h. users can put the whole interrupt service routine from 0008h (example1) or to put a ?jmp? instruction in 0008h then place the interrupt service routine in other general-purpose rom area (example2) to get more modularized coding style.
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 19 v1.4 3.1.4 general purpose program memory area the rom locations 0001h~0007h and 0009h~07fbh are us ed as general-purpose memory. the area is stored instruction?s op-code and look-up table data. the sn8p2710 includes jump table function by using program counter (pc) and look-up table function by us ing rom code registers (r, y, z). the boundary of program memory is separated by the high-by te program counter (pch) every 100h. in jump table function and look-up table function, the program count er can?t leap over the boundary by program counter automatically. users need to modify the pch value to ?pch+1? as the pcl overflow (from 0ffh to 000h). 3.1.5 lookup table description in the rom?s data lookup function, y register to the highes t 8-bit and z register to the lowest 8-bit data of rom address. after movc instruction is ex ecuted, the low-byte data of rom then will be stored in acc and high-byte data stored in r register. a example: to look up the rom data located ?table1?. b0mov y, #table1$m ; to set lookup table1?s middle address b0mov z, #table1$l ; to set lookup table1?s low address. movc ; to lookup data, r = 00h, acc = 35h ; ; increment the index address for next address incms z ; z+1 jmp @f ; not overflow incms y ; z overflow (ffh ? 00), ? y=y+1 nop ; not overflow ; @@: movc ; to lookup data, r = 51h, acc = 05h. . . ; table1: dw 0035h ; to define a word (16 bits) data. dw 5105h ; ? dw 2012h ; ? ? causion: the y register can?t increase automatically if z register cross boundary from 0xff to 0x00. therefore, user must take care such situation to avoid loop-up table errors. if z register overflow, y register must be added one. the following inc_yz macro shows a simple method to process y and z registers automatically. ? note: because the program counter (pc) is only 12-bit, the x register is useless in the application. users can omit ?b0mov x, #table1$h?. sonix ice support more larger program memory addressing capability. so make sure x register is ?0? to avoid unpredicted error in loop-up table operation. a example: inc_yz macro inc_yz macro incms z ; z+1 jmp @f ; not overflow incms y ; y+1 nop ; not overflow @@: endm
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 20 v1.4 the other coding style of loop-up table is to add y or z index register by accumulator. be careful if carry happen. refer following example for detailed information: a example: increase y and z register by b0add/add instruction b0mov y, #table1$m ; to set lookup table?s middle address. b0mov z, #table1$l ; to set lookup table?s low address. b0mov a, buf ; z = z + buf. b0add z, a b0bts1 fc ; check the carry flag. jmp getdata ; fc = 0 incms y ; fc = 1. y+1. nop getdata: ; movc ; to lookup data. if buf = 0, data is 0x0035 ; if buf = 1, data is 0x5105 ; if buf = 2, data is 0x2012 . . . . ; table1: dw 0035h ; to define a word (16 bits) data. dw 5105h ; ? dw 2012h ; ?
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 21 v1.4 3.1.6 jump table description the jump table operation is one of multi-address jumping function. add low-byte pr ogram counter (pcl) and acc value to get one new pcl. the new program counter (pc) point s to a series jump instructions as a listing table. the way is easy to make a multi-stage program. when carry flag occurs after executing of ?add pcl, a?, it will not affect pch regi ster. users have to check if the jump table leaps over the rom page boundary or the listing file gener ated by sonix assembly software. if the jump table leaps over the rom page boundary (e.g. from xxffh to xx00h), move the jump table to the top of next program memory page (xx00h). here one page mean 256 words. a example : if pc = 0323h (pch = 03h pcl = 23h) org 0x0100 ; the jump table is from the head of the rom boundary b0add pcl, a ; pcl = pcl + acc, the pch can?t be changed. jmp a0point ; acc = 0, jump to a0point jmp a1point ; acc = 1, jump to a1point jmp a2point ; acc = 2, jump to a2point jmp a3point ; acc = 3, jump to a3point in following example, the jump table starts at 0x00fd. when execute b0add pcl, a. if acc = 0 or 1, the jump table points to the right address. if the acc is larger then 1 will cause error because pch doesn?t increase one automatically. we can see the pcl = 0 when acc = 2 but the pch still keep in 0. the program counter (pc) will point to a wrong address 0x0000 and crash system operation. it is important to check whether the jump table crosses over the boundary (xxffh to xx00h). a good coding style is to put the jump table at the start of rom boundary (e.g. 0100h). a example: if ?jump table? crosses over rom boundary will cause errors. rom address . . . . . . 0x00fd b0add pcl, a ; pcl = pcl + acc, the pch can?t be changed. 0x00fe jmp a0point ; acc = 0 0x00ff jmp a1point ; acc = 1 0x0100 jmp a2point ; acc = 2 ? jump table cross boundary here 0x0101 jmp a3point ; acc = 3 . . . . sonix provides a macro for safe jump table function. this macro will check the rom boundary and move the jump table to the right position automatically . the side effect of this macro is maybe wasting some rom size. notice the maximum jmp table number for this macro is limited under 254. @jmp_a macro val if (($+1) !& 0xff00) !!= (($+(val)) !& 0xff00) jmp ($ | 0xff) org ($ | 0xff) endif add pcl, a endm ? note: ?val? is the number of the jump table listing number.
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 22 v1.4 a example: ?@jmp_a? application in sonix macro file called ?macro3.h?. b0mov a, buf0 ; ?buf0? is from 0 to 4. @jmp_a 5 ; the number of the jump table listing is five. jmp a0point ; if acc = 0, jump to a0point jmp a1point ; acc = 1, jump to a1point jmp a2point ; acc = 2, jump to a2point jmp a3point ; acc = 3, jump to a3point jmp a4point ; acc = 4, jump to a4point if the jump table position is from 00fdh to 0101h, the ?@jmp_ a? macro will make the jump table to start from 0100h.
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 23 v1.4 3.2 data memory (ram) 3.2.1 overview the sn8p2710 has internally built-in the data memory up to 128 bytes for storing the general-purpose data. for sn8p2710 ? 128 * 8-bit general purpose area in bank 0 ? 128 * 8-bit system special register area the memory is located in bank 0. the bank 0, using t he first 128-byte location assigned as general-purpose area, and the remaining 128-byte in bank 0 as system register. ram location 000h 000h~07fh of bank 0 = to store general- ? purpose data (128 bytes). ? ? ? ? 07fh general purpose area 080h 080h~0ffh of bank 0 = to store system ? registers (128 bytes). ? ? ? ? system register bank 0 0ffh end of bank 0 area figure 3-2 ram location of sn8p2710 ? note: the undefined locations of system register ar ea are logic ?high? after executing read instruction ?mov a, m?.
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 24 v1.4 3.3 working registers the locations 82h to 84h of ram bank 0 in data memory stores the specially defined registers su ch as register r, y, z, respectively shown in the following table. these regist ers can use as the general purpose of working buffer and be used to access rom?s and ram?s data. for instance, all of the rom?s table can be looked-up with r, y and z registers. the data of ram memory can be i ndirectly accessed with y and z registers. 80h 81h 82h 83h 84h 85h ram - - r z y - - - r/w r/w r/w - 3.3.1 y, z registers the y and z registers are the 8-bit buffers. there are three ma jor functions of these regist ers. first, y and z registers can be used as working registers. second, these two regist ers can be used as data pointers for @yz register. third, the registers can be address rom location in order to look-up rom data. y initial value = xxxx xxxx 084h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 y ybit7 ybit6 ybit5 ybit4 ybit3 ybit2 ybit1 ybit0 r/w r/w r/w r/w r/w r/w r/w r/w z initial value = xxxx xxxx 083h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 z zbit7 zbit6 zbit5 zbit4 zbit3 zbit2 zbit1 zbit0 r/w r/w r/w r/w r/w r/w r/w r/w the @yz that is data point_1 index bu ffer located at address e7h in ram bank 0. it employs y and z registers to addressing ram location in order to read/write data through a cc. the lower 4-bit of y register is pointed to ram bank number and z register is pointed to ram address number, respectively. the higher 4-bit data of y register is truncated in ram indirectly access mode. a example: if want to read a data from ram address 25h of bank 0, it can use indirectly addressing mode to access data as following. b0mov y, #00h ; to set ram bank 0 for y register b0mov z, #25h ; to set location 25h for z register b0mov a, @yz ; to read a data into acc a example: clear general-purpose data memo ry area of bank 0 using @yz register. mov a, #0 b0mov y, a ; y = 0, bank 0 mov a, #07fh b0mov z, a ; z = 7fh, the last address of the data memory area clr_yz_buf: clr @yz ; clear @yz to be zero decms z ; z ? 1, if z= 0, finish the routine jmp clr_yz_buf ; not zero clr @yz end_clr: ; end of clear general purpose data memory area of bank 0 . note: please consult the ?look-up table descriptio n? about y, z register look-up table application.
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 25 v1.4 3.3.2 r registers there are two major functions of the r register. first, r register can be used as worki ng registers. second, the r registers can be store high-byte data of look-up rom data. after movc instruct ion executed, the high-byte data of a rom address will be stored in r register and the low-byte data stored in acc. r initial value = xxxx xxxx 082h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 r rbit7 rbit6 rbit5 rbit4 rbit3 rbit2 rbit1 rbit0 r/w r/w r/w r/w r/w r/w r/w r/w ? note: please consult the ?look-up table description? about r register look-up table application. 3.4 program flag the pflag includes reset flag, low voltage detect flag, carry fl ag, decimal carry flag (dc) and zero flag (z). if the result of operating is zero or there is carry, borrow occurr ence, then these flags will be set to pflag register. pflag initial value = 00xx,x000 086h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 pflag nt0 npd lvd36 lvd24 - c dc z r/w r/w r/w r/ w - r/w r/w r/w 3.4.1 reset flag nt0 npd reset status 0 0 watch-dog time out 0 1 reserved 1 0 reset by lvd 1 1 reset by external reset pin 3.4.2 lvd 2.4v flag lvd24 vdd status 1 vdd <= 2.4v 0 vdd > 2.4v note: this bit is only valid when code option lvd=lvd_m 3.4.3 lvd 3.6v flag lvd36 vdd status 1 vdd <= 3.6v 0 vdd > 3.6v note: this bit is only valid when code option lvd=lvd_h
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 26 v1.4 3.4.4 carry flag c = 1: if executed arithmetic addition wi th occurring carry signal or executed ar ithmetic subtracti on without borrowing signal or executed rotation instruct ion with shifting out logic ?1?. c = 0: if executed arithmetic addition wi thout occurring carry signal or executed arithmetic s ubtraction with borrowing signal or executed rotation instruct ion with shifting out logic ?0?. 3.4.5 decimal carry flag dc = 1: if executed arithmetic addition wi th occurring carry signal from low nibbl e or executed arithmetic subtraction without borrow signal from high nibble. dc = 0: if executed arithmetic addition wit hout occurring carry signal from low nibbl e or executed arithmetic subtraction with borrow signal from high nibble. 3.4.6 zero flag z = 1: acc or arithmetic operation result is zero after ex ecuting a instruction. refer instruction set table for detailed information. z = 0: acc or arithmetic operation result is not zero afte r executing a instruction. re fer instruction set table for detailed information.
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 27 v1.4 3.5 accumulator the acc is an 8-bits data register responsible for tr ansferring or manipulating data between alu and data memory. if the result of operating is zero (z) or there is carry (c or dc) occurrence, then these flags will be set to pflag register. acc is not in data memory (ram), so acc can?t be a ccess by ?b0mov? instruction during the instant addressing mode. a example: read and write acc value. ; read acc data and store in buf data memory mov buf, a . . ; write a immediate data into acc mov a, #0fh . . ; write acc data from buf data memory mov a, buf . . the acc value don?t store in any inte rrupt service executed. acc must be exchanged to anot her data memory defined by users. thus, once interrupt occurs, these data must be stored in the data memory based on the user?s program as follows. a example: acc and working registers protection. accbuf equ 00h ; accbuf is acc data buffer in bank 0. int_service: b0xch a, accbuf ; b0xch doesn?t change c, z flag b0mov a, pflag b0mov pflagbuf, a ; save pflag register in a buffer . . b0mov a, pflagbuf b0mov pflag, a ; restore pflag register from buffer b0xch a, accbuf ; re-load acc reti ; exit interrupt service vector ? notice: to save and re-load acc data must be used ?b0xch? instruction, or the plage value maybe modified by acc.
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 28 v1.4 3.6 stack operations 3.6.1 overview the stack buffer of sn8p2710 has 8-level high area and each leve l is 11-bits length. this buffer is designed to save and restore program counter?s (pc) data when interrupt serv ice is executed. the stkp register is a pointer designed to point active level in order to save or restore data fr om stack buffer for kernel circuit. the stknh and stknl are the 12-bit stack buffers to store program counter (pc) data. figure 3-3 stack operation stack buffer stk7h stk6h stk5h stk4h stk3h stk2h stk1h stk0h stk7l stk6l stk5l stk4l stk3l stk2l stk1l stk0l stkp = 0 stkp = 1 stkp = 2 stkp = 3 stkp = 4 stkp = 5 stkp = 6 stkp = 7 stkp - 1 stkp + 1 call / interrupt ret / reti stkp pch pcl stkp stack buffer stk7h stk6h stk5h stk4h stk3h stk2h stk1h stk0h stk7l stk6l stk5l stk4l stk3l stk2l stk1l stk0l stk7h stk6h stk5h stk4h stk3h stk2h stk1h stk0h stk7l stk6l stk5l stk4l stk3l stk2l stk1l stk0l stkp = 0 stkp = 1 stkp = 2 stkp = 3 stkp = 4 stkp = 5 stkp = 6 stkp = 7 stkp = 0 stkp = 1 stkp = 2 stkp = 3 stkp = 4 stkp = 5 stkp = 6 stkp = 7 stkp - 1 stkp + 1 stkp - 1 stkp - 1 stkp + 1 call / interrupt ret / reti stkp stkp pch pcl pch pch pcl pcl stkp stkp
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 29 v1.4 3.6.2 stack registers the stack pointer (stkp) is a 4-bit register to store t he address used to access the stack buffer, 11-bits data memory (stknh and stknl) set aside for tem porary storage of stack addresses. the two stack operations are writing to the top of the stack (stack-save) and r eading (stack-restore) from the top of stack. stack-save operation decrement s the stkp and the stack-resotre operat ion increments one time. that makes the stkp always points to the top address of stack buffer and writes the last progr am counter value (pc) into the stack buffer. the program counter (pc) value is stored in the stack bu ffer before a call instruction executed or during interrupt service routine. stack operation is a lifo type (last in and first out). the stack pointer (stkp) and stack buffer (stknh and stknl) are located in t he system register area bank 0. stkp (stack pointer) initial value = 0xxx x111 0dfh bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 stkp gie - - - - stkpb2 stkpb1 stkpb0 r/w - - - - r/w r/w r/w stkpbn: stack pointer. (n = 0 ~ 3) gie: global interrupt control bit. 0 = disable, 1 = enabl e. more detail information is in interrupt chapter. a example: stack pointer (stkp) reset routine. mov a, #00000111b b0mov stkp, a stkn (stack buffer) initial value = xxxx xxxx xxxx xxxx, stkn = stknh + stknl (n = 7 ~ 0) 0f0h~0ffh bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 stknh - - - - - snpc10 snpc9 snpc8 - - - - - r/w r/w r/w 0f0h~0ffh bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 stknl snpc7 snpc6 snpc5 snpc4 snpc3 snpc2 snpc1 snpc0 r/w r/w r/w r/w r/w r/w r/w r/w stknh: store pch data as interrupt or call executing. the n expressed 0 ~7. stknl: store pcl data as interrupt or call executing. the n expressed 0 ~7.
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 30 v1.4 3.6.3 stack operation example the two kinds of stack-save operations to reference the stack pointer (stkp) and write the program counter contents (pc) into the stack buffer are call instruction and interr upt service. under each condition, the stkp is decremented and points to the next available stack lo cation. the stack buffer stores the pr ogram counter about the op-code address. the stack-save operation is as following table. stkp register stack buffer description stack level stkpb2 stkpb1 stkpb0 high byte low byte 0 1 1 1 stk0h stk0l - 1 1 1 0 stk1h stk1l - 2 1 0 1 stk2h stk2l - 3 1 0 0 stk3h stk3l - 4 0 1 1 stk4h stk4l - 5 0 1 0 stk5h stk5l - 6 0 0 1 stk6h stk6l - 7 0 0 0 stk7h stk7l - >8 - - - - - stack overflow table 3-1. stkp, stknh and stknl relative of stack-save operation the reti instruction is for interrupt se rvice routine. the ret instruction is fo r call instruction. when a stack-restore operation occurs, the stkp is incremented and points to the next free stack location. the sta ck buffer restores the last program counter (pc) to the program counter registers. the stack-rest ore operation is as following table. stkp register stack buffer description stack level stkpb2 stkpb1 stkpb0 high byte low byte 7 0 0 0 stk7h stk7l - 6 0 0 1 stk6h stk6l - 5 0 1 0 stk5h stk5l - 4 0 1 1 stk4h stk4l - 3 1 0 0 stk3h stk3l - 2 1 0 1 stk2h stk2l - 1 1 1 0 stk1h stk1l - 0 1 1 1 stk0h stk0l - table 3-2. stkp, stknh and stknl re lative of stack-restore operation
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 31 v1.4 3.7 program counter the program counter (pc) is a 11-bit bi nary counter separated into the high-byte 3 bits and the low-byte 8 bits. this counter is responsible for pointing a location in order to fe tch an instruction for kernel circuit. normally, the program counter is automatically incremented with eac h instruction during program execution. besides, it can be replaced with specific address by executing call or jmp inst ruction. when jmp or call instruction is executed, t he destination address will be inserted to bit 0 ~ bit 10. pc initial value = xxxx 0000 0000 0000 bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 pc - - - - - 0 0 0 0 0 0 0 0 0 0 0 pch pcl pch initial value = xxxx x000 0cfh bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 pch - - - - - pc10 pc9 pc8 - - - - - r/w r/w r/w pcl initial value = 0000 0000 0ceh bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 pcl pc7 pc6 pc5 pc4 pc3 pc2 pc1 pc0 r/w r/w r/w r/w r/w r/w r/w r/w
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 32 v1.4 3.7.1 one address skipping there are 7 instructions (cmprs, incs, incms, decs, decms, b0bt s0, b0bts1) with one address skipping function. if the result of these instructions is matc hed, the pc will add 2 steps to skip next instruction. if the condition of bit test instruction is matched, the pc will add 2 steps to skip next instruction. b0bts1 fc ; skip next instruction, if carry_flag = 1 jmp c0step ; else jump to c0step. . c0step: nop b0mov a, buf0 ; move buf0 value to acc. b0bts0 fz ; skip next instruction, if zero flag = 0. jmp c1step ; else jump to c1step. . c1step: nop if the acc is equal to the immediate data or memory , the pc will add 2 steps to skip next instruction. cmprs a, #12h ; skip next instruction, if acc = 12h. jmp c0step ; else jump to c0step. . c0step: nop if the result after increasing 1 or decreasing 1 is 0xffh (for decs and decms) or 0x00h (for incs and incms) , the pc will add 2 steps to skip next instruction. incs instruction: incs buf0 ; skip next instruction, if buf0 = 0x00h. jmp c0step ; else jump to c0step. . c0step: nop incms instruction: incms buf0 ; skip next instruction, if buf0 = 0x00h. jmp c0step ; else jump to c0step. . c0step: nop decs instruction: decs buf0 ; skip next instruction, if buf0 = 0xffh. jmp c0step ; else jump to c0step. . c0step: nop decms instruction: decms buf0 ; skip next instruction, if buf0 = 0xffh. jmp c0step ; else jump to c0step. . c0step: nop
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 33 v1.4 3.7.2 multi-address jumping users can jump round multi-address by either jmp instruct ion or add m, a instruction (m = pcl) to activate multi-address jumping function. if carry signal occurs after ex ecution of add pcl, a, the carry signal will not affect pch register. a example: if pc = 0323h (pch = 03h pcl = 23h) ; pc = 0323h mov a, #28h b0mov pcl, a ; jump to address 0328h . . . . ; pc = 0328h . . mov a, #00h b0mov pcl, a ; jump to address 0300h a example: if pc = 0323h (pch = 03h pcl = 23h) ; pc = 0323h b0add pcl, a ; pcl = pcl + acc, the pch cannot be changed. jmp a0point ; if acc = 0, jump to a0point jmp a1point ; acc = 1, jump to a1point jmp a2point ; acc = 2, jump to a2point jmp a3point ; acc = 3, jump to a3point . . ;
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 34 v1.4 4 addressing mode 4.1 overview the sn8p2710 provides three addressing modes to access ra m data, including immediate addressing mode, directly addressing mode and indirectly address mode. the main purpos e of the three different modes is described in the following: 4.1.1 immediate addressing mode the immediate addressing mode uses an immediate data to set up the location (mov a, #i, b0mov m,#i) in acc or specific ram. immediate addressing mode mov a, #12h ; to set an immediate data 12h into acc 4.1.2 directly addressing mode the directly addressing mode uses address number to a ccess memory location (mov a,12h, mov 12h,a). directly addressing mode b0mov a, 12h ; to get a content of location 12h of bank 0 and save in acc 4.1.3 indirectly addressing mode the indirectly addressing mode is to set up an address in dat a pointer registers (y/z) and uses mov instruction to read/write data between acc and @yz regi ster (mov a,@yz, mov @yz,a). a example: indirectly addressing mode with @yz register clr y ; to clear y register to access ram bank 0. b0mov z, #12h ; to set an immediate data 12h into z register. b0mov a, @yz ; use data pointer @yz reads a data from ram location ; 012h into acc.
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 35 v1.4 4.1.4 to access data in ram bank 0 in the ram bank 0, this area memory can be read/written by these twoaccess methods. a example 1: to use ram bank0 dedicate in struction (such as b0xxx instruction). b0mov a, 12h ; to move content fr om location 12h of ram bank 0 to acc a example 2: to use indirectly addressing mode with @yz register. clr y ; to clear y register for accessing ram bank 0. b0mov z, #12h ; to set an immediate data 12h into z register. b0mov a, @yz ; use data pointer @yz reads a data from ram location ; 012h into acc.
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 36 v1.4 5 system register 5.1 overview the system special register is located at 80h~ffh. the main purpose of system registers is to control the peripheral hardware of the chip. using system r egisters can control i/o ports, adc, pw m, timers and counters by programming. the memory map provides an easy and quick refer ence source for writing application program. 5.2 system register arrangement (bank 0) 5.2.1 bytes of system register sn8p2710 0 1 2 3 4 5 6 7 8 9 a b c d e f 8 - - r z y - pflag - - - - - - - - - 9 - - - - - - - - - - - - - - - - a - - - - - - - - - - - - - - p4con - b dam adm adb adr - - - - - - - - - - - pedge c - - p2m - p4m p5m - - intrq inten oscm - wdtr tc0r pcl pch d p0 - p2 - p4 p5 - - t0m - tc0m tc0c tc1m tc1c tc1r stkp e p0ur - p2ur - p4ur p5ur - @yz - - - - - - - - f stk7l stk7h stk6l stk6h stk5l stk5h stk4l stk4h stk3l stk3h stk2l stk2h stk1l stk1h stk0l stk0h table 5-1. system regist er arrangement of sn8p2710 description pflag = rom page and special flag register. r = w orking register and rom lookup data buffer. dam = dac?s mode register. y, z = wor king, @yz and rom addressing register. adb = adc?s data buffer. adm = adc?s mode register. pnm = port n input/output mode register. adr = adc?s resolution selects register. intrq = interrupts? request register. pn = port n data buffer. oscm = oscillator mode register. inten = interrupts? enable register. t0m = timer/ counter 0, timer/ counter 1 speed selection . pch, pcl = program counter. tc1m = timer/counter 1 mode register. tc0m = timer/counter 0 mode register. tc1c = timer/counter 1 counting register. tc0c = timer/counter 0 counting register. stkp = stack pointer buffer. tc0r = timer/counter 0 auto-reload data buffer. @hl = ram hl indirect addressing index pointer. tc1r = timer/counter 1 auto-reload data buffer. p4con= port 4 configuration setting stk0~stk7 = stack 0 ~ stack 7 buffer. @yz = ram yz indirect addressing index pointer. ? note: a). all of register names had been declared in sonix 8-bit mcu assembler. b). one-bit name had been declared in sonix 8-bit mcu assembler with ?f? prefix code. c). it will get logic ?h? data, when use instruction to check empty location. d). the low nibble of adr register is read only. e). ?b0bset?, ?b0bclr?, ?bset?, ?bclr? in structions only support ?r/w? registers.
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 37 v1.4 5.2.2 bits of system register sn8p2710 system register table address bit7 bit6 bit5 bit4 bi t3 bit2 bit1 bit0 r/w remarks 080h 081h 082h rbit7 rbit6 rbit5 rbit4 rbit3 rbit2 rbit1 rbit0 r/w r 083h zbit7 zbit6 zbit5 zbit4 zbit3 zbit2 zbit1 zbit0 r/w z 084h ybit7 ybit6 ybit5 ybit4 ybit3 ybit2 ybit1 ybit0 r/w y 085h 086h nt0 npd lvd36 lvd24 - c dc z r/w pflag 087h - - - - - - - - - - 0aeh p4con7 p4con6 p4con 5 p4con4 p4con3 p4con2 p4con1 p4con0 w p4con 0b0h daenb dab6 dab5 dab4 dab3 d ab2 dab1 dab0 r/w dam data register 0b1h adenb ads eoc gchs - chs2 chs1 chs0 r/w adm mode register 0b2h adb11 adb10 adb9 adb8 adb7 adb6 adb5 adb4 r adb data buffer 0b3h - adcks1 - adcks0 adb3 adb2 adb1 adb0 r/w adr register 0b4h - - - - - - - - - 0b5h - - - - - - - - - 0b6h - - - - - - - - - 0b8h - - - - - - - - - 0bfh - - - p00g1 p00g0 - - - r/w pedge 0c0h - - - - - - - - - 0c1h - - - - - - - - - 0c2h p27m p26m p25m p24m p23m p 22m p21m p20m r/w p2m i/o direction 0c3h - - - - - - - - - 0c4h p47m p46m p45m p44m p43m p 42m p41m p40m r/w p4m i/o direction 0c5h - p56m p55m p54m p53m p52m p51m p50m r/w p5m i/o direction 0c8h - tc1irq tc0irq - - - p01irq p00irq r/w intrq 0c9h - tc1ien tc0ien - - - p01ien p00ien r/w inten 0cah - - - - cpum0 clkmd stphx - r/w oscm 0cch wdtr7 wdtr6 wdtr5 wdtr4 wdtr3 wdtr2 wdtr1 wdtr0 w wdtr 0cdh tc0r7 tc0r6 tc0r5 tc0r4 tc0r3 tc0r2 tc0r1 tc0r0 w tc0r 0ceh pc7 pc6 pc5 pc4 pc3 pc2 pc1 pc0 r/w pcl 0cfh - - - - - pc10 pc9 pc8 r/w pch 0d0h - - - - p03 p02 p01 p00 r p0 data buffer 0d1h - - - - - - - - - 0d2h p27 p26 p25 p24 p23 p22 p21 p20 r/w p2 data buffer 0d3h - - - - - - - - - 0d4h p47 p46 p45 p44 p43 p42 p41 p40 r/w p4 data buffer 0d5h - p56 p55 p54 p53 p52 p51 p50 r/w p5 data buffer 0d8h - - - - tc1x8 tc0x8 - - r/w t0m 0d9h - - - - - - - - - 0dah tc0enb tc0rate2 tc0rat e1 tc0rate0 tc0cks aload0 tc0out pwm0out r/w tc0m 0dbh tc0c7 tc0c6 tc0c5 tc0c4 tc0c3 tc0c2 tc0c1 tc0c0 r/w tc0c 0dch tc1enb tc1rate2 tc1rate1 tc1rate0 tc1cks aload1 tc1out pwm1out r/w tc1m 0ddh tc1c7 tc1c6 tc1c5 tc1c4 tc1c3 tc1c2 tc1c1 tc1c0 r/w tc1c 0deh tc1r7 tc1r6 tc1r5 tc1r4 tc1r3 tc1r2 tc1r1 tc1r0 w tc1r 0dfh gie - - - - stkpb2 stkpb1 stkpb0 r/w stkp stack pointer 0e0h - - - - - p02r p01r p00r w p0ur 0e1h - - - - - - - - - 0e2h p27r p26r p25r p24r p23r p22r p21r p20r w p2ur 0e3h - - - - - - - - - 0e4h p47r p46r p45r p44r p43r p42r p41r p40r w p4ur 0e5h - p56r p54r p54r p53r p52r p51r p50r w p5ur 0e6h - - - - - - - - - 0e7h @yz7 @yz6 @yz5 @yz4 @yz3 @yz2 @yz1 @yz0 r/w @yz index pointer 0e9h - - - - - - - - - 0f0h s7pc7 s7pc6 s7pc5 s7pc4 s7pc3 s7pc2 s7pc1 s7pc0 r/w stk7l 0f1h - - - - - s7pc10 s7pc9 s7pc8 r/w stk7h 0f2h s6pc7 s6pc6 s6pc5 s6pc4 s6pc3 s6pc2 s6pc1 s6pc0 r/w stk6l 0f3h - - - - - s6pc10 s6pc9 s6pc8 r/w stk6h
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 38 v1.4 address bit7 bit6 bit5 bit4 bi t3 bit2 bit1 bit0 r/w remarks 0f4h s5pc7 s5pc6 s5pc5 s5pc4 s5pc3 s5pc2 s5pc1 s5pc0 r/w stk5l 0f5h - - - - - s5pc10 s5pc9 s5pc8 r/w stk5h 0f6h s4pc7 s4pc6 s4pc5 s4pc4 s4pc3 s4pc2 s4pc1 s4pc0 r/w stk4l 0f7h - - - - - s4pc10 s4pc9 s4pc8 r/w stk4h 0f8h s3pc7 s3pc6 s3pc5 s3pc4 s3pc3 s3pc2 s3pc1 s3pc0 r/w stk3l 0f9h - - - - - s3pc10 s3pc9 s3pc8 r/w stk3h 0fah s2pc7 s2pc6 s2pc5 s2pc4 s2pc3 s2pc2 s2pc1 s2pc0 r/w stk2l 0fbh - - - - - s2pc10 s2pc9 s2pc8 r/w stk2h 0fch s1pc7 s1pc6 s1pc5 s1pc4 s1pc3 s1pc2 s1pc1 s1pc0 r/w stk1l 0fdh - - - - - s1pc10 s1pc9 s1pc8 r/w stk1h 0feh s0pc7 s0pc6 s0pc5 s0pc4 s0pc3 s0pc2 s0pc1 s0pc0 r/w stk0l 0ffh - - - - - s0pc10 s0pc9 s0pc8 r/w stk0h table. bit system register table of sn8p2710 note: a). to avoid system error, please be sure to put all the ?0? as it indicates in the above table b). all of register name had been declared in sonix 8-bit mcu assembler. c). one-bit name had been declared in sonix 8-bit mcu assembler with ?f? prefix code. d). ?b0bset?, ?b0bclr?, ?bset?, ?bclr? in structions only support ?r/w? registers. e). for detail description please refer file of ?system register quick reference table?
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 39 v1.4 6 reset 6.1 overview the system would be reset in three conditions as following. z power on reset z watchdog reset z brown out reset z external reset (only supports ex ternal reset pin enable situation) when any reset condition occurs, all system registers k eep initial status, program stops and program counter is cleared. after reset status releas ed, the system boots up and program st arts to execute from org 0. finishing any reset sequence needs some time. the system provides complete procedures to make the power on reset successful. for different oscillator types, the reset time is different. that causes the vdd rise rate and start-up time of different oscillator is not fixed. rc type oscillator? s start-up time is very short, but the crystal type is longer. under client terminal application, users have to take care the power on reset time for the master terminal requirement. the reset timing diagram is as following. vdd vss vdd vss watchdog normal run watchdog stop system normal run system stop lvd detect level external reset low detect external reset high detect watchdog overflow watchdog reset delay time external reset delay time power on delay time power external reset watchdog reset system status
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 40 v1.4 6.2 power on reset the power on reset depend no lvd operation for most power-up si tuations. the power supplying to system is a rising curve and needs some time to achieve the normal voltage. power on reset sequence is as following. z power-up: system detects the power volt age up and waits for power stable. z external reset (only external reset pin enable): system checks external reset pin status. if external reset pin is not high level, the system keeps reset stat us and waits external reset pin released. z system initialization: all system registers is set as in itial conditions and system is ready. z oscillator warm up: oscillator operation is successfully and supply to system clock. z program executing: power on sequence is finished and pr ogram executes from org 0. 6.3 watchdog reset watchdog reset is a system protection. in normal conditi on, system works well and clears watchdog timer by program. under error condition, system is in unknown situation and watchdog can?t be clear by program before watchdog timer overflow. watchdog timer overflow occurs and the system is reset. after watchdog reset, the system restarts and returns normal mode. watchdog reset sequence is as following. z watchdog timer status: system checks watchdog timer overflow stat us. if watchdog timer overflow occurs, the system is reset. z system initialization: all system registers is set as in itial conditions and system is ready. z oscillator warm up: oscillator operation is successfully and supply to system clock. z program executing: power on sequence is finished and pr ogram executes from org 0. watchdog timer application note is as following. z before clearing watchdog timer, check i/o status and check ram contents can improve system error. z don?t clear watchdog timer in interrupt vector and interrupt service routine. that can improve main routine fail. z clearing watchdog timer program is only at one part of t he program. this way is the best structure to enhance the watchdog timer function. ? note: please refer to the ?watchdog timer? about watchdog timer detail information.
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 41 v1.4 6.4 brown out reset 6.4.1 brown out description the brown out reset is a power dropping condition. the power drops from normal voltage to low voltage by external factors (e.g. eft interference or external loading changed). t he brown out reset would make the system not work well or executing program error. vdd vss v1 v2 v3 system work well area system work error area brown out reset diagram the power dropping might through the voltage range that ?s the system dead-band. the dead-band means the power range can?t offer the system minimum operation power requi rement. the above diagram is a typical brown out reset diagram. there is a serious noise under the vdd, and vdd vo ltage drops very deep. there is a dotted line to separate the system working area. the above area is the system work well area. the below area is the system work error area called dead-band. v1 doesn?t touch the below area and not effect the system operation. but the v2 and v3 is under the below area and may induce the system error occurrenc e. let system under dead-band includes some conditions. dc application: the power source of dc application is usually using ba ttery. when low battery condition and mcu drive any loading, the power drops and keeps in dead-band. under the situati on, the power won?t drop deeper and not touch the system reset voltage. that makes the system under dead-band. ac application: in ac power application, the dc power is regulated from ac power source. this kind of pow er usually couples with ac noise that makes the dc power dirty. or the external loading is very heavy, e. g. driving motor. the loading operating induces noise and overlaps with the dc power. vdd drops by the noise, and the system works under unstable power situation. the power on duration and power down duration are longer in ac application. the system power on sequence protects the power on successful, but t he power down situation is like dc low battery condition. when turn off the ac power, the vdd drops slowly and through the dead-band for a while.
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 42 v1.4 6.4.2 the system operating voltage decsription to improve the brown out reset needs to know the syst em minimum operating voltage which is depend on the system executing rate and power level. differ ent system executing rates have differ ent system minimum operating voltage. the electrical characteristic section shows the system voltage to executing rate relationship. vdd (v) system rate (fcpu) system mini. operating voltage. system reset voltage. dead-band area normal operating area reset area normally the system operation voltage ar ea is higher than the system reset vo ltage to vdd, and the reset voltage is decided by lvd detect level. the syst em minimum operating voltage rises when the system executing rate upper even higher than system reset voltage. the dead-band definition is the system minimum operat ing voltage above the system reset voltage. 6.4.3 brown out reset improvement how to improve the brown reset condition? there are some methods to improv e brown out reset as following. z lvd reset z watchdog reset z reduce the system executing rate z external reset circuit. (zener diode reset circui t, voltage bias reset circuit, external reset ic) ? note: 1. the ? zener diode reset circuit?, ?volta g e bias reset circuit? and ?external reset ic? can completely improve the brown out reset, dc low battery and ac slow power down conditions. 2. for ac power application and enhance eft performance, the s y stem clock is 4mhz/4 ( 1 mips ) and use external reset ( ? zener diode reset circuit?, ?volta g e bias reset circuit?, ?external reset ic?). the structure can improve noise effective and get good eft characteristic.
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 43 v1.4 lvd reset: vdd vss system normal run system stop lvd detect voltage power on delay time power system status power is below lvd detect voltage and system reset. the lvd (low voltage detector) is built-in sonix 8-bit mcu to be brown out reset protection. when the vdd drops and is below lvd detect voltage, the lvd would be triggered, and t he system is reset. the lvd detect level is different by each mcu. the lvd voltage level is a point of volt age and not easy to cover all dead-band range. using lvd to improve brown out reset is depend on application requirement and environment. if the power variation is very deep, violent and trigger the lvd, the lvd c an be the protection. if the power variat ion can touch the lvd detect level and make system work error, the lvd can?t be the prot ection and need to other reset methods. more detail lvd information is in the electric al characteristic section. watchdog reset: the watchdog timer is a protection to make sure the syst em executes well. normally the watchdog timer would be clear at one point of program. don?t clear the watchdog time r in several addresses. the system executes normally and the watchdog won?t reset system. when the system is under dead-band and the execution error, the watchdog timer can?t be clear by program. the watchdog is continuously counting until overflow occurrence. the overflow signal of watchdog timer triggers the system to re set, and the system return to normal mode after reset sequence. this method also can improve brown out reset condition and make sure the system to return normal mode. if the system reset by watchdog and the power is still in dead-band, the system reset sequence won?t be successful and the system stays in re set status until the power return to normal range. reduce the system executing rate: if the system rate is fast and the dead-band exists, to r educe the system executing ra te can improve the dead-band. the lower system rate is with lower minimum operati ng voltage. select the power voltage that?s no dead-band issue and find out the mapping system rate. adju st the system rate to the value and the system exit s the dead-band issue. this way needs to modify whole program timing to fit the application requirement. external reset circuit: the external reset methods also can improve brown out rese t and is the complete solution. there are three external reset circuits to improve brown out reset including ?zener di ode reset circuit?, ?voltage bias reset circuit? and ?external reset ic?. these three reset structures use external re set signal and control to make sure the mcu be reset under power dropping and under dead-band. the external reset in formation is described in the next section.
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 44 v1.4 6.5 external reset external reset function is controlled by ?reset_pin? code option. set the code option as ?reset? option to enable external reset function. external reset pin is schmitt trigger structure and low level active. the system is running when reset pin is high level voltage input. the reset pin receives the low voltage and the system is reset. the external reset operation actives in power on and normal running mode. during system power-up, the exter nal reset pin must be high level input, or the system keeps in reset st atus. external reset sequence is as following. z external reset (only external reset pin enable): system checks external reset pin status. if external reset pin is not high level, the system keeps reset stat us and waits external reset pin released. z system initialization: all system registers is set as in itial conditions and system is ready. z oscillator warm up: oscillator operation is successfully and supply to system clock. z program executing: power on sequence is finished and pr ogram executes from org 0. the external reset can reset the system during power on duration, and good external reset circuit can protect the system to avoid working at unusual power condition, e.g. brown out reset in ac power application? 6.6 external reset circuit 6.6.1 simply rc reset circuit mcu vdd vss vcc gnd r s t r1 47k ohm c1 0.1uf r2 100 ohm this is the basic reset circuit, and only includes r1 and c1 . the rc circuit operation makes a slow rising signal into reset pin as power up. the reset signal is slower than vdd power up timing, and system occurs a power on signal from the timing difference. ? note: the reset circuit is no any protection against unusual power or brown out reset.
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 45 v1.4 6.6.2 diode & rc reset circuit mcu vdd vss vcc gnd r s t r1 47k ohm c1 0.1uf diode r2 100 ohm this is the better reset circuit. the r1 and c1 circuit operati on is like the simply reset circuit to make a power on signal. the reset circuit has a simply protection against unusual power. the diode offers a power positive path to conduct higher power to vdd. it is can make reset pin voltage le vel to synchronize with vdd voltage. the structure can improve slight brown out reset condition. ? note: the r2 100 ohm resistor of ?simply reset ci rcuit? and ?diode & rc reset circuit? is necessar y to limit an y current flowin g into reset pin from external capacitor c in the event of reset pin breakdown due to electrostatic discharge (esd) or electrical over-stress (eos). 6.6.3 zener diode reset circuit mcu vdd vss vcc gnd r s t r1 33k ohm r3 40k ohm r2 10k ohm vz q1 e c b the zener diode reset circuit is a simple low voltage detector and can improve brown out reset condition completely . use zener voltage to be the active level. when vdd vo ltage level is above ?vz + 0. 7v?, the c terminal of the pnp transistor outputs high voltage and mcu operates norma lly. when vdd is below ?vz + 0.7v?, the c terminal of the pnp transistor outputs low voltage and mcu is in reset mode. decide the reset detect voltage by zener specification. select the right zener voltage to conform the application.
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 46 v1.4 6.6.4 voltage bias reset circuit mcu vdd vss vcc gnd r s t r1 47k ohm r3 2k ohm r2 10k ohm q1 e c b the voltage bias reset circuit is a low cost voltage detector and can improve brown out reset condition completely . the operating voltage is not accurate as zener diode reset circ uit. use r1, r2 bias voltage to be the active level. when vdd voltage level is above or equal to ?0.7v x (r1 + r2) / r1?, the c terminal of the pnp transistor outputs high voltage and mcu operates normally. when vdd is below ?0.7v x (r 1 + r2) / r1?, the c terminal of the pnp transistor outputs low voltage and mcu is in reset mode. decide the reset detect voltage by r1, r2 resistances. select the right r1, r2 value to conform the application. in the circuit diagram condition, the mcu?s reset pin level varies with vdd voltage variation, and the differential voltage is 0.7v. if the vdd drops and the voltage lower than reset pin detect level, the system would be reset. if want to make the reset active earlier, set the r2 > r1 and the cap between v dd and c terminal voltage is larger than 0.7v. the external reset circuit is with a stable current through r1 and r2. for power consumption issue application, e.g. dc power system, the current must be considered to whole system power consumption. ? note: under unstable power condition as brown out reset, ?zener diode rest circuit? and ?volta g e bias reset circuit? can protects s y stem no an y error occurrence as power droppin g . when power drops below the reset detect voltage, the system reset would be triggered, and then s y stem executes reset sequence. that makes sure the system work well under unstable power situation.
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 47 v1.4 6.6.5 external reset ic mcu vdd vss vcc gnd r s t reset ic vdd vss rst bypass capacitor 0.1uf the external reset circuit also use external reset ic to enhance mcu reset performance. this is a high cost and good effect solution. by different applicati on and system requirement to select su itable reset ic. the reset circuit can improve all power variation.
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 48 v1.4 7 oscillators 7.1 overview the sn8p2710 highly performs the dual clock micro-cont roller system. the dual clocks are high-speed clock and low-speed clock. the high-speed clock frequency is supplied through the external oscillator circuit. the low-speed clock frequency is supplied through on-chip rc oscillator circuit. figure 7-1 system clock block diagram z fosc = fhosc (external high clock) in normal mode z fosc = flosc (internal low rc clock) in slow mode z fosc is system clock, fcpu is instruction cycle clock z fcpu = fosc/1 ~ fosc/8 in normal mode z fcpu = fosc/4 in slow mode the system clock is required by the following peripheral modules: 9 timer ( tc0 / tc1 / watchdog timer) 9 pwm output (pwm0, pwm1) 9 buzzer output (tc0out, tc1out) 9 adc converter 4 or 8 (noise filter code option enable) 1 ~ 8 (noise filter code option disable) 4 fcpu hx osc. xin xout stphx fcpu code option high_clk code option lxosc. clkmd cpum 0 fosc fosc
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 49 v1.4 7.1.1 oscm register description the oscm register is an oscillator control regist er. it can control oscillator select, system mode. oscm initial value = xxx0 000x 0cah bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 oscm - - - - cpum0 clkmd stphx - - - - - r/w r/w r/w - bit [4:3] cpum 0: cpu operating mode control bit. 0 = normal mode 1 = sleep (power down) mode. always enter normal mode after wakeup. bit 2 clkmd: select instruction cycle clock (fcpu) source 0 fcpu came form external high clock (fhosc). operation mode is normal mode. 1 fcpu came from internal low clock (flosc). operation mode is slow mode. bit1 stphx : stop high clock control bit. 0=high clock free running. 1=high clock stop. 7.1.2 external high-speed oscillator the high clock oscillator of sn8p2710 can be configured as four different oscillator types. there are external rc oscillator modes, high crystal/resonator mode (12m code option), standard crystal/resonator mode (4m code option). for different application, the users c an select one of suitable oscillator m ode by programming ?high_clk? code option to generate system high-speed clock source after reset. a example: stop external high-speed oscillator. b0bset fstphx ; to stop external high-speed oscillator only. b0bset fcpum0 ; to stop external hi gh-speed oscillator and internal low-speed ; oscillator called power down mode (sleep mode). 7.1.3 high clock oscillator code option sn8p2710 provide four oscillator modes for different app lications. these modes are 4m, 12m and rc. the main purpose is to support different oscilla tor types and frequencies. high-speed crystal needs more current but the low one doesn?t. for crystals, there are three st eps to select. user can select osc illator mode from code option table before compiling. the table is as follow. code option content function description ext_rc low cost external rc oscillato r for high clock oscillator. output the fcpu clock from xout pin. 12m_x?tal high speed crystal /resonator (e.g. 12mhz ~ 16mhz) for high clock oscillator. high_clk 4m_x?tal middle speed crystal /resonator (e.g . 4mhz ~ 10mhz) for high clock oscillator.
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 50 v1.4 7.1.4 system oscillator circuits mcu xin vdd xout vss crystal 20pf 20pf figure 7-2. crystal/ceramic oscillator mcu xin vdd vss xout c r figure 7-3. rc oscillator xin vdd mcu vss xout external clock input figure 7-4. external clock input ? note1: the vdd and vss of external oscillator circuit must be from the micro-controller. don?t connect them from the neighbor power terminal. ? note2: the external clock input mode can select rc type oscillator or crystal type oscillator of the code option and input the external clock into xin pin. ? note3: the power and ground of external oscillator circ uit must be connected from the micro-controller?s vdd and vss. it is necessary to step up the performance of the whole system.
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 51 v1.4 7.1.5 external rc oscillator frequency measurement there is one way to get the fosc frequency of external rc osc illator by instruction cycle (fcpu). we can get the fosc frequency of external rc from the fcpu fr equency. the sub-routine to get fcpu fr equency of external oscillator is as the following. example: fcpu instruction cy cle of external oscillator b0bset p2m.0 ; set p2.0 to be output mode for outputting fcpu toggle signal. @@: b0bset p2.0 ; output fcpu toggle signal in low-speed clock mode. b0bclr p2.0 ; measure the fcpu frequency by oscilloscope. jmp @b
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 52 v1.4 7.2 internal low-speed oscillator the internal low-speed oscillator is built in the micro-cont roller. the low-speed clock?s source is a rc type oscillator circuit. the low-speed clock can supplies clock for syst em clock, timer counter, watchdog timer, and so on. a example: stop internal low-speed oscillator. b0bset fcpum0 ; to stop external hi gh-speed oscillator and internal low-speed ; oscillator called power down mode (sleep mode). ? note: the internal low-speed clock can?t be turned o ff individually. it is controlled by cpum0 bit of oscm register. the low-speed oscillator uses rc type oscillator circuit. t he frequency is affected by the voltage and temperature of the system. in common condition, the frequency of the rc oscillator is about 16khz at 3v and 32khz at 5v. the relative between the rc frequency and voltage is as following. internal rc vs. vdd 7.329 8.663 11.998 15.333 18.668 22.003 25.338 28.673 32.008 35.343 38.678 0 5 10 15 20 25 30 35 40 1.80 2.00 2.50 3.00 3.50 4.00 4.50 5.00 5.50 6.00 6.50 vdd (volts) fintrc (khz) figure 7-5. internal rc vs. vdd diagram a example: to measure the internal rc frequency is by in struction cycle (fcpu). the internal rc frequency is the fcpu multiplied by 4. so we can get the fosc frequency of internal rc from the fcpu frequency. b0bset p2m.0 ; set p2.0 to be output mode for outputting fcpu toggle signal. b0bset fclkmd ; switch the system cl ock to internal low-speed clock mode. @@: b0bset p2.0 ; output fcpu toggle signal in low-speed clock mode. b0bclr p2.0 ; measure t he fcpu frequency by oscilloscope. jmp @b
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 53 v1.4 7.3 system mode description 7.3.1 overview the chip is featured with low power consumption by switching around three different modes as following. in actual application, the user can adjus t the chip?s controller to work in thes e three modes by using oscm register. 7.3.2 normal mode in normal mode, the system clock source is external high-speed clock. after power on, the system works under normal mode. all software and hardware are executed and working. in normal mode, system can get into power down mode and slow mode. 7.3.3 slow mode in slow mode, the system clock source is internal low-speed rc clock. to set cl kmd = 1, the system switch to slow mode. in slow mode, the system works as normal mode but the slower clock. t he system in slow mode can get into normal mode and power down mode. to set stphx = 1 to stop the external high-speed oscillator, and then the system consumes less power. 7.3.4 power down (sleep) mode the power down mode is also called sleep mode. the chip stops working as sleeping status. the power consumption is very less almost to zero. the power down mode is usually applied to low power consuming system as battery power productions. to set cupm0 = 1, the system gets into power down mode. the external high-speed and low-speed oscillators are turned off. the system can be waked up by p0 (p0.0, p0.1, p0.2) wakeup trigger signal(p0.0, p0.1, p0.2 level change). note: ? watch_dog code option = ?enable? stop in power down (sleep) mode. enable in normal mode mode. ? watch_dog code option = ?always_on?. enable in normal mode and power down (sleep) mode.
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 54 v1.4 7.4 system mode control 7.4.1 sn8p2710 system mode block diagram figure 7-6. sn8p2710 system mode block diagram mode normal slow power down (sleep) remark hx osc. running by stphx stop lx osc. running running stop cpu instruction execut ing executing stop tc0/tc1 *active *active inactive * active by program watchdog timer active active by watchdog code option internal interrupt all active all active all inactive external interrupt all active all active all inactive wakeup source - - p0, reset by rst, lvd, *watchdog * watchdog code option must be ?always_on? table 7-1. operating mode description normal mode slow mode power down mode (sleep mode) p0 wake-up function active. external reset circuit active. cpum0 = 1 clkmd = 0 clkmd = 1 normal mode slow mode power down mode (sleep mode) p0 wake-up function active. external reset circuit active. cpum0 = 1 clkmd = 0 clkmd = 1
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 55 v1.4 7.4.2 system mode switching switch normal/slow mode to power down (sleep) mode. cpum0 = 1 b0bset fcpum0 ; set cpum0 = 1. during the sleep, only the wakeup pin and reset c an wakeup the system back to the normal mode. switch normal mode to slow mode. b0bset fclkmd ;to set clkmd = 1, change the system into slow mode b0bset fstphx ;to stop external high-speed oscillator for power saving. ? note: to stop high-speed oscillator is not necessary and user can omit it. switch slow mode to normal mode (the ext ernal high-speed oscillator is still running) b0bclr fclkmd ;to set clkmd = 0 switch slow mode to normal mode ( the external high-speed oscillator stops) if external high clock stop and program want to switch back normal mode. it is necessary to delay at least 10ms for external clock stable. b0bclr fstphx ; turn on the external high-speed oscillator. b0mov z, #27 ; if vdd = 5v, internal rc=32khz (typical) will delay @@: decms z ; 0.125ms x 81 = 10.125m s for external clock stable jmp @b ; b0bclr fclkmd ; change the system back to the normal mode
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 56 v1.4 7.5 wakeup time 7.5.1 overview the external high-speed oscillator needs a delay time from stopping to operating. the del ay is very necessary and makes the oscillator to work stably. some conditions duri ng system operating, the exter nal high-speed oscillator often runs and stops. under these conditions, the delay time for external high-speed osc illator restart is called wakeup time. there are two conditions need wakeup time. one is power dow n mode to normal mode. the other one is slow mode to normal mode. for the first case, sn8p2710 provides 4096 oscilla tor clocks to be the wakeup time. however, in the last case, users need to make the wakeup time by themselves. 7.5.2 hardware wakeup when the system is in power down mode (sleep mode), t he external high-speed oscillator stops. for wakeup into normal, sn8p2710 provides 4096 external high-speed oscilla tor clocks to be the wakeup time for warming up the oscillator circuit. after the wakeup time, the system goes in to the normal mode. the value of the wakeup time is as following. the wakeup time = 1/fosc * 3584 (sec) + x?tal settling time the x?tal settling time is depended on the x?ta l type. typically, it is about 2~4ms. a example: in power down mode (sleep mode), the syst em is waked up by p0 trigger signal. after the wakeup time, the system goes into normal mode. the wakeup time of p0 wakeup function is as following. the wakeup time = 1/fosc * 3584 = 1.001 ms (fosc = 3.58mhz) the total wakeup time = 1.001 ms + x?tal settling time under power down mode (sleep mode), ther e are only i/o ports with wakeup function making the system to return normal mode. port 0.0 and port 0.1 wakeup function always enables.
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 57 v1.4 8 timers counters 8.1 watchdog timer (wdt) this built-in wdt watchdog 4-bit binary up counter designed for monitoring program execution. if the program is operated into the unknown status by noise interference or pr ogram dead lock, wdt?s overflow signal will reset this chip to restart operation. in normal operation flow, the user must clear watchdog timer before overflow occurs to prevent the program from unexpected system reset. the clock source of watchdog timer (wdt) always comes from internal low speed rc oscillator. the overflow time of wdt is about: 1 / ( 16k 512 16 ) ~ 0.5s @ 3v 1 / ( 32k 512 16 ) ~ 0.25s @ 5v 0cch bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 wdtr wdtr7 wdtr6 wdtr5 wdtr4 wdtr3 wdtr2 wdtr1 wdtr0 read/write r/w r/w r/w r/w r/w r/w r/w r/w after reset - - - - - - - - write wdtr with ?0x5a? to clear the watchdog timer. note: ? the watchdog timer can be set ?always_on?,?enab le? and ?disabled? at the code option. ? watch_dog code option = ?enable? stop in power down (sleep) mode. enable in normal mode. ? watch_dog code option = ?always_on?. enable in normal mode and power down (sleep) mode. a example: an operation of watchdog timer is as followi ng. to clear the watchdog timer counter in the top of the main routine of the program. main: mov a,#0x5a mov wdtr,a ; clear the watchdog timer counter. . . call sub1 call sub2 . . . . . . jmp main
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 58 v1.4 8.2 timer counter 0 (tc0) 8.2.1 overview the tc0 is an 8-bit binary up timer and event counter fo r general-purpose timer, buzzer and pwm output. tc0 has a auto re-loadable counter that consists of two parts: an 8-bit reload register (tc0 r) into which you write the counter reference value, and an 8-bit counter register (tc0c) whos e value is automatically in cremented by counter logic. figure 8-1. timer count tc0 block diagram the main purposes of the tc0 ti mer counter is as following. ? 8-bit programmable timer: generates interrupts at specific time intervals based on the selected clock frequency. ? arbitrary frequency output (buzzer output): outputs selectable clock frequenc ies to the bz0 pin (p5.4). ? pwm function: pwm output can be generated by the pwm1out bit and output to pwm0out pin (p5.4). tc0 r re load data buffer fcpu tc0 x8 tc0 e nb tc0 c 8-bit binary counter tc0 ti me ou t p0.0 (schmitter trigger) tc0 cks load aload0 auto. reload p5.4 2 tc0 out internal p5.4 i/o circuit cpum 0 s r com pare pwm0out pwm buzzer fosc 2 (8-tc0rate)
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 59 v1.4 8.2.2 tc0m mode register the tc0m is the timer counter mode register, which is an 8- bit read/write register. by loading different value into the tc0m register, users can modify the timer counter clock frequency dynamically when program executing. eight rates for tc0 timer can be selected by tc0rate0 ~ tc0rate2 and tc0x8 bits. if tc0x8=1 the tc0 clock will come from fosc and the range is from fosc/1 to fosc/128, if tc0x8=0 (initial), the range is from fcpu/2 to fcpu/256. the tc0m initial value is zero and the rate is fcpu/256. t he bit7 of tc0m named tc0enb is the control bit to start tc0 timer. the combination of these bits is to determine the tc0 timer frequency. t0m initial value = xxxx 00xx 0d8h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 t0m - - - - tc1x8 tc0x8 - - - - - r/w r/w - bit3 tc1x8 : multiple tc1 timer speed eight times. refe r tc1m register for detailed information. 0 = tc1 clock came from fcpu 1 = tc1 clock came from fosc bit2 tc0x8 : multiple tc0 timer speed eight times. refe r tc0m register for detailed information. 0 = tc0 clock came from fcpu 1 = tc0 clock came from fosc ? note: under tc0 event counter mode (tc0cks =1), tc0x8 bit and tc0rate are useless. tc0m initial value = 0000 0000 0dah bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 tc0m tc0enb tc0rate2 tc0rate1 tc0rat e0 tc0cks aload0 tc0out pwm0out r/w r/w r/w r/w r/w r/w r/w r/w bit 7 tc0enb: tc0 counter enable bit. 0 = disable 1 = enable bit [6:4] tc0rate [2:0]: tc0 internal clock rate select bits. only for tc0cks = 0 tc0rate tc0x8=0 tc0x8=1 000 fcpu/256 fosc/128 001 fcpu/128 fosc/64 010 fcpu/64 fosc/32 011 fcpu/32 fosc/16 100 fcpu/16 fosc/8 101 fcpu/8 fosc/4 110 fcpu/4 fosc/2 111 fcpu/2 fosc/1 bit 3 tc0cks: tc0 clock source select bit. 0 = internal clock source (fcpu or fosc) 1 = external clock source input from p0.0 (int0) pin. bit 2 aload0: auto-reload control bit. 0 = none auto-reload 1 = auto-reload. bit 1 tc0out: tc0 time-out toggle signal output control bit. only valid when pwm0out = 0 0 = disable tc0out signal output and enable p5.4?s i/o function, 1 = enable tc0out signal output and disable p5.4?s i/o function.
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 60 v1.4 bit 0 pwm0out: pwm output control bit. refer ?pwm function de scription? section for detailed information. 0 = disable the pwm output 1 = enable the pwm output (auto- disable the tc0out function.) pwm0out = 1, tc0x8=0 aload0 tc0out tc0 overflow boundary pwm duty range max pwm frequency (fosc = 16m) (fcpu = 4m) note 0 0 ffh to 00h 0/256 ~ 255/256 7.8125k overflow per 256 count 0 1 3fh to 40h 0/64 ~ 63/64 31.25k overflow per 64 count 1 0 1fh to 20h 0/32 ~ 31/32 62.5k overflow per 32 count 1 1 0fh to 10h 0/16 ~ 15/16 125k overflow per 16 count pwm0out = 1, tc0x8=1 aload0 tc0out tc0 overflow boundary pwm duty range max pwm frequency (fosc = 16m) (fcpu = 4m) note 0 0 ffh to 00h 0/256 ~ 255/256 62.5k overflow per 256 count 0 1 3fh to 40h 0/64 ~ 63/64 250k overflow per 64 count 1 0 1fh to 20h 0/32 ~ 31/32 500k overflow per 32 count 1 1 0fh to 10h 0/16 ~ 15/16 1000k overflow per 16 count ? note: when tc0cks=1, tc0 became an external event counter and tc0rate is useless. no more p0.0 interrupt request will be raised. (p0.0irq will be always 0).
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 61 v1.4 8.2.3 tc0c counting register tc0c is an 8-bit counter register for the timer counter (tc0 ). tc0c must be reset whenever the tc0enb is set ?1? to start the timer counter. tc0c is incremented by one wi th a clock pulse which the frequency is determined by tc0rate0 ~ tc0rate2. when tc0c has incremented to ?0ffh ?, it is will be cleared to ?00h? in next clock and an overflow is generated. under tc0 interrupt service reques t (tc0ien) enable condition, the tc0 interrupt request flag will be set ?1? and the system executes the interrupt service routine. tc0c initial value = xxxx xxxx 0dbh bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 tc0c tc0c7 tc0c6 tc0c5 tc0c4 tc0c3 tc0c2 tc0c1 tc0c0 r/w r/w r/w r/w r/w r/w r/w r/w the equation of tc0c initial value is as following. tc0c initial value = 256 - (tc0 interrupt interval time * input clock) a example: to set 10ms interval time for tc0 interrupt at 3.58mhz high-speed mode. tc0c value (74h) = 256 - (10ms * fcpu/256) tc0c initial value = 256 - (tc0 interrupt interval time * input clock) = 256 - (10ms * 3.58 * 10 6 / 256) = 256 - (10 -2 * 3.58 * 10 6 / 256) = 116 = 74h
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 62 v1.4 tc0_counter=8-bit, tc0x8=0 high speed mode (fcpu = 3.58mhz / 4) low speed mode (fcpu = 32768hz / 4) tc0rate tc0clock max overflow interval one step = max/256 ma x overflow interval one step = max/256 000 fcpu/256 73.2 ms 286us 8000 ms 31.25 ms 001 fcpu/128 36.6 ms 143us 4000 ms 15.63 ms 010 fcpu/64 18.3 ms 71.5us 2000 ms 7.8 ms 011 fcpu/32 9.15 ms 35.8us 1000 ms 3.9 ms 100 fcpu/16 4.57 ms 17.9us 500 ms 1.95 ms 101 fcpu/8 2.28 ms 8.94us 250 ms 0.98 ms 110 fcpu/4 1.14 ms 4.47us 125 ms 0.49 ms 111 fcpu/2 0.57 ms 2.23us 62.5 ms 0.24 ms tc0_counter=6-bit , tc0x8=0 high speed mode (fcpu = 3.58mhz / 4) low speed mode (fcpu = 32768hz / 4) tc0rate tc0clock max overflow interval one step = max/256 ma x overflow interval one step = max/256 000 fcpu/256 18.3 ms 71.5us 2000 ms 7.8 ms 001 fcpu/128 9.15 ms 35.8us 1000 ms 3.9 ms 010 fcpu/64 4.57 ms 17.9us 500 ms 1.95 ms 011 fcpu/32 2.28 ms 8.94us 250 ms 0.98 ms 100 fcpu/16 1.14 ms 4.47us 125 ms 0.49 ms 101 fcpu/8 0.57 ms 2.23us 62.5 ms 0.24 ms 110 fcpu/4 0.285 ms 1.11us 31.25 ms 0.12 ms 111 fcpu/2 0.143 ms 0.56 us 15.63 ms 0.06 ms tc0_counter=5-bit, tc0x8=0 high speed mode (fcpu = 3.58mhz / 4) low speed mode (fcpu = 32768hz / 4) tc0rate tc0clock max overflow interval one step = max/256 ma x overflow interval one step = max/256 000 fcpu/256 9.15 ms 35.8us 1000 ms 3.9 ms 001 fcpu/128 4.57 ms 17.9us 500 ms 1.95 ms 010 fcpu/64 2.28 ms 8.94us 250 ms 0.98 ms 011 fcpu/32 1.14 ms 4.47us 125 ms 0.49 ms 100 fcpu/16 0.57 ms 2.23us 62.5 ms 0.24 ms 101 fcpu/8 0.285 ms 1.11us 31.25 ms 0.12 ms 110 fcpu/4 0.143 ms 0.56 us 15.63 ms 0.06 ms 111 fcpu/2 71.25 us 0.278 us 7.81 ms 0.03 ms tc0_counter=4-bit, tc0x8=0 high speed mode (fcpu = 3.58mhz / 4) low speed mode (fcpu = 32768hz / 4) tc0rate tc0clock max overflow interval one step = max/256 ma x overflow interval one step = max/256 000 fcpu/256 4.57 ms 17.9us 500 ms 1.95 ms 001 fcpu/128 2.28 ms 8.94us 250 ms 0.98 ms 010 fcpu/64 1.14 ms 4.47us 125 ms 0.49 ms 011 fcpu/32 0.57 ms 2.23us 62.5 ms 0.24 ms 100 fcpu/16 0.285 ms 1.11us 31.25 ms 0.12 ms 101 fcpu/8 0.143 ms 0.56 us 15.63 ms 0.06 ms 110 fcpu/4 71.25 us 0.278 us 7.81 ms 0.03 ms 111 fcpu/2 35.63 us 0.139 us 3.91 ms 0.015 ms table 8-1. the timing table of timer count tc0
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 63 v1.4 8.2.4 tc0r auto-load register tc0r is an 8-bit register for the tc0 auto-reload functi on. tc0r?s value applies to tc0out and pwm0out functions.. under tc0out application, users must enable and set the tc0r register. the main purpose of tc0r is as following. ? store the auto-reload value and set into tc 0c when the tc0c overflow. (aload0 = 1). ? store the duty value of pwm0out function. tc0r initial value = xxxx xxxx 0cdh bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 tc0r tc0r7 tc0r6 tc0r5 tc0r4 tc0r3 tc0r2 tc0r1 tc0r0 w w w w w w w w the equation of tc0r initial val ue is like tc0c as following. tc0r initial value = 256 - (tc0 interrupt interval time * input clock) note: the tc0r is write-only register can?t be process by incms, decms instructions.
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 64 v1.4 8.2.5 tc0 timer counter operation sequence the tc0 timer counter?s sequence of operation can be following. ? set the tc0c initial value to setup the interval time. ? set the tc0enb to be ?1? to enable tc0 timer counter. ? tc0c is incremented by one with each clock pulse which frequency is corresponding to t0m selection. ? tc0c overflow when tc 0c from ffh to 00h. ? when tc0c overflow occur, the tc0irq flag is set to be ?1? by hardware. ? execute the interrupt service routine. ? users reset the tc0c value and resume the tc0 timer operation. a example: setup the tc0m and tc0c without auto-reload function. b0bclr ftc0ien ; to dis able tc0 interrupt service b0bclr ftc0enb ; to disable tc0 timer mov a,#00h ; b0mov tc0m,a ; to set tc0 clock = fcpu / 256 mov a,#74h ; to set tc0c initial value = 74h b0mov tc0c,a ;(to set tc0 interval = 10 ms) b0bset ftc0ien ; to enable tc0 interrupt service b0bclr ftc0irq ; to cl ear tc0 interrupt request b0bset ftc0enb ; to enable tc0 timer a example: setup the tc0m and tc0c with auto-reload function. b0bclr ftc0ien ; to dis able tc0 interrupt service b0bclr ftc0enb ; to disable tc0 timer mov a,#00h ; b0mov tc0m,a ; to set tc0 clock = fcpu / 256 mov a,#74h ; to set tc0c initial value = 74h b0mov tc0c,a ; (to set tc0 interval = 10 ms) b0mov tc0r,a ; to set tc0r auto-reload register b0bset ftc0ien ; to enable tc0 interrupt service b0bclr ftc0irq ; to cl ear tc0 interrupt request b0bset ftc0enb ; to enable tc0 timer b0bset aload0 ; to enable tc0 auto-reload function.
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 65 v1.4 a example: tc0 interrupt service routine without auto-reload function. org 8 ; interrupt vector jmp int_service int_service: b0xch a, accbuf ; b0xch doesn?t change c, z flag b0mov a, pflag ; b0mov pflagbuf, a ; save pfla g register in a buffer ; save b0bts1 ftc0irq ; check tc0irq jmp exit_int ; tc0irq = 0, exit interrupt vector b0bclr ftc0irq ; reset tc0irq mov a,#74h ; reload tc0c b0mov tc0c,a . . ; tc0 interrupt service routine . . jmp exit_int ; end of tc0 interrupt service routine and exit interrupt vector . . . . exit_int: ; b0mov a, pflagbuf b0mov pflag, a ; restore pflag register from buffer b0xch a, accbuf ; restore acc value. reti ; exit interrupt vector a example: tc0 interrupt service routine with auto-reload. org 8 ; interrupt vector jmp int_service int_service: b0xch a, accbuf ; b0xch doesn?t change c, z flag b0mov a, pflag ; b0mov pflagbuf, a ; save pflag register in a buffer b0bts1 ftc0irq ; check tc0irq jmp exit_int ; tc0irq = 0, exit interrupt vector b0bclr ftc0irq ; reset tc0irq . . ; tc0 interrupt service routine . . jmp exit_int ; end of tc0 interrupt service routine and exit interrupt vector . . . . exit_int: b0mov a, pflag ; b0mov pflagbuf, a ; save pflag register in a buffer b0xch a, accbuf ; restore acc value. reti ; exit interrupt vector
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 66 v1.4 8.2.6 tc0 clock frequency output (buzzer) tc0 timer counter provides a frequency out put function. by setting the tc0 clo ck frequency, the clock signal is output to p5.4 and the p5.4 general purpose i/o function is auto-dis able. the tc0 output signal di vides by 2. the tc0 clock has many combinations and easily to make difference fr equency. this function applies as buzzer output to output multi-frequency. figure 8-2. the tc0out pulse frequency a example: setup tc0out output from tc0 to tc0out (p5.4). the fcpu is 4mhz. the tc0out frequency is 1khz. because the tc0out signal is divided by 2, set the tc0 clock to 2khz. the tc0 clock source is from external oscillator clock. t0c rate is fcpu/4. the tc0rate2~tc0rate1 = 110. tc0c = tc0r = 131, tc0x8=1. mov a,#01100000b b0mov tc0m,a ; set the tc0 rate to fcpu/4 mov a,#131 ; set the auto-reload reference value b0mov tc0c,a b0mov tc0r,a b0bclr ftc0x8 b0bset ftc0out ; enable tc0 output to p5.4 and disable p5.4 i/o function b0bset faload0 ; enable tc0 auto-reload function b0bset ftc0enb ; enable tc0 timer
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 67 v1.4 8.3 timer counter 1 (tc1) 8.3.1 overview the timer counter 1 (tc1) is used to generate an interrupt request when a specified time interval has elapsed. tc1 has a auto re-loadable counter that consis ts of two parts: an 8-bit reload regist er (tc1r) into which you write the counter reference value, and an 8-bit counter register (tc1 c) whose value is automatic ally incremented by counter logic. figure 8-3. timer count tc1 block diagram the main purposes of the tc1 timer is as following. ? 8-bit programmable timer: generates interrupts at specific time intervals based on the selected clock frequency. ? arbitrary frequency output (buzzer output): outputs selectable clock frequenc ies to the bz1 pin (p5.3). ? pwm function: pwm output can be generated by the pwm1out bit and output to pwm1out pin (p5.3). tc1 r re load data buffer tc1 e nb tc1 c 8-bit binary counter tc1 ti me ou t tc1 cks load aload1 auto. reload p5.3 2 tc1 out internal p5.3 i/o circuit cpum0 s r com pare pwm1out pwm buzzer fcpu tc1 x8 p0.1 (schmitter trigger) fosc 2 (8-tc0rate)
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 68 v1.4 8.3.2 tc1m mode register the tc1m is an 8-bit read/write timer mode register. by l oading different value into the tc1m register, users can modify the timer clock frequency dynam ically as program executing. eight rates for tc1 timer can be selected by tc1rate0 ~ tc1rate2 bits. if tc1x8=1 the tc1 clock will come from fosc and the range is from fosc/1 to fosc/ 128. if tc1x8=0 (initial), the range is from fcpu(fosc)/2 to fcpu(fosc)/256. the tc1m initial value is zero and the rate is fcpu/256. the bi t7 of tc1m called tc1enb is the control bit to start tc1 timer. the combination of these bits is to det ermine the tc1 timer clock frequency and the intervals. t0m initial value = xxxx 00xx 0d8h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 t0m - - - - tc1x8 tc0x8 - - - - - r/w r/w - bit3 tc1x8 : multiple tc1 timer speed eight times. refe r tc1m register for detailed information. 0 = tc1 clock came from fcpu 1 = tc1 clock came from fosc bit2 tc0x8 : multiple tc0 timer speed eight times. refe r tc0m register for detailed information. 0 = tc0 clock came from fcpu 1 = tc0 clock came from fosc ? note: under tc1 event counter mode (tc1cks =1), tc1x8 bit and tc1rate are useless. tc1m initial value = 0000 0000 0dch bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 tc1m tc1enb tc1rate2 tc1rate1 tc1rat e0 tc1cks aload1 tc1out pwm1out r/w r/w r/w r/w r/w r/w r/w r/w bit 7 tc1enb: tc1 counter enable bit. 0 = disable 1 = enable bit [6:4] tc1rate [2:0]: tc1 internal clock rate select bits. only for tc1cks = 0 tc1rate tc1x8=0 tc1x8=1 000 fcpu/256 fosc/128 001 fcpu/128 fosc/64 010 fcpu/64 fosc/32 011 fcpu/32 fosc/16 100 fcpu/16 fosc/8 101 fcpu/8 fosc/4 110 fcpu/4 fosc/2 111 fcpu/2 fosc/1 bit 3 tc1cks: tc1 clock source select bit. 0 = internal clock source (fcpu/fosc) 1 = external clock source input from p0.1 (int1) pin. bit 2 aload1: auto-reload control bit. 0 = none auto-reload 1 = auto-reload. bit 1 tc1out: tc1 time-out toggle signal output control bit. only valid when pwm1out = 0 0 = disable tc1out signal output and enable p5.3?s i/o function, 1 = enable tc1out signal output and disable p5.3?s i/o function.
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 69 v1.4 bit 0 pwm1out: pwm output control bit. refer ?pwm function de scription? section for detailed information. 0 = disable the pwm output 1 = enable the pwm output (auto- disable the tc1out function.) pwm1out = 1, tc1x8=0 aload1 tc1out tc1 overflow boundary pwm duty range max pwm frequency (fosc = 16m) (fcpu = 4m) note 0 0 ffh to 00h 0/256 ~ 255/256 7.8125k overflow per 256 count 0 1 3fh to 40h 0/64 ~ 63/64 31.25k overflow per 64 count 1 0 1fh to 20h 0/32 ~ 31/32 62.5k overflow per 32 count 1 1 0fh to 10h 0/16 ~ 15/16 125k overflow per 16 count pwm0out = 1, tc1x8=1 aload0 tc0out tc0 overflow boundary pwm duty range max pwm frequency (fosc = 16m) (fcpu = 4m) note 0 0 ffh to 00h 0/256 ~ 255/256 62.5k overflow per 256 count 0 1 3fh to 40h 0/64 ~ 63/64 250k overflow per 64 count 1 0 1fh to 20h 0/32 ~ 31/32 500k overflow per 32 count 1 1 0fh to 10h 0/16 ~ 15/16 1000k overflow per 16 count ? note: when tc1cks=1, tc1 became an external event counter and tc1rate is useless. no more p0.1 interrupt request will be raised. (p0.1irq will be always 0).
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 70 v1.4 8.3.3 tc1c counting register tc1c is an 8-bit counter register for the timer counter (tc1 ). tc1c must be reset whenever the tc1enb is set ?1? to start the timer. tc1c is incremented by one with a cl ock pulse which the frequency is determined by tc1rate0 ~ tc1rate2. when tc1c has incremented to ?0ffh?, it is will be cleared to ?00h? in next clock and an overflow is generated. under tc1 interrupt service request (tc1ien) enable condition, the tc1 interrupt request flag will be set ?1? and the system executes the interrupt service routine. tc1c initial value = xxxx xxxx 0ddh bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 tc1c tc1c7 tc1c6 tc1c5 tc1c4 tc1c3 tc1c2 tc1c1 tc1c0 r/w r/w r/w r/w r/w r/w r/w r/w the interval time of tc1 basic timer table. the equation of tc1c initial value is as following. tc1c initial value = 256 - (tc1 interrupt interval time * input clock) a example: to set 10ms interval time for tc1 interrupt at 3.58mhz high-speed mode. tc1c value (74h) = 256 - (10ms * fcpu/256) tc1c initial value = 256 - (tc1 interrupt interval time * input clock) = 256 - (10ms * 3.58 * 10 6 / 256) = 256 - (10 -2 * 3.58 * 10 6 / 256) = 116 = 74h
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 71 v1.4 tc1_counter=8-bit, tc1x8=0 high speed mode (fcpu = 3.58mhz / 4) low speed mode (fcpu = 32768hz / 4) tc1rate tc1clock max overflow interval one step = max/256 ma x overflow interval one step = max/256 000 fcpu/256 73.2 ms 286us 8000 ms 31.25 ms 001 fcpu/128 36.6 ms 143us 4000 ms 15.63 ms 010 fcpu/64 18.3 ms 71.5us 2000 ms 7.8 ms 011 fcpu/32 9.15 ms 35.8us 1000 ms 3.9 ms 100 fcpu/16 4.57 ms 17.9us 500 ms 1.95 ms 101 fcpu/8 2.28 ms 8.94us 250 ms 0.98 ms 110 fcpu/4 1.14 ms 4.47us 125 ms 0.49 ms 111 fcpu/2 0.57 ms 2.23us 62.5 ms 0.24 ms tc1_counter=6-bit, tc1x8=0 high speed mode (fcpu = 3.58mhz / 4) low speed mode (fcpu = 32768hz / 4) tc1rate tc1clock max overflow interval one step = max/256 ma x overflow interval one step = max/256 000 fcpu/256 18.3 ms 71.5us 2000 ms 7.8 ms 001 fcpu/128 9.15 ms 35.8us 1000 ms 3.9 ms 010 fcpu/64 4.57 ms 17.9us 500 ms 1.95 ms 011 fcpu/32 2.28 ms 8.94us 250 ms 0.98 ms 100 fcpu/16 1.14 ms 4.47us 125 ms 0.49 ms 101 fcpu/8 0.57 ms 2.23us 62.5 ms 0.24 ms 110 fcpu/4 0.285 ms 1.11us 31.25 ms 0.12 ms 111 fcpu/2 0.143 ms 0.56 us 15.63 ms 0.06 ms tc1_counter=5-bit, tc1x8=0 high speed mode (fcpu = 3.58mhz / 4) low speed mode (fcpu = 32768hz / 4) tc1rate tc1clock max overflow interval one step = max/256 ma x overflow interval one step = max/256 000 fcpu/256 9.15 ms 35.8us 1000 ms 3.9 ms 001 fcpu/128 4.57 ms 17.9us 500 ms 1.95 ms 010 fcpu/64 2.28 ms 8.94us 250 ms 0.98 ms 011 fcpu/32 1.14 ms 4.47us 125 ms 0.49 ms 100 fcpu/16 0.57 ms 2.23us 62.5 ms 0.24 ms 101 fcpu/8 0.285 ms 1.11us 31.25 ms 0.12 ms 110 fcpu/4 0.143 ms 0.56 us 15.63 ms 0.06 ms 111 fcpu/2 71.25 us 0.278 us 7.81 ms 0.03 ms tc1_counter=4-bit, tc1x8=0 high speed mode (fcpu = 3.58mhz / 4) low speed mode (fcpu = 32768hz / 4) tc1rate tc1clock max overflow interval one step = max/256 ma x overflow interval one step = max/256 000 fcpu/256 4.57 ms 17.9us 500 ms 1.95 ms 001 fcpu/128 2.28 ms 8.94us 250 ms 0.98 ms 010 fcpu/64 1.14 ms 4.47us 125 ms 0.49 ms 011 fcpu/32 0.57 ms 2.23us 62.5 ms 0.24 ms 100 fcpu/16 0.285 ms 1.11us 31.25 ms 0.12 ms 101 fcpu/8 0.143 ms 0.56 us 15.63 ms 0.06 ms 110 fcpu/4 71.25 us 0.278 us 7.81 ms 0.03 ms 111 fcpu/2 35.63 us 0.139 us 3.91 ms 0.015 ms table 8-2. the timing table of timer count tc1
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 72 v1.4 8.3.4 tc1r auto-load register tc1r is an 8-bit register for the tc1 auto-reload functi on. tc1r?s value applies to tc1out and pwm1out functions. under tc1out application, users must enable and set the tc1r register. the main purpose of tc1r is as following. ? store the auto-reload value and set into tc 1c when the tc1c overflow. (aload1 = 1). ? store the duty value of pwm1out function. tc1r initial value = xxxx xxxx 0deh bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 tc1r tc1r7 tc1r6 tc1r5 tc1r4 tc1r3 tc1r2 tc1r1 tc1r0 w w w w w w w w the equation of tc1r initial val ue is like tc1c as following. tc1r initial value = 256 - (tc1 interrupt interval time * input clock) note: the tc1r is write-only register can?t be process by incms, decms instructions.
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 73 v1.4 8.3.5 tc1 timer counter operation sequence the tc1 timer?s sequence of operation can be following. ? set the tc1c initial value to setup the interval time. ? set the tc1enb to be ?1? to enable tc1 timer counter. ? tc1c is incremented by one with each clock pulse which frequency is corresponding to tc1m selection. ? tc1c overflow if tc 1c from ffh to 00h. ? when tc1c overflow occur, the tc1irq flag is set to be ?1? by hardware. ? execute the interrupt service routine. ? users reset the tc1c value and resume the tc1 timer operation. a example: setup the tc1m and tc1c without auto-reload function. b0bclr ftc1ien ; to dis able tc1 interrupt service b0bclr ftc1enb ; to disable tc1 timer b0bclr ftc1x8 ; mov a,#00h ; b0mov tc1m,a ; to set tc1 clock = fcpu / 256 mov a,#74h ; to set tc1c initial value = 74h b0mov tc1c,a ;(to set tc1 interval = 10 ms) b0bset ftc1ien ; to enable tc1 interrupt service b0bclr ftc1irq ; to cl ear tc1 interrupt request b0bset ftc1enb ; to enable tc1 timer a example: setup the tc1m and tc1c with auto-reload function. b0bclr ftc1ien ; to dis able tc1 interrupt service b0bclr ftc1enb ; to disable tc1 timer b0bclr ftc1x8 ; mov a,#00h ; b0mov tc1m,a ; to set tc1 clock = fcpu / 256 mov a,#74h ; to set tc1c initial value = 74h b0mov tc1c,a ; (to set tc1 interval = 10 ms) b0mov tc1r,a ; to set tc1r auto-reload register b0bset ftc1ien ; to enable tc1 interrupt service b0bclr ftc1irq ; to cl ear tc1 interrupt request b0bset ftc1enb ; to enable tc1 timer b0bset aload1 ; to enable tc1 auto-reload function.
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 74 v1.4 a example: tc1 interrupt service routine without auto-reload function. org 8 ; interrupt vector jmp int_service int_service: b0xch a, accbuf ; b0xch doesn?t change c, z flag b0mov a, pflag b0mov pflagbuf, a ; save pflag register in a buffer b0bts1 ftc1irq ; check tc1irq jmp exit_int ; tc1irq = 0, exit interrupt vector b0bclr ftc1irq ; reset tc1irq mov a,#74h ; reload tc1c b0mov tc1c,a . . ; tc1 interrupt service routine . . jmp exit_int ; end of tc1 interrupt service routine and exit interrupt vector . . . . exit_int: b0mov a, pflagbuf b0mov pflag, a ; restore pflag register from buffer b0xch a, accbuf ; restore acc value. reti ; exit interrupt vector a example: tc1 interrupt service routine with auto-reload. org 8 ; interrupt vector jmp int_service int_service: b0xch a, accbuf ; b0xch doesn?t change c, z flag b0mov a, pflag b0mov pflagbuf, a ; save pflag register in a buffer b0bts1 ftc1irq ; check tc1irq jmp exit_int ; tc1irq = 0, exit interrupt vector b0bclr ftc1irq ; reset tc1irq . . ; tc1 interrupt service routine . . jmp exit_int ; end of tc1 interrupt service routine and exit interrupt vector . . . . exit_int: b0mov a, pflagbuf b0mov pflag, a ; restore pflag register from buffer b0xch a, accbuf ; restore acc value. reti ; exit interrupt vector
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 75 v1.4 8.3.6 tc1 clock frequency output (buzzer) tc1 timer counter provides a frequency out put function. by setting the tc1 clo ck frequency, the clock signal is output to p5.3 and the p5.3 general purpose i/o function is auto-dis able. the tc1 output signal di vides by 2. the tc1 clock has many combinations and easily to make difference fr equency. this function applies as buzzer output to output multi-frequency. figure 8-4. the tc1out pulse frequency a example: setup tc1out output from tc1 to tc1out (p5.3). the fcpu is 4mhz. the tc1out frequency is 1khz. because the tc1out signal is divided by 2, set the tc1 clock to 2khz. the tc1 clock source is from external oscillator clock. tc1 rate is fcpu/4. the tc1rate2~tc1rate1 = 110. tc1x8=1, tc1c = tc1r = 131. b0bclr ftc1x8 ; mov a,#01100000b b0mov tc1m,a ; set the tc1 rate to fcpu/4 mov a,#131 ; set the auto-reload reference value b0mov tc1c,a b0mov tc1r,a b0bset ftc1out ; enable tc1 output to p5.3 and disable p5.3 i/o function b0bset faload1 ; enable tc1 auto-reload function b0bset ftc1enb ; enable tc1 timer ? note: the tc1out frequency table is as tc0out frequency table. please consult tc0out frequency table. (table 7-2~7-5)
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 76 v1.4 8.4 pwm function description 8.4.1 overview pwm function is generated by tc0/tc1 timer counter and output the pwm signal to pwm0out pin (p5.4)/ pwm1out pin (p5.3). the 8-bit counter counts modulus 256, fr om 0-255, inclusive. the value of the 8-bit counter is compared to the contents of the reference register tc0r/t c1r. when the reference register value (tc0r/tc1r) is equal to the counter value tc0c/tc1c, the pwm output goes low. when the count er reaches zero, the pwm output is forced high. initial pwm output level is low until the counter value cr oss boundary (e.g. tc0c changes from ffh back to 00h), the pwm outputs are forced to high level. the pulse width rati o (duty cycle) is defined by tc0r/tc1r registers and the overflow boundary is defined by aload0/aload1 and tc0out /tc1out bits. pwm output can be held at low level by continuously loading the tc0r/tc1r with 00h. by cont inuously loading the tc0r with boundary value (e.g. ffh), you can hold the pwm output to high level, except for the la st pulse of the clock source , which sends the output low. pwm0out = 1, tc0x8=0 aload0 aload1 tc0out tc1out tc0 overflow boundary tc1 overflow boundary pwm duty range max pwm frequency (fcpu = 4m) note 0 0 ffh to 00h 0/256 ~ 255/256 7.8125k overflow per 256 count 0 1 3fh to 40h 0/64 ~ 63/64 31.25k overflow per 64 count 1 0 1fh to 20h 0/32 ~ 31/32 62.5k overflow per 32 count 1 1 0fh to 10h 0/16 ~ 15/16 125k overflow per 16 count aload0 aload1 tc0out tc1out tc0r tc1r pwm duty range 0 0 00000000 to 11111111 0/256 to 255/256 0 1 xx000000 to xx111111 0/64 to 63/64 1 0 xxx00000 to xxx11111 0/32 to 31/32 1 1 xxxx0000 to xxxx1111 0/16 to 15/16 table 8-2. the pwm duty cycle table note: if pwm0out or tc0out is enabled, p5.4 mode will be forced as output mode automatically. when pwm0out or tc0out is disabled, p5 .4 mode will be defined by p54m bit. figure 8-5 the output of pwm with different tc0r/tc1r. tc0/tc1 clock tc0r/tc1r = 00h low high low low high tc0r/tc1r = 01h tc0r/tc1r = 80h tc0r/tc1r = ffh low high 01 128 ..... 254 255 ..... 01 128 ..... 254 255 ..... tc0/tc1 clock tc0r/tc1r = 00h low high low low high tc0r/tc1r = 01h tc0r/tc1r = 80h tc0r/tc1r = ffh low high low high 01 128 ..... 254 255 ..... 01 128 ..... 254 255 ..... 01 128 ..... 254 255 ..... ..... 01 128 ..... 254 255 ..... .....
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 77 v1.4 8.4.2 pwm program description a example: setup pwm0 output from tc0 to pwm0out (p 5.4). the fcpu is 4mhz. the duty of pwm is 30/256. the pwm frequency is about 1khz. the pwm clock source is from external oscillator clock. tc0 rate is fcpu/4. the tc0rate2~tc0rate1 = 110. tc0c = tc0r = 30. b0bclr ftc0x8 ; b0bclr ftc1x8 ; mov a,#01100000b b0mov tc0m,a ; set the tc0 rate to fcpu/4 b0mov tc0m,a ; set the tc0 rate to fcpu/4 mov a,#0x00 ;first time initial tc0 mov a,#30 ; set the pwm duty to 30/256 b0mov tc0r,a b0bclr ftc0out ; disable tc0out function. b0bset fpwm0out ; enable pwm0 output to p5.4 and disable p5.4 i/o function b0bset ftc0enb ; enable tc0 timer ? note1: the tc0r and tc1r are write-only regi sters. don?t process them using incms, decms instructions. ? note2: set tc0c at initial is to make first duty-cycle correct. a example: modify tc0r/tc1r registers? value. mov a, #30h ; input a number using b0mov instruction. b0mov tc0r, a incms buf0 ; get the new tc0r va lue from the buf0 buffer defined by b0mov a, buf0 ; programming. b0mov tc0r, a ? note3: that is better to set the tc0c and tc0r valu e together when pwm0 duty modified. it protects the pwm0 signal no glitch as pwm0 duty changing. that is better to set the tc1c and tc1r value together when pwm1 duty modified. it protects the pw m1 signal no glitch as pwm1 duty changing. ? note4: the tc0out function must be set ?0? when pwm0 output enable. the tc1out function must be set ?0? when pwm1 output enable. ? note5: the pwm can work with interrupt request.
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 78 v1.4 8.4.3 pwm duty with tcxr changing in pwm mode, the system will compare tcxc and tcxr a ll the time. when tcxc = tc0r pwm high to low tc0c < tc0r pwm low to high new tc0r new tc0r
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 79 v1.4 8.4.4 tcxirq and pwm duty in pwm mode, the frequency of tc0irq is depended on pwm duty range. aloadx tcxout tcx overflow boundary pwm duty range tcxirq frequency 0 0 ffh to 00h 0/256 ~ 255/256 tcx clock / 256 0 1 3fh to 40h 0/64 ~ 63/64 tcx clock / 64 1 0 1fh to 20h 0/32 ~ 31/32 tcx clock / 32 1 1 0fh to 10h 0/16 ~ 15/16 tcx clock / 16 from following diagram, the tc0irq frequency is related with pwm duty. tc0 overflow, tc0irq = 1 pwm0 output (duty range 0~15) 0xff tc0c value 0x00 pwm0 output (duty range 0~31) 0xff tc0c value 0x00 pwm0 output (duty range 0~63) 0xff tc0c value 0x00 0xff tc0c value 0x00 pwm0 output (duty range 0~255) tc0 overflow, tc0irq = 1 tc0 overflow, tc0irq = 1 tc0 overflow, tc0irq = 1
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 80 v1.4 9 interrupt 9.1 overview the sn8p2710 provides 4 interrupt sources, including two in ternal interrupts (tc0, tc1) and two external interrupts (int0, int1). these external interr upts can wakeup the chip from power down mode to high-speed normal mode. the external clock input pins of int0/int1 ar e shared with p0.0/p0.1 pins. once interr upt service is execut ed, the gie bit in stkp register will clear to ?0? for stopping other interrupt reques t. when interrupt service exits, the gie bit will set to ?1? to accept the next interrupts? request. all of the interrupt request signals are stored in intrq register. the user can program the chip to check intrq?s c ontent for setting executive priority. ? note: 1.the gie bit must enable at first and all interrupt operations work. 9.2 inten interrupt enable register inten is the interrupt request control register including two internal interrupts, two exte rnal interrupts. one of the register to be set ?1? is to enable the interrupt request functi on. once of the interrupt occur, the program jump to org 8 to execute interrupt service routines . the program exits the interrupt servic e routine when the returning interrupt service routine instructi on (reti) is executed. inten initial value = 0000 0000 0c9h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 inten - tc1ien tc0ien - - - p01ien p00ien - r/w r/w - - - r/w r/w bit 6 tc1ien: timer interrupt control bit. 0 = disable tc1 interrupt 1 = enable tc1 interrupt bit 5 tc0ien: timer interrupt control bit. 0 = disable tc0 interrupt 1 = enable tc10interrupt bit 1 p01ien: external p0.1 interrupt control bit. 0 = disable p01 interrupt 1 = enable p01 interrupt bit 0 p00ien: external p0.0 interrupt control bit. 0 = disable p00 interrupt 1 = enable p00 interrupt
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 81 v1.4 9.3 intrq interrupt request register intrq is the interrupt request flag regi ster. the register includes all interr upt request indication flags. each one of these interrupt request occurs, the bit of the intrq regist er would be set ?1?. the intrq value needs to be clear by programming after detecting the flag. in the interrupt vect or of program, users know the any interrupt requests occurring by the register and do the routi ne corresponding of the interrupt request. intrq initial value = x00x xx00 0c8h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 intrq - tc1irq tc0irq - - - p01irq p00irq - r/w r/w - - - r/w r/w bit 6 tc1irq: tc1 timer interrupt request controls bit. 0 = non request from tc1 1 = request from tc1 bit 5 tc0irq: tc0 timer interrupt request controls bit. 0 = non request from tc0 1 = request from tc0 bit 1 p01irq: external p0.1 interrupt request bit. 0 = non-request from p01 1 = request from p01 bit 0 p00irq: external p0.0 interrupt request bit. 0 = non-request from p00 1 = request from p00 9.4 p0.0 interrupt trigger edge control register pedge initial value = xxx1 0xxx 0bfh bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 pedge - - - p00g1 p00g0 - - - - - - r/w r/w - - - bit [4:3] p00g [1:0]: p0.0 interrupt trigger edge control register 00 = reserved 01 = rising edge 10 = falling edge (reset default setting) 11 = falling and rising edge both (level change trigger)
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 82 v1.4 9.5 interrupt operation description sn8p2710 provides 4 interrupts. the operation of the 4 interrupts is as following. 9.5.1 gie global interrupt operation gie is the global interrupt control bit. all interrupts start wo rk after the gie = 1. it is necessary for interrupt service request. one of the interrupt requests occurs, and the program counter (pc) points to the interrupt vector (org 8) and the stack add 1 level. stkp initial value = 0xxx 1111 0dfh bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 stkp gie - - - - stkpb2 stkpb1 stkpb0 r/w - - - - r/w r/w r/w bit 7 gie: global interrupt control bit. 0 = disable interrupt function 1 = enable interrupt function a example: set global interrupt control bit (gie). b0bset fgie ; enable gie ? note: the gie bit must enable and all interrupt operations work.
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 83 v1.4 9.5.2 int0 (p0.0) interrupt operation the int0 is triggered by falling edge. when the int0 trigger occurs, the p00irq will be set to ?1? however the p00ien is enable or disable. if the p00ien = 1, the trigger event will make the p00irq to be ?1? and the system enter interrupt vector. if the p00ien = 0, the trigger ev ent will make the p00irq to be ?1? but t he system will not enter interrupt vector. users need to care for the operation under multi-interrupt situation. a example: int0 interrupt request setup. b0bset fp00ien ; enable int0 interrupt service b0bclr fp00irq ; clear int0 interrupt request flag b0bset fgie ; enable gie a example: int0 interrupt service routine. org 8 ; interrupt vector jmp int_service int_service: b0xch a, accbuf ; b0xch doesn?t change c, z flag b0mov a, pflag b0mov pflagbuf, a ; save pflag register in a buffer b0bts1 fp00irq ; check p00irq jmp exit_int ; p00irq = 0, exit interrupt vector b0bclr fp00irq ; reset p00irq . . ; int0 interrupt service routine . . exit_int: b0mov a, pflagbuf b0mov pflag, a ; restore pflag register from buffer b0xch a, accbuf ; restore acc value. reti ; exit interrupt vector 9.5.3 int1 (p0.1) interrupt operation the int1 is triggered by falling edge. when the int1 trigger occurs, the p01irq will be set to ?1? however the p01ien is enable or disable. if the p01ien = 1, the trigger event will make the p01irq to be ?1? and the system enter interrupt vector. if the p01ien = 0, the trigger ev ent will make the p01irq to be ?1? but t he system will not enter interrupt vector. users need to care for the operation under multi-interrupt situation. a example: int1 interrupt request setup. b0bset fp01ien ; enable int1 interrupt service b0bclr fp01irq ; clear int1 interrupt request flag b0bset fgie ; enable gie
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 84 v1.4 a example: int1 interrupt service routine. org 8 ; interrupt vector jmp int_service int_service: b0xch a, accbuf ; b0xch doesn?t change c, z flag b0mov a, pflag b0mov pflagbuf, a ; save pflag register in a buffer b0bts1 fp01irq ; check p01irq jmp exit_int ; p01irq = 0, exit interrupt vector b0bclr fp01irq ; reset p01irq . . ; int1 interrupt service routine . . exit_int: b0mov a, pflagbuf b0mov pflag, a ; restore pflag register from buffer b0xch a, accbuf ; restore acc value. reti ; exit interrupt vector
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 85 v1.4 9.5.4 tc0 interrupt operation when the tc0c counter occurs overflow, the tc0irq will be set to ?1? no matter the tc0ien is enable or disable. if the tc0ien = 1, the trigger event will make the tc0irq to be ?1? and the system enter interrupt vector. if the tc0ien = 0, the trigger event will make the tc0i rq to be ?1? but the system will not ent er interrupt vector. users need to care for the operation under multi-interrupt situation. a example: tc0 interrupt request setup. b0bclr ftc0ien ; disable tc0 interrupt service b0bclr ftc0enb ; disable tc0 timer mov a, #20h ; b0mov tc0m, a ; set tc0 clock = fcpu / 64 mov a, #74h ; set tc0c initial value = 74h b0mov tc0c, a ; set tc0 interval = 10 ms b0bset ftc0ien ; enable tc0 interrupt service b0bclr ftc0irq ; clear tc0 interrupt request flag b0bset ftc0enb ; enable tc0 timer b0bset fgie ; enable gie a example: tc0 interrupt service routine. org 8 ; interrupt vector jmp int_service int_service: b0xch a, accbuf ; b0xch doesn?t change c, z flag b0mov a, pflag b0mov pflagbuf, a ; save pflag register in a buffer b0bts1 ftc0irq ; check tc0irq jmp exit_int ; tc0irq = 0, exit interrupt vector b0bclr ftc0irq ; reset tc0irq mov a, #74h b0mov tc0c, a ; reset tc0c. . . ; tc0 interrupt service routine . . exit_int: b0mov a, pflagbuf b0mov pflag, a ; restore pflag register from buffer b0xch a, accbuf ; restore acc value. reti ; exit interrupt vector
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 86 v1.4 9.5.5 tc1 interrupt operation when the tc1c counter occurs overflow, the tc1irq will be set to ?1? no matter the tc1ien is enable or disable. if the tc1ien = 1, the trigger event will make the tc1irq to be ?1? and the system enter interrupt vector. if the tc1ien = 0, the trigger event will make the tc1i rq to be ?1? but the system will not ent er interrupt vector. users need to care for the operation under multi-interrupt situation. a example: tc1 interrupt request setup. b0bclr ftc1ien ; disable tc1 interrupt service b0bclr ft c1enb ; disable tc1 timer mov a, #20h ; b0mov tc1m, a ; set tc1 clock = fcpu / 64 mov a, #74h ; set tc1c initial value = 74h b0mov tc1c, a ; set tc1 interval = 10 ms b0bset ftc1ien ; enable tc1 interrupt service b0bclr ftc1irq ; clear tc1 interrupt request flag b0bset ftc1enb ; enable tc1 timer b0bset fgie ; enable gie a example: tc1 interrupt service routine. org 8 ; interrupt vector jmp int_service int_service: b0xch a, accbuf ; b0xch doesn?t change c, z flag b0mov a, pflag b0mov pflagbuf, a ; save pflag register in a buffer b0bts1 ftc1irq ; check tc1irq jmp exit_int ; tc1irq = 0, exit interrupt vector b0bclr ftc1irq ; reset tc1irq mov a, #74h b0mov tc1c, a ; reset tc1c. . . ; tc1 interrupt service routine . . exit_int: b0mov a, pflagbuf b0mov pflag, a ; restore pflag register from buffer b0xch a, accbuf ; restore acc value. reti ; exit interrupt vector
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 87 v1.4 9.5.6 multi-interrupt operation in most conditions, the software designer uses more t han one interrupt request. proce ssing multi-interrupt request needs to set the priority of these interr upt requests. the irq flags of the 4 interr upt are controlled by the interrupt event occurring. but the irq flag set doesn?t mean the system to ex ecute the interrupt vector. the irq flags can be triggered by the events without interr upt enable. just only any the event occurs and the irq will be logic ?1?. the irq and its trigger event relationship is as the below table. interrupt name trigger event description p00irq p0.0 trigger. falling edge. p01irq p0.1 trigger. falling edge. tc0irq tc0c overflow. tc1irq tc1c overflow. there are two things need to do for multi-interrupt. one is to make a good priority for these interrupt requests. two is using ien and irq flags to decide executing interrupt service routine or not. users have to check interrupt control bit and interrupt request flag in interrupt vector. there is a simple routine as following.
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 88 v1.4 a example: how does users check the interrupt request in multi-interrupt situation? org 8 ; interrupt vector nop b0xch a, accbuf ; b0xch doesn?t change c, z flag b0mov a, pflag b0mov pflagbuf, a ; save pflag register in a buffer intp00chk: ; check int0 interrupt request b0bts1 fp00ien ; check p00ien jmp intp01chk ; jump check to next interrupt b0bts0 fp00irq ; check p00irq jmp intp00 ; jump to int0 interrupt service routine intp01chk: ; check int1 interrupt request b0bts1 fp01ien ; check p01ien jmp inttc0chk ; jump check to next interrupt b0bts0 fp01irq ; check p01irq jmp intp01 ; jump to int1 interrupt service routine inttc0chk: ; check tc0 interrupt request b0bts1 ftc0ien ; check tc0ien jmp inttc1chk ; jump check to next interrupt b0bts0 ftc0irq ; check tc0irq jmp inttc0 ; jump to tc0 interrupt service routine inttc1hk: ; check tc1 interrupt request b0bts1 ftc1ien ; check tc1ien jmp int_exit ; jump check to next interrupt b0bts0 ftc1irq ; check tc1irq jmp inttc1 ; jump to tc1 interrupt service routine int_exit: b0mov a, pflagbuf b0mov pflag, a ; restore pflag register from buffer b0xch a, accbuf ; restore acc value. reti ; exit interrupt vector
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 89 v1.4 10 i/o port 10.1 overview the sn8p2710 provides up to four ports for users? applicat ion, consisting of one input onl y port (p0), three i/o ports ( p2, p4, p5). the direction of i/o port is selected by pn m register and register pnur is defined for user setting pull-up register. after the system resets, all ports work as input function without pull-up resistors. port 0.1 and p0.2 structure: pin int. bus int. rst pull-up pnur port 0.3 structure: pin ext. reset code option int. bus int. rst port 2, 5 structure: pull-up pin output latch pnm, pnur input bus pnm output bus port 4 structure: gchs int. adc p4con pull-up output latch pnm, pnur input bus pnm output bus pin figure 10-1. the i/o pin circuit diagram
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 90 v1.4 10.2 i/o port function table port/pin i/o function description remark general-purpose input function p0.0: tc0 external clock input pin p0.1: tc1 external clock input pin external interrupt (int0~int1) p0.0~p0.1 i wakeup for power down mode general-purpose input function p0.2 i wakeup for power down mode general-purpose input function no pull-up, no wakeup function p0.3 i share with reset pin p2.0~p2.7 i/o general-purpose input/output function general-purpose input/output function p4.0~p4.7 i/o adc analog signal input p5.0~p5.6 i/o general-purpose input/output function table 10-1. i/o function table
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 91 v1.4 10.3 pull-up resisters pull-up register can set pull-up regist er by port. the typical pull-up register value is 200k@3v and 100k@5v. ? port0 0e0h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 p0ur - - - - - p02r p01r p00r read/write - - - - - w w w after reset - - - - - 0 0 0 ? port2 0e2h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 p2ur p27r p26r p25r p24r p23r p22r p21r p20r read/write w w w w w w w w after reset 0 0 0 0 0 0 0 0 ? port4 0e4h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 p4ur p47r p46r p45r p44r p43r p42r p41r p40r read/write w w w w w w w w after reset 0 0 0 0 0 0 0 0 ? port5 0e5h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 p5ur p56r p55r p54r p53r p52r p51r p50r read/write w w w w w w w after reset 0 0 0 0 0 0 0 a example: i/o pull up register clr p0ur ; disable port0 pull-up register. mov a, #01h ; , b0mov p0ur, a ; enable port0.0 pull-up register
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 92 v1.4 i/o port mode the port direction is programmed by pnm register. port 0 is always input mode. port 1,2, 3,4 and 5 can select input or output direction. p2m initial value = 0000 0000 0c2h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 p2m p27m p26m p25m p24m p23m p22m p21m p20m r/w r/w r/w r/w r/w r/w r/w r/w bit [7:0] p2 [7:0] m: p2.0~p2.7 i/o direction control bit. 0 = set p2 as input mode 1 = set p2 as output mode p4m initial value = 0000 0000 0c4h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 p4m p47m p46m p45m p44m p43m p42m p41m p40m r/w r/w r/w r/w r/w r/w r/w r/w bit [7:0] p4 [7:0] m: p4.0~p4.7 i/o direction control bit. 0 = set p4 as input mode 1 = set p4 as output mode p5m initial value = x000 0000 0c5h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 p5m p56m p55m p54m p53m p52m p51m p50m r/w r/w r/w r/w r/w r/w r/w bit [6:0] p5 [6:0] m: p5.0~p5.6 i/o direction control bit. 0 = set p5 as input mode 1 = set p5 as output mode
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 93 v1.4 a example: i/o mode selecting. clr p2m clr p4m clr p5m mov a, #0ffh ; set all ports to be output mode. b0mov p2m, a b0mov p4m, a b0mov p5m, a b0bclr p2m.5 ; set p2.5 to be input mode. b0bset p2m.5 ; set p2.5 to be output mode.
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 94 v1.4 10.4 i/o port data register p0 initial value = xxxx xxxx 0d0h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 p0 - - - - p03 p02 p01 p00 - - - - r r r r p2 initial value = xxxx xxxx 0d2h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 p2 p27 p26 p25 p24 p23 p22 p21 p20 r/w r/w r/w r/w r/w r/w r/w r/w p4 initial value = xxxx xxxx 0d4h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 p4 p47 p46 p45 p44 p43 p42 p41 p40 r/w r/w r/w r/w r/w r/w r/w r/w p5 initial value = xxxx xxxx 0d5h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 p5 p56 p55 p54 p53 p52 p51 p50 r/w r/w r/w r/w r/w r/w r/w a example: read data from input port. b0mov a, p0 ; read data from port 0 b0mov a, p2 ; read data from port 2 b0mov a, p4 ; read data from port 4 b0mov a, p5 ; read data from port 5 a example: write data to output port. mov a, #55h ; write data 55h to port 1, port2, port 4, port 5 b0mov p2, a b0mov p4, a b0mov p5, a
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 95 v1.4 a example: write one bit data to output port. b0bset p2.3 ; set p2.3 and p4.0 to be ?1?. b0bset p4.0 b0bclr p2.3 ; set p2.3 and p5.5 to be ?0?. b0bclr p5.5 a example: port bit test. b0bts1 p0.0 ; bit test 1 for p0.0 . b0bts0 p2.5 ; bit test 0 for p2.5
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 96 v1.4 11 8-channel analog to digital converter 11.1 overview this analog to digital converter of sn8p2710 has 8-input sources with up to 4096-step resolution to transfer analog signal into 12-bits digital data. the sequence of adc operation is to select input source (ain0 ~ ain7) at first, then set gchs and ads bit to ?1? to start conversion. when the conver sion is complete, the adc circuit will set eoc bit to ?1? and final value output in adb register. a /d converter (adc) db a u ts a a in0/p4.0 a in5/p4.5 a in2/p4.2 a in3/p4.3 a in4/p4.4 a in1/p4.1 a in6/p4.6 a in7/p4.7 a /d converter (adc) a in0/p4.0 a in0/p4.0 a in5/p4.5 a in5/p4.5 a in2/p4.2 a in2/p4.2 a in3/p4.3 a in3/p4.3 a in4/p4.4 a in4/p4.4 a in1/p4.1 a in1/p4.1 a in6/p4.6 a in6/p4.6 a in7/p4.7 a in7/p4.7 figure 11-1. ad converter function diagram ? note: the analog input level must be between the avrefh and avrefl. ? note: the avrefh level must be between the avdd and vss + 2.0v. ? note: adc programming notice: set adc input pin i/o direction as input mode disable pull-up resistor of adc input pin disable adc before enter power down (sleep) mode to save power consumption. set related bit of p4con register to avoid extra power consumption in power down mode. delay 100us after enable adc (set adenb = ?1?) to wait adc circuit ready for conversion. disable adc (set adenb = ?0?) before enter sleep mode to save power consumption.
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 97 v1.4 11.2 adm register adm initial value = 0000 x000 0b1h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 adm adenb ads eoc gchs - chs2 chs1 chs0 r/w r/w r/w r/ w - r/w r/w r/w bit 7 adenb: adc control bit. 0 = disable adc function 1 = enable adc function bit 6 ads: adc start bit. 0 = adc convert stop 1 = adc convert starting bit 5 eoc: adc status bit. 0 = progressing 1 = end of converting and reset ads bit bit 4 gchs: global channel select bit. 0 = disable ain channel 1 = enable ain channel bit [2:0] chs [2:0]: adc input channels select bit. 000 = ain0, 001 = ain1, 010 = ain2, 011 = ain3 100 = ain4, 101 = ain5, 110 = ain6, 111 = ain7 11.3 adr registers adr initial value = x00x 0000 0b3h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 adr adcks1 adcks0 adb3 adb2 adb1 adb0 r/w r/w r r r r bit 6,4 adcks [1:0]: adc?s clock source select bit. adcks1 adcks0 adc clock source 0 0 fcpu/16 0 1 fcpu/8 1 0 fcpu 1 1 fcpu/2 bit [3:0] adb [3:0]: adc data buffer. adb11~adb0 bits for 12-bit adc 11.4 adb registers adb initial value = xxxx xxxx 0b2h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 adb adb11 adb10 adb9 adb8 adb7 adb6 adb5 adb4 r r r r r r r r adb is adc data buffer to store ad converter result. the ad b is only 8-bit register including bit 4~bit11 adc data. to combine adb register and the low-nibble of adr will get full 12-bit adc data buffer. the adc buffer is a read-only register. the adc data is stor ed in adb and adr registers. ? note: adb [0:11] value is unknown when power on.
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 98 v1.4 the ain?s input voltage v.s. adb?s output data ain n adb1 1 adb10 adb9 adb8 adb7 adb6 ad b5 adb4 adb3 ad b2 adb1 adb0 0/4095*avrefh 0 0 0 0 0 0 0 0 0 0 0 0 1/4095*avrefh 0 0 0 0 0 0 0 0 0 0 0 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4094/4095*avrefh 1 1 1 1 1 1 1 1 1 1 1 0 4095/4095*avrefh 1 1 1 1 1 1 1 1 1 1 1 1 for different applications, users maybe need more than 8-bit resolution but less than 12-bit adc converter. to process the adb and adr data can make the job well. first, the ad resolution must be set 12-bit mode and then to execute adc converter routine. then delete the lsb of adc data and get the new resolution result. the table is as following. adb adr adc resolution adb11 adb10 adb9 adb8 adb7 adb6 adb5 adb4 adb3 adb2 adb1 adb0 8-bit o o o o o o o o x x x x 9-bit o o o o o o o o o x x x 10-bit o o o o o o o o o o x x 11-bit o o o o o o o o o o o x 12-bit o o o o o o o o o o o o o = selected, x = delete 11.5 p4con registers adb initial value = 0000 0000 0aeh bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 p4con p4con7 p4con6 p4con5 p4con4 p4con3 p4con2 p4con1 p4con0 w w w w w w w w the port 4 is shared with adc input f unction. only one pin of port 4 can be conf igured as adc input in the same time by adm register. the other pins of port 4 are digital i/o pins. connect an analog signal to coms digital input pin, especially the analog signal level is about 1/2 vdd will caus e extra current leakage. in the power down mode, the leakage current will be a big issue. unfortunately, if us ers connect more than one analog input signal to port 4 will encounter above current leakage si tuation. p4con is port4 configuration r egister. write ?1? into p4con [7:0] will configure related port 4 pin as pure analog input pin to avoid current leakage. bit[7:0] p4con [7:0] port4 configuration register. 0 = p4.x can be an analog input (adc input) or digital i/o pins. 1 = p4.x is pure analog input, can?t be a digital i/o pin. note: when port4 [7:0] is general i/o port not adc channel, p4con [7:0] must set to ?0? or the port4 input signal would be isolated
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 99 v1.4 11.6 adc converting time 12-bit adc conversion time = 1/(adc clock / 4 )*16 sec high clock (fosc) = 4mhz fcpu adcks1 adcks0 adc clock adc converting time 0 0 fcpu/16 1/( ( 4mhz / 1 ) / 16 /4 ) x16= 256 us 0 1 fcpu/8 1/( ( 4mhz / 1 ) / 8 /4 ) x16= 128 us 1 0 fcpu 1/( ( 4mhz / 1 ) / 1 /4 ) x16= 16 us fosc/ 1 1 1 fcpu/2 1/( ( 4mhz / 1 ) / 2 /4 ) x16= 32 us 0 0 fcpu/16 1/( ( 4mhz / 2 ) / 16 /4 ) x16= 512 us 0 1 fcpu/8 1/( ( 4mhz / 2 ) / 8 /4 ) x16= 256 us 1 0 fcpu 1/( ( 4mhz / 2 ) / 1 /4 ) x16= 32 us fosc/ 2 1 1 fcpu/2 1/( ( 4mhz / 2 ) / 2 /4 ) x16= 64 us 0 0 fcpu/16 1/( ( 4mhz / 4 ) / 16 /4 ) x16= 1024 us 0 1 fcpu/8 1/( ( 4mhz / 4 ) / 8 /4 ) x16= 512 us 1 0 fcpu 1/( ( 4mhz / 4 ) / 1 /4 ) x16= 64 us fosc/ 4 1 1 fcpu/2 1/( ( 4mhz / 4 ) / 2 /4 ) x16= 128 us 0 0 fcpu/16 1/( ( 4mhz / 8 ) / 16 /4 ) x16= 2048 us 0 1 fcpu/8 1/( ( 4mhz / 8 ) / 8 /4 ) x16= 1024 us 1 0 fcpu 1/( ( 4mhz / 8 ) / 1 /4 ) x16= 128 us fosc/ 8 1 1 fcpu/2 1/( ( 4mhz / 8 ) / 2 /4 ) x16= 256 us ? note: adc function can work in slow mode also. in slow mode, the fcpu = lxosc / 4 (lxosc is internal low rc oscillator). ? note: because the frequency of lxosc (internal low rc oscillator) will vary with different temperature and vdd, so adc converting time will be effected. a example : configure ain0 as 12-bi t adc input and start adc conversion then enter power down mode. adc0: b0bset fadenb ; enable adc circuit call delay100us ; delay 100us to wait adc circuit ready for conversion mov a, #0feh b0mov p4ur, a ; disable p4.0 pull-up resistor b0bclr fp40m ; set p4.0 as input pin mov a, #01h b0mov p4con, a ; set p4.0 as pure analog input mov a, #40h b0mov adr, a ; to set 12-bit adc and adc clock = fosc. mov a,#90h b0mov adm,a ; to enable adc and set ain0 input b0bset fads ; to start conversion wadc0: b0bts1 feoc ; to skip, if end of converting =1 jmp wadc0 ; else, jump to wadc0 b0mov a,adb ; to get ain0 input data bit11 ~ bit4 b0mov adc_buf_hi, a b0mov a,adr ; to get ain0 input data bit3 ~ bit0 and a, 0fh b0mov adc_buf_low, a power_down . . b0bclr fadenb ; disable adc circuit b0bset fcpum0 ; enter sleep mode
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 100 v1.4 11.7 adc circuit avrefh is connected to vdd. avrefh is connected to external ad reference voltage. figure 11-2. the ainx and avrefh circuit of ad converter ? note: the capacitor between ain and gnd is a bypass cap acitor. it is helpful to stable the analog signal. users can omit it. vdd avref ain0/p40 analog signal input 0.1uf mcu vdd avref ain0/p40 analog signal input 0.1uf mcu vdd avref ain0/p40 analog signal input 0.1uf mcu reference voltage input 47uf vdd avref ain0/p40 analog signal input 0.1uf mcu reference voltage input 47uf
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 101 v1.4 12 7-bit digital to analog converter 12.1 overview the d/a converter uses 7-bit structur e to synthesize 128 steps' analog signal with current source output. after daenb bit is set to ?1?, dac circuit will turn to be enabled and the da m register, from bit0 to bit6, will send digital signal to ladder resistors in order to generate analog signal on dao pin. ladder resistors dam register dao output ladder resistors dam register dao output figure 12-1. the da converter block diagram in order to get a proper linear output, a loading resistor r l is usually added between dao and ground. the example shows the result of vdd = 5v, r l =150ohm and vdd = 3v, r l =150ohm. figure 12-2 dao circuit with r l figure 12-3. dac output voltage in vdd=5v and 3v note: ? 1:the d/a converter is not desi g ned for a precise dc volta g e output and is suitable for a simple audio application e.g. tone or melody generation. ? 2:for best linearity performance, the max. loading resistance r l is 150 ohm @5v, 100 ohm @3v vdd=3v vdd=5v
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 102 v1.4 12.2 dam register dam initial value = 0000 0000 0b0h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 dam daenb dab6 dab5 dab4 dab3 dab2 dab1 dab0 r/w r/w r/w r/w r/w r/w r/w r/w bit 7 daenb: digital to analog converter control bit. 0 = disable dac function 1 = enable dac function bit [6:0] dab [6:0]: digital input data. 12.3 d/a converter operation when the daenb = 0, the dao pin is out put floating status. after setting daen b to ?1?, the dao output value is controlled by dab bits. a example: output 1/2 vdd from dao pin. mov a, #00111111b b0mov dam, a ; set dab to a half of the full scale. b0bset fdaenb ; enable d/a function. the dab?s data v.s. dao?s output voltage as following: dab6 dab5 dab4 dab3 dab2 dab1 dab0 dao 0 0 0 0 0 0 0 vss 0 0 0 0 0 0 1 idac 0 0 0 0 0 1 0 2 * idac 0 0 0 0 0 1 1 3 * idac . . . . . . . . . . . . . . . . . . . . . . . . 1 1 1 1 1 1 0 126 * idac 1 1 1 1 1 1 1 127 * idac table 12-1. dab and dao relative table ? note: idac = i fso / (2 7 -1) (i fso : full-scale output current)
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 103 v1.4 13 coding issue 13.1 template code ;******************************************************************************* ; filename : template.asm ; author : sonix ; purpose : template code for sn8p2710 ; revision : v1.0 first issue ;******************************************************************************* ;* (c) copyright 2004, sonix technology co., ltd. ;******************************************************************************* chip sn8p2715 ; select the chip ;------------------------------------------------------------------------------- ; include files ;------------------------------------------------------------------------------- .nolist ; do not list the macro file includestd macro1.h includestd macro2.h includestd macro3.h .list ; enable the listing function ;------------------------------------------------------------------------------- ; constants definition ;------------------------------------------------------------------------------- ; one equ 1 ;------------------------------------------------------------------------------- ; variables definition ;------------------------------------------------------------------------------- .data org 0h ;bank 0 data section start from ram address 0x000 wk00b0 ds 1 ;temporary buffer for main loop iwk00b0 ds 1 ;temporary buffer for isr accbuf ds 1 ;accumulater buffer pflagbuf ds 1 ;pflag buffer org 100h ;bank 1 data section start from ram address 0x100 bufb1 ds 20 ;temporary buffer in bank 1 ;------------------------------------------------------------------------------- ; bit flag definition ;------------------------------------------------------------------------------- wk00b0_0 equ wk00b0.0 ;bit 0 of wk00b0 iwk00b0_1 equ iwk00b0.1 ;bit 1 of iwk00 ;------------------------------------------------------------------------------- ; code section ;------------------------------------------------------------------------------- .code org 0 ;code section start jmp reset ;reset vector
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 104 v1.4 ;address 4 to 7 are reserved org 8 jmp isr ;interrupt vector org 10h ;------------------------------------------------------------------------------- ; program reset section ;------------------------------------------------------------------------------- reset: mov a,#07fh ;initial stack pointer and b0mov stkp,a ;disable global interrupt clr pflag ;pflag = x,x,x,x,x,c,dc,z mov a,#00h ;initial system mode b0mov oscm,a mov a, #0x5a b0mov wdtr, a ;clear watchdog timer call clrram ;clear ram call sysinit ;system initial b0bset fgie ;enable global interrupt ;------------------------------------------------------------------------------- ; main routine ;------------------------------------------------------------------------------- main: mov a, #0x5a ;clear watchdog timer b0mov wdtr, a call mnapp jmp main ;------------------------------------------------------------------------------- ; main application ;------------------------------------------------------------------------------- mnapp: ; put your main program here ret ;----------------------------------- ; jump table routine ;----------------------------------- org 0x0100 ;the jump table should start from the head ;of boundary. b0mov a,wk00b0 and a,#3 add pcl,a jmp jmpsub0 jmp jmpsub1 jmp jmpsub2 ;----------------------------------- jmpsub0: ; subroutine 1 jmp jmpexit jmpsub1:
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 105 v1.4 ; subroutine 2 jmp jmpexit jmpsub2: ; subroutine 3 jmp jmpexit jmpexit: ret ;return main ;------------------------------------------------------------------------------- ; isr (interrupt service routine) ; arguments : ; returns : ; reg change: ;------------------------------------------------------------------------------- isr: ;----------------------------------- ; save acc and system registers ;----------------------------------- b0xch a,accbuf ;b0xch instruction do not change c,z flag b0mov a, pflag b0mov pflagbuf, a ;----------------------------------- ; check which interrupt happen ;----------------------------------- intp00chk: b0bts1 fp00ien jmp inttc0chk ;modify this line for another interrupt b0bts0 fp00irq jmp p00isr ;if necessary, insert another interrupt checking here inttc0chk: b0bts1 ftc0ien jmp isrexit ;suppose tc0 is the last interrupt which you b0bts0 ftc0irq ;want to check jmp tc0isr ;----------------------------------- ; exit interrupt service routine ;----------------------------------- isrexit: b0mov a, pflagbuf ; b0mov pflag, a b0xch a,accbuf ;b0xch instruction do not change c,z flag reti ;exit the interrupt routine ;------------------------------------------------------------------------------- ; int0 interrupt service routine ;------------------------------------------------------------------------------- p00isr: b0bclr fp00irq
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 106 v1.4 ;process p0.0 external interrupt here jmp isrexit ;------------------------------------------------------------------------------- ; tc0 interrupt service routine ;------------------------------------------------------------------------------- tc0isr: b0bclr ftc0irq ;process tc0 timer interrupt here jmp isrexit ;------------------------------------------------------------------------------- ; sysinit ; initialize i/o, timer, interrupt, etc. ;------------------------------------------------------------------------------- sysinit: ret ;------------------------------------------------------------------------------- ; clrram ; use index @yz to clear ram (00h~7fh) ;------------------------------------------------------------------------------- clrram: ; ram bank 0 clr y ;select bank 0 b0mov z,#0x7f ;s et @yz address from 7fh clrram10: clr @yz ;clear @yz content decms z ;z = z ? 1 , skip next if z=0 jmp clrram10 clr @yz ;clear address 0x00 ret ;------------------------------------------------------------------------------- endp
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 107 v1.4 13.2 program check list item description undefined bits all bits those are marked as ?0? (undefined bits ) in system registers should be set ?0? to avoid unpredicted system errors. adc 1. set adc input pin i/o direction as input mode 2. disable pull-up resister of adc input pin 3. disable adc before enter power down (s leep) mode to save power consumption. 4. set related bit of p4con to avoid ex tra power consumption in power down mode 5. delay 100us after enable adc (set adenb = ?1?) to wait adc circuit ready for conversion interrupt do not enable interrupt before initializing ram. non-used i/o non-used i/o ports should be pull-up or pull-down in input mode, or be set as low in output mode to save current consumption. sleep mode enable on-chip pull-up resistors of port 0 to avoid unpredicted wakeup. stack buffer be careful of function call and interrupt serv ice routine operation. don?t let stack buffer overflow or underflow. system initial 1. write 0x7f into stkp register to init ial stack pointer and disable global interrupt 2. clear all ram. 3. initialize all system r egister even unused registers. 4. initialize all i/o pin direction. noisy immunity 1. set the watchdog option as ?alway s on? to protect system crash. 2. enable ?noise filter? code option 3. non-used i/o ports should be set as output low mode 4. constantly refresh important system registers and variables in ram to avoid system crash by a high electrical fast transient noise.
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 108 v1.4 14 instruction set table field mnemonic descr iption c dc z cycle mov a,m a m - - 1 m mov m,a m a - - - 1 o b0mov a,m a m (bnak 0) - - 1 v b0mov m,a m (bank 0) a - - - 1 e mov a,i a i - - - 1 b0mov m,i m i, ?m? only supports 0x80~0x87 regi sters (e.g. pflag,r,y,z?), - - - 1 xch a,m a m - - - 1+n b0xch a,m a m (bank 0), - - - 1+n movc r, a rom [y,z] - - - 2 adc a,m a a + m + c, if occur carry, then c=1, else c=0 1 a adc m,a m a + m + c, if occur carry, then c=1, else c=0 1+n r add a,m a a + m, if occur carry, then c=1, else c=0 1 i add m,a m m + a, if occur carry, then c=1, else c=0 1+n t b0add m,a m (bank 0) m (bank 0) + a, if occur carry, then c=1, else c=0 1+n h add a,i a a + i, if occur carry, then c=1, else c=0 1 m sbc a,m a a - m - /c, if occur borrow, then c=0, else c=1 1 e sbc m,a m a - m - /c, if occur borrow, then c=0, else c=1 1+n t sub a,m a a - m, if occur borrow, then c=0, else c=1 1 i sub m,a m a - m, if occur borrow, then c=0, else c=1 1+n c sub a,i a a - i, if occur borrow, then c=0, else c=1 1 and a,m a a and m - - 1 l and m,a m a and m - - 1+n o and a,i a a and i - - 1 g or a,m a a or m - - 1 i or m,a m a or m - - 1+n c or a,i a a or i - - 1 xor a,m a a xor m - - 1 xor m,a m a xor m - - 1+n xor a,i a a xor i - - 1 swap m a (b3~b0, b7~b4) m(b7~b4, b3~b0) - - - 1 p swapm m m(b3~b0, b7~b4) m(b7~b4, b3~b0) - - - 1+n r rrc m a rrc m - - 1 o rrcm m m rrc m - - 1+n c rlc m a rlc m - - 1 e rlcm m m rlc m - - 1+n s clr m m 0 - - - 1 s bclr m.b m.b 0 - - - 1+n bset m.b m.b 1 - - - 1+n b0bclr m.b m(bank 0).b 0 - - - 1+n b0bset m.b m(bank 0).b 1 - - - 1+n cmprs a,i zf,c a - i, if a = i, then skip next instruction - 1 + s b cmprs a,m zf,c a - m, if a = m, then skip next instruction - 1 + s r incs m a m + 1, if a = 0, then skip next instruction - - - 1 + s a incms m m m + 1, if m = 0, then skip next instruction - - - 1+n+s n decs m a m - 1, if a = 0, then skip next instruction - - - 1 + s c decms m m m - 1, if m = 0, then skip next instruction - - - 1+n+s h b0bts0 m.b if m(bank 0).b = 0, then skip next instruction - - - 1 + s b0bts1 m.b if m(bank 0).b = 1, then skip next instruction - - - 1 + s jmp d pc15/14 rompages1/0, pc13~pc0 d - - - 2 call d stack pc15~pc0, pc15/14 rompages1/0, pc13~pc0 d - - - 2 m ret pc stack - - - 2 i reti pc stack, and to enable global interrupt - - - 2 s nop no operation - - - 1 retlw i pc ? stack, a ? i - - - 2 ? note: 1. the ?m? is memory including system registers and user defined memory. 2. if branch condition is true then ?s = 1?, otherwise ?s = 0?. 3. if ?m? is system registers (80h ~ ffh of bank 0) then ?n? = 0, otherwise ?n? = 1
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 109 v1.4 15 electrical characteristic 15.1 absolute maximum rating (all of the voltages referenced to vss) supply voltage (vdd)????????????????????????????????????? - 0.3v ~ 6.0v input in voltage (vin)???????????????????????????????? ..vss - 0.2v ~ vdd + 0.2v operating ambient temperature (topr) SN8P27142p, SN8P27142s, sn8p27143p, sn8p 27143s, sn8p27143x, sn8p2714k, sn8p2714s, sn8p2715p, sn8p2715s???????.???????????????????????? 0 c ~ + 70 c SN8P27142pd, SN8P27142sd, sn8p27143pd, sn8p27143sd, sn8p27143xd, sn8p2714kd, sn8p2714sd, sn8p2715pd, sn8p 2715sd.?.?????????????..????.?.. ?40 c ~ + 85 c storage ambient temperature (tstor) ???????????????..?????????.??? ?40 c ~ + 125 c 15.2 standard electrical characteristic (all of voltages referenced to vss, vdd = 5.0v, fosc = 4 mhz,fcpu=1mhz, ambient temperature is 25 c unless otherwise note.) parameter sym. description min. typ. max. unit normal mode, vpp = vdd, 25 c 2.4 5.0 5.5 normal mode, vpp = vdd, -40 c~85 c 2.5 5.0 5.5 operating voltage vdd programming mode, vpp = 12.5v 5.0 v ram data retention voltage vdr 1.5 - - v internal por vpor vdd rise rate to ensure internal power-on reset 0.05 - - v/ms vil1 all input ports vss - 0.3vdd v input low voltage vil2 reset pin vss - 0.2vdd v vih1 all input ports 0.7vdd - vdd v input high voltage vih2 reset pin 0.9vdd - vdd v vin = vdd, 25 c - - 2 ua reset pin leakage current ilekg vin = vdd, -40 c~85 c - - 5 ua vin = vss , vdd = 3v 100 200 300 k ? i/o port pull-up resistor rup vin = vss , vdd = 5v 50 100 180 k ? i/o port input leakage current ilekg pull-up resistor disable, vin = vdd - - 2 ua ioh vop = vdd - 0.5v(source) 8 12 - ma port2, port4, port 5 output current iol vop = vss + 0.5v(sink) 8 15 - ma intn trigger pulse width tint0 int0 ~ int1 interrupt request pulse width 2/fcpu - - cycle avrefh input voltage varfh vdd = 5.0v 2v - vdd v ain0 ~ ain7 input voltage vani vdd = 5.0v 0 - varfh v f adclk vdd=5.0v - 8m hz adc clock frequency vdd=3.0v - 5m hz adc conversion cycle time f adcyl vdd=2.4v~5.5v 64 1/f adclk f adsmp vdd=5.0v 125 k/sec adc sampling rate (set fads=1 frequency) vdd=3.0v 80 k/sec differential nonlinearity dnl vdd=5.0v , avrefh=3.2v, f adsmp =7.8k 1 2 16 lsb integral nonlinearity inl vdd=5.0v , avrefh=3.2v, f adsmp =7.8k 2 4 16 lsb no missing code nmc vdd=5.0v , avrefh=3.2v, f adsmp =7.8k 8 10 12 bits adc enable time tast ready to start convert after set adenb = ?1? 100 - - us vdd=5.0v - 0.6* - ma adc current consumption i adc vdd=3.0v - 0.4* - ma vdd=5v, 25 c 8 14 21 ma vdd=3v, 25 c 5 11 18 ma vdd=5v, -40 c~85 c 8 18 27 ma dac full-scale output current i fso vdd=3v, -40 c~85 c 5 15 24 ma vdd=5v - - 150 ? dac loading resistance r l vdd=3v - - 100 ? dac dnl dac dnl dac differential nonlinearity - 1* - lsb dac inl dac inl dac integral nonlinearity - 3* - lsb vdd= 5v 4mhz - 2.5 5 ma supply current (disable adc) idd1 normal mode fcpu = fosc/4 vdd= 3v 4mhz - 1.5 3 ma
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 110 v1.4 vdd= 5v ~ ilrc 32khz - 25 50 ua idd2 slow mode (internal rc mode, stop high clock) vdd= 3v ~ ilrc 16khz - 5 10 ua vdd= 5v, 25 c - 1 2 ua vdd= 3v, 25 c 0.6 1 ua vdd= 5v, -40 c~85 c 10 21 ua idd3 sleep mode (lvd = lvd_l) vdd= 3v, -40 c~85 c - 10 21 ua vdet0 low voltage reset level 1.7 2.0 2.3 v vdet1 low voltage reset/indicator level fcpu=1mhz 2.0 2.4 3 v lvd voltage vdet2 low voltage indicator level fcpu=1mhz 2.7 3.6 4.5 v *these parameters are for design reference, not tested. 15.3 characteristic graphs the graphs in this section are for design guidance, not tested or guaranteed. in some graphs, the data presented are outside specified operating range. this is for informat ion only and devices are guaranteed to operate properly only within the specified range. standby current 0.6 0.8 1.0 1.2 1.4 2.5 3 3.5 4 4.5 5 5.5 vdd(v) ua -40 ~85 slow mode current 0.0 5.0 10.0 15.0 20.0 25.0 30.0 35.0 2.533.544.555.5 vdd(v) ua -40 85 25 operating current (fosc=4mhz fcpu=fosc/4) 0.0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 2.5 3 3.5 4 4.5 5 5.5 vdd(v) ma -40 25 85 pull up resistor (all port) 0.0 50.0 100.0 150.0 200.0 250.0 300.0 350.0 2.5 3 3.5 4 4.5 5 5.5 vdd(v) kohm -40 85 25
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 111 v1.4 vih(port2 port5) 1.8 2.0 2.2 2.4 2.6 2.8 3.0 3.2 -40 0 25 70 85 v 5v 3v vil(port2 port5) 1.2 1.4 1.6 1.8 2.0 2.2 2.4 -40 0 25 70 85 v 5v 3v vih(port4) 1.2 1.4 1.6 1.8 2.0 2.2 2.4 -40 0 25 70 85 v 5v 3v vil(port4) 1.2 1.4 1.6 1.8 2.0 2.2 2.4 -40 0 25 70 85 v 5v 3v driving current (all port) 8.0 9.0 10.0 11.0 12.0 13.0 14.0 15.0 16.0 17.0 18.0 -40 0 25 70 85 ma 5v 3v sinking current (all port) 8.0 9.0 10.0 11.0 12.0 13.0 14.0 15.0 16.0 17.0 18.0 -40 0 25 70 85 ma 5v 3v
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 112 v1.4 fc pu= fos c /1 noise filter disable -40~85 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 4mhz 8mhz 12mhz 16mhz fhos c vdd(v) fc pu= fos c /4 noise filter disable -40~85 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 4mhz 8mhz 12mhz 16mhz fhos c vdd(v) fc pu= fos c /4 noise filter enable -40~85 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 4mhz 8mhz 12mhz 16mhz fhos c vdd(v) fc pu= fos c /1 noise filter disable 0~70 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 4mhz 8mhz 12mhz 16mhz fhos c vdd(v) internal low rc oscillator 0.0 5.0 10.0 15.0 20.0 25.0 30.0 35.0 40.0 45.0 50.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 vdd(v) kh z -40 85 25 external rc oscillator (25 ) 0.0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 2.5 3 3.5 4 4.5 5 5.5 vdd(v) mhz 3.3k 100p 5.1k 100p 10k 100p 3.3k 20p 5.1k 20p
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 113 v1.4 fc pu= fos c /4 noise filter disable 0~70 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 4mhz 8mhz 12mhz 16mhz fhos c vdd(v) fc pu= fos c /4 noise filter enable 0~70 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 4mhz 8mhz 12mhz 16mhz fhos c vdd(v)
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 114 v1.4 16 development tools 16.1 development tool version 16.1.1 ice (in circuit emulation) z sn8ice 2k: full function emulates sn8p2714/sn8p2715 series ? sn8ice2k ice emulation notice a. operation voltage of ice: 3.0v~5.0v. b. recommend maximum emulation speed at 5v: 8 mips (e.g. 16mhz crystal and fcpu = fhosc/2). c. use sn8p2714 / 2715 ev-kit to emulation lvd. ? note: s8kd-2 ice doesn?t support sn8p2714x and sn8p2715 serial emulation. 16.1.2 otp writer z writer 3.0: support sn8p2715/sn8p2714 but no stand-alone mode. z easy writer v1.0: otp programming is controlled by ice wit hout firmware upgrade suffers. please refer easy writer user manual for detailed information. z mp-ez writer v1.0: stand-alone operation to support sn8p2715/sn8p2714 mass production 16.1.3 ide (integrated development environment) sonix 8-bit mcu integrated development environment in clude assembler, ice debugger and otp writer software. z for sn8ice 2k: m2ide v1.07 or later z for writer 3.0, easy writer and mp-easy writer: m2ide v1.07 or later z sn8ide v1.99x doesn?t support sn8p2714x and sn8p2715.
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 115 v1.4 16.2 sn8p2715/sn8p2714 ev-kit 16.2.1 pcb description sonix provides sn8p2715 ev-kit board for ice emulation. the ev-kit provide lvd2.4v/3.6v selection circuit emulation. con1 and jp3 :ice i/o interface. s1 : vd 2.4v and lvd 3.6v trigger control. to emulate lvd 2.4v flag/reset function and lvd 3.6v flag function. switch no. on off note s7 lvd 2.4v active lvd 2.4v inacti ve emulate vdd is lower than 2.4v s8 lvd 3.6v active lvd 3.6v inacti ve emulate vdd is lower than 3.6v
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 116 v1.4 16.3 sn8p2715/14 ev-kit connnect to sn8ice 2k the connection from sn8p2715/14 ev-kit to sn8ice 2k is as following. ? sn8ice2k ice emulation notice a: operation voltage of ice: 3.0v~5.0v. b: recommend maximum emulation speed at 5v: 8 mips(e.g. 16mhz crystal and fcpu = fhosc/2). c: use sn8p2715 ev-kit to emulation lvd. d: remove avrefh/vdd jumper of sn8ice 2k when chip declare as sn8p2715/sn8p2714/sn8p27143 . a vrefh/vdd
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 117 v1.4 16.4 transition board for otp progtramming 16.4.1 sn8p2715/2715 rev. b transition board sn8p2715/2714 rev. b transition board is for sn8p2715/2714 otp programming including p-dip 20 pins and p-dip 18 pins. rev. b transition board and ev-kit is the same board. jp2 : connect to easy writer or mp-e z writer through 20 pins cable. u1 : sn8p2715 p-dip 32 pins socket u2 : sn8p2714 p-dip 28 pins socket 16.4.2 connnect rev. b transition board to easy writer mp-ez write r rev. b transition board
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 118 v1.4 16.5 otp programming pin to transition board mapping 16.5.1 the pin assignment of easy and mp ez writer transition board socket: easy writer jp1/jp2 easy writer jp3 (mapping to 48-pin text tool) vss 2 1 vdd dip1 1 48 dip48 ce 4 3 clk/pgclk dip2 2 47 dip47 oe/shiftdat 6 5 pgm/otpclk dip3 3 46 dip46 d0 8 7 d1 dip4 4 45 dip45 d2 10 9 d3 dip5 5 44 dip44 d4 12 11 d5 dip6 6 43 dip43 d6 14 13 d7 dip7 7 42 dip42 vpp 16 15 vdd dip8 8 41 dip41 rst 18 17 hls dip9 9 40 dip40 alsb/pdb 20 19 - dip10 10 39 dip39 dip11 11 38 dip38 jp1 for mp transition board dip12 12 37 dip38 jp2 for writer v3.0 transition board dip13 13 36 dip36 dip14 14 35 dip35 dip15 15 34 dip34 dip16 16 33 dip33 dip17 17 32 dip32 dip18 18 31 dip31 dip19 19 30 dip30 dip20 20 29 dip29 dip21 21 28 dip28 dip22 22 27 dip27 dip23 23 26 dip26 dip24 24 25 dip25 jp3 for mp transition board 16.5.2 the pin assignment of writer v3.0 transition board socket: gnd 2 1 vdd ce 4 3 clk oe 6 5 pgm d0 8 7 d1 d2 10 9 d3 d4 12 11 d5 d6 14 13 d7 vpp 16 15 vdd rst 18 17 hls 20 19 writer v3.0 jp1 pin assignment
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 119 v1.4 16.5.3 sn8p2710 series programming pin mapping: otp programming pin of sn8p2710 series chip name sn8p2714 sn8p2715 SN8P27142 sn8p27143 easy, mp-ez writer and writer v3.0 otp ic / jp3 pin assignment number pin number pin number pin number pin number pin 1 vdd 25 vdd 30 vdd 12 vdd 13 vdd 2 gnd 15 vss 20 vss 6 vss 5 vss 3 clk 4 p5.0 6 p5.0 17 p5.0 18 p5.0 4 ce - - - - - - - - 5 pgm 8 p2.0 10 p2.0 2 p2.0 1 p2.0 6 oe 3 p5.1 5 p5.1 16 p5.1 17 p5.1 7 d1 - - - - - - - - 8 d0 - - - - - - - - 9 d3 - - - - - - - - 10 d2 - - - - - - - - 11 d5 - - - - - - - - 12 d4 - - - - - - - - 13 d7 - - - - - - - - 14 d6 - - - - - - - - 15 vdd 25 vdd 30 vdd 12 vdd 13 vdd 16 vpp 26 rst 31 rst 13 rst 14 rst 17 hls - - - - - - - - 18 rst - - - - - - - - 19 - - - - - 20 alsb/pdb 9 p2.1 11 p2.1 3 p2.1 2 p2.1
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 120 v1.4 17 marking definition 17.1 introduction there are many different types in sonix 8-bit mcu production line. this note listed the production definition of all 8-bit mcu for order or obtain information. this definition is only for blank otp mcu. 17.2 marking indetification system sn8 x part no. x x x title sonix 8-bit mcu production rom type p=otp material b = pb-free package g = green package temperature range - = 0 ~ 70 d = -40 ~ 85 shipping package w = wafer h = dice p = p-dip k = skinny dip s = sop x = ssop device 27142p 27142s 27143p 27143s 27143x 2714k 2714s 2715p 2715s
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 121 v1.4 17.3 marking example name rom type device package temperature material SN8P27142pdg otp 27142 p-dip -40 ~85 green package sn8p2624sb otp 2624 sop 0 ~70 pb-free package sn8p1907h otp 1907 dice 0 ~70 n/a sn8a1708ax mask 1708a ssop 0 ~70 n/a ? note: industrial level production didn?t support wafer or dice shipping type. 17.4 datecode system there are total 8~9 letters of sonix datecode system. the final four or five char. are for sonix inside use only, and the first 4 indicate the package date including year/m onth/date. the detail information is following: x x x x xxxxx year month 1=january 2=february . . . . 9=september a=october b=november c=december sonix internal use day 1=01 2=02 . . . . 9=09 a=10 b=11 . . . . 03= 2003 04= 2004 05= 2005 06= 2006 . . . .
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 122 v1.4 18 package information 18.1 p-dip18 pin symbols min. nor. max. a - - 0.210 a1 0.015 - - a2 0.125 0.130 0.135 d 0.880 0.900 0.920 e 0.300bsc. e1 0.245 0.250 0.255 l 0.115 0.130 0.150 b 0.335 0.355 0.375 0 7 15 unit : inch
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 123 v1.4 18.2 sop18 pin symbols min. max. a 0.093 0.104 a1 0.004 0.012 d 0.447 0.463 e 0.291 0.299 h 0.394 0.419 l 0.016 0.050 0 8 unit : inch
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 124 v1.4 18.3 p-dip 20 pin
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 125 v1.4 18.4 sop 20 pin
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 126 v1.4 18.5 ssop20 pin dimension (mm) dimension (mil) symbols min, nom. max. min. nom. max. a 1.35 1.60 1.75 53 63 69 a1 0.10 0.15 0.25 4 6 10 a2 - - 1.50 - - 59 b 0.20 0.254 0.30 8 10 12 b1 0.20 0.254 0.28 8 11 11 c 0.18 0.203 0.25 7 8 10 c1 0.18 0.203 0.23 7 8 9 d 8.56 8.66 8.74 337 341 344 e 5.80 6.00 6.20 228 236 244 e1 3.80 3.90 4.00 150 154 157 e 0.635 bsc 25 bsc h 0.25 0.42 0.50 10 17 20 l 0.40 0.635 1.27 16 25 50 l1 1.00 1.05 1.10 39 41 43 zd 1.50 ref 58 ref y - - 0.10 - - 4 0 - 8 0 - 8
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 127 v1.4 18.6 sk-dip28 pin symbols min. nor. max. a - - 0.210 a1 0.015 - - a2 0.114 0.130 0.135 d 1.390 1.390 1.400 e 0.310bsc. e1 0.283 0.288 0.293 l 0.115 0.130 0.150 b 0.330 0.350 0.370 0 7 15 unit : inch
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 128 v1.4 18.7 sop28 pin symbols min. max. a 0.093 0.104 a1 0.004 0.012 d 0.697 0.713 e 0.291 0.299 h 0.394 0.419 l 0.016 0.050 0 8 unit : inch
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 129 v1.4 18.8 p-dip 32 pin 18.9 sop 32 pin
sn8p2714x_2715 8-bit micro-controller build-in 12-bit adc sonix technology co., ltd page 130 v1.4 sonix reserves the right to make change without further notic e to any products herein to im prove reliability, function or design. sonix does not assume any liability arising out of the application or use of any produc t or circuit described herein; neither does it convey any license under its patent rights nor the rights of others. sonix products are not designed, intended, or authorized for us as components in systems intended, for surgical implant into the body, or other applications intended to support or sustain life, or for any other applicati on in which the failure of the sonix product could create a situation where personal injury or death may occur. s hould buyer purchase or use so nix products for any such unintended or unauthorized application. buyer shall indemnify and hold sonix and its o fficers , employees, subsidiaries, affiliates and distributors harmless against all claims, cos t, damages, and expenses, and reasonabl e attorney fees arising out of, directly or indirectly, any claim of personal in jury or death associated with such unintended or unauthorized use even if such claim alleges that sonix was negligent regarding the design or manufacture of the part. main office: address: 9f, no. 8, hsien cheng 5th s t, chupei city, hsinchu, taiwan r.o.c. tel: 886-3-551 0520 fax: 886-3-551 0523 taipei office: address: 15f-2, no. 171, song ted road, taipei, taiwan r.o.c. tel: 886-2-2759 1980 fax: 886-2-2759 8180 hong kong office: address: flat 3 9/f energy plaza 92 gr anville road, tsimshatsui east kowloon. tel: 852-2723 8086 fax: 852-2723 9179 technical support by email: sn8fae@sonix.com.tw


▲Up To Search▲   

 
Price & Availability of SN8P27142

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


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