Part Number Hot Search : 
M4001 5551L MA11FBX C6H7XX HCC40 116004 S5935TFC DO204AL
Product Description
Full Text Search
 

To Download MG64F237 Datasheet File

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


  Datasheet File OCR Text:
  this document information is the intell ectual property of megawin technology. ? megawin technology co., ltd. 2011 all right reserved. qp-7300-03d 1/68 ????? megawin technology co., ltd. MG64F237 data sheet 65c02 mcu with an usb 2.0 low-speed interface version 1.00
this document information is the inte llectual property of megawin technology. ? megawin technology co., ltd. 2013 all right reserved. qp-7300-03d 2/68 MG64F237 datasheet v1.00 list of contents 1 description ..................................................................................................... 4 2 features......................................................................................................... 5 3 block diagram................................................................................................ 6 4 pin description............................................................................................... 7 4.1 pin definition ................................................................................................................. . 7 4.2 pin configuration............................................................................................................ 9 4.2.1 package lqfp48 ................................................................................................... 9 4.2.2 package ssop16................................................................................................. 10 4.2.3 dice ...................................................................................................................... 10 5 6502 function description ........................................................................... 11 5.1 registers ...................................................................................................................... 11 5.1.1 accumulator.......................................................................................................... 11 5.1.2 index register(x,y) .............................................................................................. 11 5.1.3 processor status register.................................................................................... 11 5.1.4 program counter(pc)........................................................................................... 11 5.1.5 stack point(s)....................................................................................................... 11 6 memory mapping ......................................................................................... 12 6.1 sfr mapping ............................................................................................................... 13 6.1.1 sfr table ............................................................................................................ 13 7 configurable i/o ports ................................................................................. 15 7.1 io structure diagram ................................................................................................... 15 7.2 io port register........................................................................................................... 15 8 interrupt ....................................................................................................... 19 8.1 interrupt register.......................................................................................................... 19 8.2 interrupt system ........................................................................................................... 20 9 timers / pwm .............................................................................................. 21 9.1 8-bit timer0 / pwm0 .................................................................................................... 21 9.1.1 timer0 / pwm0 register........................................................................................ 22 9.2 8-bit timer1 / pwm1 .................................................................................................... 23 9.2.1 timer1 / pwm1 register........................................................................................ 24 10 spi serial interface................................................................................. 25 10.1 sfr control register ................................................................................................... 25 11 reset ...................................................................................................... 26 11.1 reset register.............................................................................................................. 26 11.2 watchdog timer reset................................................................................................. 28 12 power...................................................................................................... 29 12.1 regulator...................................................................................................................... 29 12.2 halt mode(idle mode) ................................................................................................ 29 12.3 stop mode(power-down mode)................................................................................. 29 12.4 power control register ................................................................................................ 30 13 system clock.......................................................................................... 32 14 dpm control (ps/2 control) ................................................................... 33 14.1 dpm register ............................................................................................................... 33 15 usb (universal serial bus)..................................................................... 34 15.1 features ....................................................................................................................... 34 15.2 block diagram .............................................................................................................. 34 15.3 special function registers........................................................................................... 34 15.3.1 usb sfr r/w procedure .................................................................................... 35
this document information is the inte llectual property of megawin technology. ? megawin technology co., ltd. 2013 all right reserved. qp-7300-03d 3/68 MG64F237 datasheet v1.00 15.3.2 usb interrupt........................................................................................................ 36 15.3.3 sfr memory mapping.......................................................................................... 36 15.3.4 usb reset event .................................................................................................. 37 15.3.5 sfr description ................................................................................................... 37 16 in application programming (iap) .......................................................... 49 16.1 iap register ................................................................................................................. 49 17 hardware option..................................................................................... 50 18 application circuit ................................................................................... 51 18.1 usb keyboard circuit ................................................................................................... 51 18.2 usb multi media dongle .............................................................................................. 52 19 dfu function description....................................................................... 53 19.1 dfu ap description ..................................................................................................... 53 19.2 dfu firmware library .................................................................................................. 53 19.3 manual force device into dfu mode ............................................................................ 55 20 instruction set......................................................................................... 56 20.1 instruction set summary .............................................................................................. 56 20.2 instruction set table .................................................................................................... 57 20.3 instruction set summary .............................................................................................. 58 20.4 symbol description ...................................................................................................... 59 20.5 arithmetic operations ................................................................................................... 60 20.6 logic operations .......................................................................................................... 61 20.7 data transfer ............................................................................................................... 63 20.8 boolean variable manipulation..................................................................................... 64 20.9 program and machine control ..................................................................................... 65 21 electrical characteristics ........................................................................ 66 21.1 dc characteristics ....................................................................................................... 66 21.2 usb transceiver electrical characteristics .................................................................. 67 22 revision history...................................................................................... 68
this document information is the inte llectual property of megawin technology. ? megawin technology co., ltd. 2013 all right reserved. qp-7300-03d 4/68 MG64F237 datasheet v1.00 1 description the MG64F237 is a 65c02 mcu with an usb 2.0 low-sp eed interface. a ps/2 connection can be established on usb dp & dm pins by user firmware. it will be very suitable for low-cost keyb oard and products like hand- held game, data bank, and i-toy, which need to download/upload data from the pc host.
this document information is the inte llectual property of megawin technology. ? megawin technology co., ltd. 2013 all right reserved. qp-7300-03d 5/68 MG64F237 datasheet v1.00 2 features ? 6502 8-bit cpu core ? 8k bytes mtp rom ? flash write/erase cycle: 100 ? flash data retention: 100 years at 25 ? 256 bytes data sram ? data ram (0100h to 01bfh) and stacks ram (01c0h to 01ffh). ? address 0100h~01bfh and 0000h~00bfh share the same memory block. ? 34+2 programmable gpio ? port 0 shared 1 pin with f osc output (6mhz / 3mhz / 1.5mhz) ? port 1 shared 2 pins with t0cko/pwm0 and t1cko/pwm1. ? port 2 shared with spi interface (3 pins) and icp interface (3 pins) ? port 3 shared with external crystal and external interrupt. ? port 0/1/2/3 support wakeup function. ? port 0/1/2/3/4 led direct sink pins. ? support vddo pin to setup output voltage. ? master mode spi interface ? clock rate : 1.5mhz, 750khz ? msb / lsb of the data byte is transmitted first. ? timer / pwm ? 8-bit auto-reload timer (timer0) support t0cko/pwm0 to p1.1 ? 8-bit auto-reload timer (timer1) support t1cko/pwm1 to p1.2 ? programmable watch-dog timer (wdt) ? programmable system clock (6mhz / 3mhz) ? usb 2.0 low speed device controller ? built-in usb low-speed (1.5mbps) transceiver ? 8-bytes fifo for endpoint 0 control in/out. ? 8-bytes fifo for endpoint 1 interrupt in. ? 8-bytes fifo for endpoint 2 interrupt in/out, default is in. ? supports usb suspend/resume and remote wake-up event. ? software-controlled usb disconnection mechanism. ? dp/dm combine with ps/2 mode (ps2_clk and ps2_data) ? built-in 5v to 3.3v regulator. ? built-in 6mhz1.5% ihrco with temperature -20 ~ 85 . ? low-voltage detect: lvdf (low voltage detect flag): 3.6v5% ? power saving modes ? halt(idle) mode ? stop(power-down) mode ? operating condition: ? operating voltage: 2.7v ~ 5.5v with usb off-line application ? operating voltage: 4.0v ~ 5. 5v with usb on-line application ? operating speed range: dc to 6mhz @vdd>2.7v ? operating ambient temperature: -20 ~ 85 for internal oscillator mode ? operating ambient temperature: -20 ~ 85 for external crystal mode ? package type ? dice : MG64F237h ? lqfp-48 : MG64F237ad48 ? ssop-16 : MG64F237al16
this document information is the inte llectual property of megawin technology. ? megawin technology co., ltd. 2013 all right reserved. qp-7300-03d 6/68 MG64F237 datasheet v1.00 3 block diagram 6502 cpu 1.5% ihrco wdt ldo ram 256 x 8 mtp 8k x 8 timer0 port1 ext. int lvd 3.6v resb p1.0~p1.7 iap control port0 p0.0~p0.7 ps2 control usb control vdd v33 dp / ps2_clk dm / ps2_data timer1 external osc xtal out / p3.6 xtal in / p3.5 fosc out / p0.4 port2 p2.0~p2.7 port3 p3.0~p3.6 port4 p4.0~p4.2 p4.4~p4.5 p3.2 / int0 p3.3 / int1 spi interface t0cko / pwm0 / p1.1 t1cko / pwm1 / p1.2 spi_sclk / p2.5 spi_miso / p2.1 spi_mosi / p2.0 icp_comb / p2.0 icp_sck / p2.5 icp_sda / p2.6 figure 3-1 block diagram
this document information is the inte llectual property of megawin technology. ? megawin technology co., ltd. 2013 all right reserved. qp-7300-03d 7/68 MG64F237 datasheet v1.00 4 pin description 4.1 pin definition table 4-1 pin definition table pin number pin name dice ssop16 lqfp48 type description p45 1 1 b bi-directional i/o, with wakeup function, and sink led directly. p44 44 46 b bi-directional i/o, with wakeup function, and sink led directly. p42 36 38 b bi-directional i/o, with wakeup function, and sink led directly. p41 35 37 b bi-directional i/o, with wakeup function, and sink led directly. p40 34 36 b bi-directional i/o, with wakeup function, and sink led directly. p36 / xtal2 2 2 o / b 6mhz crystal output with high sink current gpio p36. external 6mhz crystal output. p35 / xtal1 3 3 i / b 6mhz crystal input with high sink current gpio p35. external 6mhz crystal input. p34 4 7 4 b bi-directional i/o, with wakeup function, and sink led directly. p33 / int1 5 8 5 b bi-directional i/o, with wakeup function, and sink led directly. external interrupt (int1) p32 / int0 6 9 6 b bi-directional i/o, with wakeup function, and sink led directly. external interrupt (int0) p31 7 7 b bi-directional i/o, with wakeup function, and sink led directly. p30 8 8 b bi-directional i/o, with wakeup function, and sink led directly. p27 9 9 b bi-directional i/o, with wakeup function, and sink led directly. p26 / icp_sda 10 10 10 b bi-directional i/o, with wakeup function, and sink led directly. icp interface, icp_sda. p25 / icp_sck / spi_sclk 11 11 11 b bi-directional i/o, with wakeup function, and sink led directly. icp interface, icp_sck. spi_sclk p24 12 13 b bi-directional i/o, with wakeup function, and sink led directly. p23 13 14 b bi-directional i/o, with wakeup function, and sink led directly. p22 14 15 b bi-directional i/o, with wakeup function, and sink led directly. p21 / spi_miso 15 12 16 b bi-directional i/o, with wakeup function, and sink led directly. spi_miso p20 / icp_comb / spi_mosi 16 13 17 b bi-directional i/o, with wakeup function, and sink led directly. icp interface, icp_comb. spi_mosi p17 17 18 b bi-directional i/o, with wakeup function, and sink led directly. p16 18 19 b bi-directional i/o, with wakeup function, and sink led directly p15 19 20 b bi-directional i/o, with wakeup function, and sink led directly. p14 20 21 b bi-directional i/o, with wakeup function, and sink led directly. p13 21 22 b bi-directional i/o, with wakeup function, and sink led directly. p12 / t1cko / pwm1 22 14 23 b bi-directional i/o, with wakeup function, and sink led directly. timer 1 underflow output. pwm 1 output.
this document information is the inte llectual property of megawin technology. ? megawin technology co., ltd. 2013 all right reserved. qp-7300-03d 8/68 MG64F237 datasheet v1.00 pin number pin name dice ssop16 lqfp48 type description p11 / t0cko / pwm0 23 15 24 b bi-directional i/o, with wakeup function, and sink led directly. timer 0 underflow output. pwm 0 output. p10 24 26 b bi-directional i/o, with wakeup function, and sink led directly. p07 25 27 b bi-directional i/o, with wakeup function, and sink led directly. p06 26 28 b bi-directional i/o, with wakeup function, and sink led directly. p05 27 29 b bi-directional i/o, with wakeup function, and sink led directly. p04 / icko 28 16 30 b bi-directional i/o, with wakeup function, and sink led directly. f osc clock output. p03 29 31 b bi-directional i/o, with wakeup function, and sink led directly. p02 30 32 b bi-directional i/o, with wakeup function, and sink led directly. p01 31 33 b bi-directional i/o, with wakeup function, and sink led directly. p00 32 34 b bi-directional i/o, with wakeup function, and sink led directly. resb 33 1 35 i reset pin, low action, have internal pull high resistor. vsso 37 2 39 g ground for io vss 38 2 40 g ground for others v33 39 3 41 p 3.3v regulator output, a capacitor should be added on this pin. dm / ps2_data 40 4 42 b usb dm(d-) combo with ps/2 data pin. dp / ps2_clk 41 5 43 b usb dp(d+) combo with ps/2 clk pin. vdd5v 42 6 44 p 5v power for others vddo 43 6 45 p power for gpio note: in the ?type? field, ?i? means input only. ?o? means output only. ?b? means bi-direction. ?p? means power, ?g? means ground.
this document information is the inte llectual property of megawin technology. ? megawin technology co., ltd. 2013 all right reserved. qp-7300-03d 9/68 MG64F237 datasheet v1.00 4.2 pin configuration please visit megawin website to download package dimension. http://www.megawin.com.tw/download_grid.asp?bigclassname=package%20dimension 4.2.1 package lqfp48 12 1 2 3 4 5 6 7 8 9 10 11 MG64F237ad48 lqfp48 13 14 15 16 17 18 19 20 21 22 nc p44 vddo vdd5v dp / ps2_clk dm / ps2_data v33 vss vsso p42 p41 resb p00 p01 p02 p03 p04 / icko p05 p06 p07 p10 p40 p23 p22 spi_miso / p21 spi_mosi / icp_comb / p20 p17 p16 p15 p14 p13 pwm1 / t1cko / p12 pwm0 / t0cko / p11 xtal2/p36 xtal1/p35 p34 int1 / p33 int0 / p32 p31 p30 p27 dfu(fw) / icp_sda / p26 spi_sclk / icp_sck / p25 nc 23 24 25 36 35 34 33 32 31 30 29 28 27 26 48 47 46 45 44 43 42 41 40 39 38 37 nc p45 p24 nc figure 4-1 package lqfp48
this document information is the inte llectual property of megawin technology. ? megawin technology co., ltd. 2013 all right reserved. qp-7300-03d 10/68 MG64F237 datasheet v1.00 4.2.2 package ssop16 ssop-16 resb vss (vddio) / v33 ps2_data / dm ps2_clk / dp (vddio) / vdd5v p34 int1 / p33 p04 / icko 1 p11 / t0cko / pwm0 p12 / t1cko / pwm1 p21 / spi_miso p25 / icp_sck / spi_sclk p26 / icp_sda / dfu(fw) p32 / int0 p20 / icp_comb / spi_mosi 2 3 4 5 6 7 89 10 11 12 13 14 15 16 figure 4-2 package ssop16 4.2.3 dice MG64F237 p25 p26 p27 p30 p31 p32 p33 p34 p35 p36 p45 p44 vddo vdd5v dp dm v33 vss vsso p42 p41 p40 resb p00 p01 p02 p03 p04 p05 p06 p07 p10 p11 p12 p13 p14 p15 p16 p17 p20 p21 p22 p23 p24 1 2 44 43 logo figure 4-3 dice
this document information is the inte llectual property of megawin technology. ? megawin technology co., ltd. 2013 all right reserved. qp-7300-03d 11/68 MG64F237 datasheet v1.00 5 6502 function description 5.1 registers a y x p pch pcl 1 s 5.1.1 accumulator the accumulator is a general-purpose 8-bit register, which stores the results of most arithmetic and logic operations. in addition, the accumulator usually contai ns one of two data words used in these operations. 5.1.2 index register(x,y) there are two 8-bit index registers (x and y), which may be used to count program steps or to provide an index value to be used in generating an effective address. wh en executing an instruction, which specifies indexed addressing, the cpu fetches the op code and the base ad dress, and modifies the address by adding the index register to it prior to performing the desired operation. pre- or po st-index of index address is possible. 5.1.3 processor status register the 8-bit processor status register contains seven status flags. some of t he flags are controlled by the program, others may be controlled both the program and the cpu. bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 n v 1 b d i z c n: signed flag, 1 = negative, 0 = positive v: overflow flag, 1 = true, 0 = false b: brk interrupt command, 1 = brk, 0 = irqb d: decimal mode, 1 = true, 0 = false i: irqb disable flag, 1 = disable, 0 = enable z: zero flag, 1 = true, 0 = false c: carry flag, 1 = true, 0 = false 5.1.4 program counter(pc) the 16-bit program counter register provides the addr esses, which step the micro- controller through sequential program instructions. each time the micro-controller fe tch an instruction from program memory, the lower byte of the program counter (pcl) is placed on the low-order 8 bits of the address bus and the higher byte of the program counter (pch) is placed on the high-order 8 bits. the counter is incremented each time an instruction or data is fetched from program memory. 5.1.5 stack point(s) the stack pointer is an 8-bit register, which is used to control the addressing of the variable-length stack. the stack pointer is automatically incremented and decremented under control of the micro-controller to perform stack manipulations under direction of either the program or interrupts (/nm i or /irq). the st ack allows simple implementation of nested subroutines and multiple level inte rrupts. the stack pointer is initialized by the user?s firmware.
this document information is the inte llectual property of megawin technology. ? megawin technology co., ltd. 2013 all right reserved. qp-7300-03d 12/68 MG64F237 datasheet v1.00 6 memory mapping there are 256 bytes sram in MG64F237. they are working ram (0100h to 01bfh) and stacks (01c0h to 01ffh). locations 0100h to 01bfh and the locations 0000h to 00bfh share the same memory block. the address 00c0h to 00ffh are special function registers area. the 8k bytes mtp rom are addressed from e000h to fffbh. the address mapping of MG64F237 is shown as below. figure 6-1 memory map
this document information is the inte llectual property of megawin technology. ? megawin technology co., ltd. 2013 all right reserved. qp-7300-03d 13/68 MG64F237 datasheet v1.00 6.1 sfr mapping the address 00c0h to 00ffh for special function register s (sfr). the sfr is used to control or store the status of i/o, timers, system clock and other peripheral. 6.1.1 sfr table table 6-1 sfr table bit address & symbol symbol description addr bit-7 bit-6 bit-5 bit-4 bit-3 bit-2 bit-1 bit-0 reset value interrupt irq_en interrupt request enable flag 00c0h -- -- p33 p32 tm1 tm0 usb spi xx00 0000b(r/w) irq_sts interrupt request status flag 00c1h -- -- p33 p32 tm1 tm0 usb spi xx00 0000b(r) irq_clr interrupt request clear flag 00c1h -- -- p33 p32 tm1 tm0 -- spi xxxx xxxxb(w) timer 0 / pwm0 timer0 buffer 00c3h t07 t06 t05 t04 t03 t02 t01 t00 1111 1111b(w) tm0 timer0 counter register 00c3h t07 t06 t05 t04 t03 t02 t01 t00 1111 1111b(r) tm0_ctl timer0 control register 00c4h ent0 t0rl -- -- -- t0k2 t0k1 t0k0 00xx x000b(r/w) timer 1 / pwm1 timer1 buffer 00c5h t17 t16 t15 t14 t13 t12 t11 t10 1111 1111b(w) tm1 timer1 counter register 00c5h t17 t16 t15 t14 t13 t12 t11 t10 1111 1111b(r) tm1_ctl timer1 control register 00c6h ent1 t1rl -- -- -- t1k2 t1k1 t1k0 00xx x000b(r/w) power & clock pwr_ctl power control register 00c8h -- icko1 icko0 cks0 enps2 enusb stop halt x000 0000b(w) reset rst_trg reset trigger source register 00c9h pof exrf swrf wrf -- -- lvdf -- xxxx xxxxb(r/w) -- usbr -- -- -- p4rst 0 -- x0xx x00xb(r) rst_ctl reset control register 00cah swr usbr -- -- -- p4rst 0 -- x0xx x00xb(w) watch dog reset -- -- -- -- -- -- ps1 ps0 xxxx xx00b(r) wdt_st wdt setup register 00cdh clr -- -- -- -- -- ps1 ps0 xxxx xxxxb(w) i/o port control wkps wakeup port source register 00d0h p33r p32r wkp3 wkp2 wkp1 wkp0 pr41 pr40 0000 0011b (r/w) pr_en1 pull-up resistor enable register (50k ) 00d1h pr31 pr30 pr21 pr20 pr11 pr10 pr01 pr00 1111 1111b (r/w) pr_en2 pull-up resistor enable register (3m ) 00d2h -- -- prm21 prm20 prm11 prm10 prm01 prm00 xx00 0000b(r/w) mfr port multi-function control register 00d8h -- -- -- -- t1m1 t1m0 t0m1 t0m0 000x 0000b(r/w) i/o port data port0 output buffer 00d3h p07 p06 p05 p04 p03 p02 p01 p00 1111 1111b(w) p0 port0 input pad 00d3h p07 p06 p05 p04 p03 p02 p01 p00 xxxx xxxxb(r) port1 output buffer 00d4h p17 p16 p15 p14 p13 p12 p11 p10 1111 1111b(w) p1 port1 input pad 00d4h p17 p16 p15 p14 p13 p12 p11 p10 xxxx xxxxb(r) p2 port2 output buffer 00d5h p27 p26 p25 p24 p23 p22 p21 p20 1111 1111b(w)
this document information is the inte llectual property of megawin technology. ? megawin technology co., ltd. 2013 all right reserved. qp-7300-03d 14/68 MG64F237 datasheet v1.00 bit address & symbol symbol description addr bit-7 bit-6 bit-5 bit-4 bit-3 bit-2 bit-1 bit-0 reset value port2 input pad 00d5h p27 p26 p25 p24 p23 p22 p21 p20 xxxx xxxxb(r) port3 output buffer 00d6h -- p36 p35 p34 p33 p32 p31 p30 x111 111b(w) p3 port3 input pad 00d6h -- p36 p35 p34 p33 p32 p31 p30 xxxx xxxxb(r) port4 output buffer 00d7h -- -- p45 p44 -- p42 p 41 p40 xx11 x111b(w) p4 port4 input pad 00d7h -- -- p45 p44 -- p42 p41 p40 xxxx xxxxb(r) usb usb_ctl usb control register 00d9h -- -- -- -- -- -- uwt urd xxxx xx00b(r/w) usb_addr usb sfr address register 00dah -- -- ua5 ua4 ua3 ua2 ua1 ua0 xx00 0000b(w) usb_di usb sfr data input register 00dbh udi7 udi6 udi5 udi4 udi3 udi2 udi1 udi0 xxxx xxxxb(w) usb_do usb sfr data output register 00dbh udo7 udo6 udo5 udo4 udo3 udo2 udo1 udo0 xxxx xxxxb(r) dpm (ps/2) dpmo dp/dm output data buffer register 00ddh -- -- -- -- -- -- dpo dmo xxxx xx00(w) dpmi dp/dm input pad 00ddh -- -- -- -- -- -- dpi dmi xxxx xx00(r) protect write pwpr protect write pattern register 00dfh pr7 pr6 pr5 pr4 pr3 pr2 pr1 pr0 xxxx xxxxb(w) in application programming (iap) iap_pr iap write protect register 00e0h ipr7 ipr6 ipr5 ipr4 ipr3 ip r2 ipr1 ipr0 xxxx xxxxb(w) spi interface spictl serial interface control register 00e7h spien sclk dord opd -- -- -- -- 0000 xxxxb(r/w) sidat : spi_mosi 00e8h (msb) (lsb) 0000 0000b(w) spidat sidat : spi_miso 00e8h (msb) (lsb) 0000 0000b(r) note: pwpr will protect addr ess from 00c8 h ~ 00cfh.
this document information is the inte llectual property of megawin technology. ? megawin technology co., ltd. 2013 all right reserved. qp-7300-03d 15/68 MG64F237 datasheet v1.00 7 configurable i/o ports this chip has 5 io ports, port0~po rt4(p0[7:0], p1[7:0], p2[7 :0], p3[6:0], p4[5,4], p4[2:0], p35 and p36 shared with xtal_in/out), total 34 + 2 programmable io and user can select enable/disable internal pull-up resistor. user should be careful on setting pin as input with no pull high resistor since this setting has potential to cause leakage. user can set different voltage to gpio by vddo pin. the io structure is illustrated as the following figure. 7.1 io structure diagram figure 7-1 gpio diagram 7.2 io port register firmware can read px(x=0~4) to get the data on each pi n and write px(x=0~4) to out put the data on each pin. when p32 and p33 are set as input pins, they are external interrupt sources. a falling/rising edge which setup by p33r and p32r bits in wkps register at these two pins will set corresponding ir q_sts bits to 1, and their interrupt subroutines will be executed if corresponding irq_en bits are set. note : p04 is shared with f osc clock output. note : p11 is multi-function with timer 0 underflow / pwm0 output. note : p12 is multi-function with timer 1 underflow / pwm1 output. note : p20 / p21 / p25 are shared with spi interface. note : p32 and p33 are external interrupt sources. note : p35 and p36 are shared with xtal_in/ou t function if enrco = 0 (hardware option). note : p40~p42, p44, p45 are led io. p0(port 0 input/output register) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 r w default 00d3h p0 output buffer p07 p06 p05 p04 p03 p02 p01 p00 ? 1111 1111b 00d3h p0 input pad p07 p06 p05 p04 p03 p02 p01 p00 ? xxxx xxxxb bit[7:0] : p0[7:0] -- port 0 input/output data. p1(port 1 input/output register) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 r w default 00d4h p1 output buffer p17 p16 p15 p14 p13 p12 p11 p10 ? 1111 1111b 00d4h p1 input pad p17 p16 p15 p14 p13 p12 p11 p10 ? xxxx xxxxb bit[7:0] : p1[7:0] -- port 1 input/output data.
this document information is the inte llectual property of megawin technology. ? megawin technology co., ltd. 2013 all right reserved. qp-7300-03d 16/68 MG64F237 datasheet v1.00 p2(port 2 input/output buffer register) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 r w default 00d5h p2 output buffer p27 p26 p25 p24 p23 p22 p21 p20 ? 1111 1111b 00d5h p2 input pad p27 p26 p25 p24 p23 p22 p21 p20 ? xxxx xxxxb bit[7:0] : p2[7:0] -- port 2 input/output data. p3 (port 3 input/output register) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 r w default 00d6h p3 output buffer -- p36 p35 p34 p33 p32 p31 p30 ? x111 1111b 00d6h p3 input pad -- p36 p35 p34 p33 p32 p31 p30 ? xxxx xxxxb bit7 : reserved bit[6:0] : p3[6:0] -- port 3 input/output data. p4 (port 4 input/output register) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 r w default 00d7h p4 output buffer -- -- p45 p44 -- p42 p41 p40 ? xx11 x111b 00d7h p4 input pad -- -- p45 p44 -- p42 p41 p40 ? xxxx xxxxb bit7 and bit6 : reserved bit[5:4] : p4[5:4] -- p4.5 and p4.4 input/output data. bit3 : reserved bit[2:0] : p4[2:0] -- p4.2, p4.1 and p4.0 input/output data. note : reset source is selected by p4rst setting. pr_en1(pull-up resistor enable register) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 r w default 00d1h pr_en1 pr31 pr30 pr 21 pr20 pr11 pr10 pr01 pr00 ? ? 1111 1111b bit[7:0] : pr_en1[7:0] -- 50k pull-up resistor control register. 0: disable. 1: enable. (default) pr31: p34~p37 50k pull-up resistor enable bit. pr30: p30~p33 50k pull-up resistor enable bit. pr21: p24~p27 50k pull-up resistor enable bit. pr20: p20~p23 50k pull-up resistor enable bit. pr11: p14~p17 50k pull-up resistor enable bit. pr10: p10~p13 50k pull-up resistor enable bit. pr01: p04~p07 50k pull-up resistor enable bit. pr00: p00~p03 50k pull-up resistor enable bit. note :the pull-up resistor is enable in default. pr_en2(pull-up resistor enable register) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 r w default 00d2h pr_en2 -- -- prm21 prm20 prm11 prm10 prm01 prm00 ? ? xx00 0000b bit7 and bit6 : reserved bit[5:0] : pr_en2[5:0] -- 3m pull-up resistor control register. 0: disable.(default) 1: enable. prm21: p2[4:7] 3m pull-up resistor enable bit. prm20: p2[0:3] 3m pull-up resistor enable bit. prm11: p1[4:7] 3m pull-up resistor enable bit. prm10: p1[0:3] 3m pull-up resistor enable bit. prm01: p0[4:7] 3m pull-up resistor enable bit. prm00: p0[0:3] 3m pull-up resistor enable bit.
this document information is the inte llectual property of megawin technology. ? megawin technology co., ltd. 2013 all right reserved. qp-7300-03d 17/68 MG64F237 datasheet v1.00 mfr(multi function control register) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 r w default 00d8h mfr -- -- -- -- t1m1 t1m0 t0m1 t0m0 ? ? 000x 0000b bit[7: 4] : reserved. bit [3:2] : t1m[1:0] -- timer1 / pwm1 output function. t1m1 t1m0 p1.2 function 0 0 normal gpio (default) 0 1 timer1 under flow toggle p1.2 (t1cko) 1 0 pwm1 output to p1.2 1 1 reserved bit [1:0] : t0m[1:0] -- timer0 / pwm0 output function. t0m1 t0m0 p1.1 function 0 0 normal gpio (default) 0 1 timer0 under flow toggle p1.1 (t0cko) 1 0 pwm0 output to p1.1 1 1 reserved
this document information is the inte llectual property of megawin technology. ? megawin technology co., ltd. 2013 all right reserved. qp-7300-03d 18/68 MG64F237 datasheet v1.00 wkps(wakeup port select register) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 r w default 00d0h wkps p33r p32r wkp3 wkp2 wkp1 wkp0 pr41 pr40 ? ? 0000 0011b bit7: p33r -- p33 rising edge interrupt/wakeup. 0: falling edge wakeup/interrupt (default). 1: rising edge wakeup/interrupt. bit6: p32r -- p32 rising edge interrupt/wakeup. 0: falling edge wakeup/interrupt (default). 1: rising edge wakeup/interrupt. bit[5:2] : wkp[3:0] -- wakeup port enable. 0: disable. (default) 1: enable. wkp3: port 3 low-level wakeup enable. wkp2: port 2 low-level wakeup enable. wkp1: port 1 low-level wakeup enable. wkp0: port 0 low-level wakeup enable. p32 p33 wkp3 irq_en p32 , p33 p30, p31, p34~p36 (low-level) p32r=0 (falling edge) p32r=1 (rising edge) p32r=0 (falling edge) p32r=1 (rising edge) 0 0 , 0 no wakeup no wakeup no wakeup no wakeup no wakeup 0 0 , 1 no wakeup no wakeup no wakeup wakeup with interrupt wakeup with interrupt 0 1 , 0 no wakeup wakeup with interrupt wakeup with interrupt no wakeup no wakeup 0 1 , 1 no wakeup wakeup with interrupt wakeup with interrupt wakeup with interrupt wakeup with interrupt 1 0 , 0 wakeup no interrupt wakeup no interrupt wakeup no interrupt wakeup no interrupt wakeup no interrupt 1 0 , 1 wakeup no interrupt wakeup no interrupt wakeup no interrupt wakeup with interrupt wakeup with interrupt 1 1 , 0 wakeup no interrupt wakeup with interrupt wakeup with interrupt wakeup no interrupt wakeup no interrupt 1 1 , 1 wakeup no interrupt wakeup with interrupt wakeup with interrupt wakeup with interrupt wakeup with interrupt blue color: low-level trigger green color: by p32r/p33r setting bit1: pr41 -- p44~p45 50k pull-up resistor enable bit. 0: disable. 1: enable. (default) bit0: pr40 -- p40~p42 50k pull-up resistor enable bit. 0: disable. 1: enable. (default) note : the pr40 and pr41 pull-up resistor is enable in default. reset source is selected by p4rst setting.
this document information is the inte llectual property of megawin technology. ? megawin technology co., ltd. 2013 all right reserved. qp-7300-03d 19/68 MG64F237 datasheet v1.00 8 interrupt there are 1 interrupt sources provided in this chip. the flag irq_en and irq_sts are used to control the interrupts. when any flag in irq_sts register is set to ?1? by hardware and the corresponding bits of flag irq_en has been set by firmware, an interrupt is generated. when an interrupt occurs, all of the interrupts are inhibited until the cli or sta irq_en, #i instruction is invoked. executing the sei instruction can also disable the interrupts. vector address item priority properties description fffch, fffdh reset 1 ext. initial reset fffeh, ffffh int 2 int. interrupt vector note : the reset interrupt include: exte rnal reset, lvr, por, wdt, swr, iar. 8.1 interrupt register irq_en (interrupt request enable flag) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 r w default 00c0h irq_en -- -- p33 p32 tm1 tm0 usb spi ? ? xx00 0000b bit7 and bit6 : reserved program can enable or disable the ability of triggering irq through this register. 0: disable (default ?0? at initialization) 1: enable bit5 : p33 -- enable p3.3 falling/rising edge interrupt. bit4 : p32 -- enable p3.2 falling/rising edge interrupt bit3 : tm1 -- enable timer1 interrupt. bit2 : tm0 -- enable timer0 interrupt. bit1 : usb -- enable usb interrupt. bit0 : spi -- enable spi interrupt. irq_sts (interrupt request status flag) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 r w default 00c1h irq_sts -- -- p33 p32 tm1 tm0 usb spi ? xx00 0000b 00c1h irq_clr -- -- p33 p32 tm1 tm0 -- spi ? xxxx xxxxb bit7 and bit6 : reserved when irq occurs, program can read this register to know which source triggering irq. firmware can clear the interrupt event by writing ?1? into the corresponding bit. usb interrupt flag is included in usb sfr. 0: default value 1: interrupt event trigger set by hardware. firmware write ?1? to clear this bit. bit5 : p33 -- p33 falling/rising edge occurs. bit4 : p32 -- p32 falling/rising edge occurs. bit3 : tm1 -- timer1 underflow. bit2 : tm0 -- timer0 underflow. bit1 : usb -- usb finished rx or tx data. bit0 : spi -- spi finished rx and tx data.
this document information is the inte llectual property of megawin technology. ? megawin technology co., ltd. 2013 all right reserved. qp-7300-03d 20/68 MG64F237 datasheet v1.00 8.2 interrupt system interrupt process logic irq_en.3 interrupt vector generator logic sta irq_en, #i enable irq_sts.3 extr, por, wdtr, iar, swr sta irq_clr, #i sei instruction disable timer1 underflow signal timer0 underflow signal irq_en.2 s r q s r q irq_sts.2 irq_sts.5 irq_en.5 cli instruction fffeh, ffffh p3.3 s r q s r q irq_sts.4 p3.2 irq_en.4 usb irq_en.1 s r q irq_sts.1 extr, por, wdtr, iar, swr spi irq_en.0 s r q irq_sts.0 figure 8-1 interrupt diagram
this document information is the inte llectual property of megawin technology. ? megawin technology co., ltd. 2013 all right reserved. qp-7300-03d 21/68 MG64F237 datasheet v1.00 9 timers / pwm there are two 8-bit timers on this chip. 9.1 8-bit timer0 / pwm0 timer 0 is a 8-bit counter. it can be a programmable down-count counter. when timer 0 is under user?s firmware control, it will pre-load value to counter at the rising edge of tm0_ctl.ent0 and its underflow frequency of timer 0 can be calculated with the following equation: ?? 10 0 _0 ? ? tm f f cktm uvtm for example: if ftm0_uv = f osc /32 = 6mhz/32 = 187.5khz tm0 f tm0_uv frequency 00h invalid 01h 93.75 khz 02h 62.5 khz ? ? ffh 732.42 hz writing data to the tm0 would write data to the reload bu ffer of the timer 0. reading data from the tm0 would read the run-time value from the counter. figure 9-1 timer0 / pwm0 structure ? timer mode figure 9-2 timer0 / pwm0 structure ? pwm mode
this document information is the inte llectual property of megawin technology. ? megawin technology co., ltd. 2013 all right reserved. qp-7300-03d 22/68 MG64F237 datasheet v1.00 9.1.1 timer0 / pwm0 register tm0(timer 0 count register) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 r w default 00c3h tm0 / pwm0 t07 t06 t05 t04 t03 t02 t01 t00 ? 1111 1111b 00c3h tm0 counter t07 t06 t05 t04 t03 t02 t01 t00 ? 1111 1111b bit[7:0] :t0[7:0] -- timer 0 count value tm0_ctl(timer 0 control register) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 r w default 00c4h tm0_ctl ent0 t0rl -- -- -- t0k2 t0k1 t0k0 ? ? 00xx x000b bit7 : ent0 -- timer0 / pwm0 clock disable/enable. 0: disable. (default) 1: enable. bit6 : t0rl -- timer0 auto-reload enable/disable. 0: enable. (default) 1: disable. bit[5:3] : reserved bit[2:0] : t0k[2:0] -- timer0 / pwm0 clock source selector. t0k2 t0k1 t0k0 selected tm0 input clock source 0 0 0 f osc / 8 (default) 0 0 1 f osc / 16 0 1 0 f osc / 32 0 1 1 f osc / 64 1 0 0 f osc / 128 1 0 1 f osc / 256 1 1 0 f osc / 512 1 1 1 timer 1 underflow
this document information is the inte llectual property of megawin technology. ? megawin technology co., ltd. 2013 all right reserved. qp-7300-03d 23/68 MG64F237 datasheet v1.00 9.2 8-bit timer1 / pwm1 timer 1 is a 8-bit counter. it can be a programmable down-count counter. when timer 1 is under user?s firmware control, it will pre-load value to counter at the rising edge of tm1_ctl.ent1 and its underflow frequency of timer 1 can be calculated with the following equation: ?? 11 1 _1 ? ? tm f f cktm uvtm for example: if ftm1_uv = f osc /32 = 6mhz/32 = 187.5khz tm1 f tm1_uv frequency 00h invalid 01h 93.75 khz 02h 62.5 khz ? ? ffh 732.42 hz writing data to the tm1 would write data to the reload bu ffer of the timer 1. reading data from the tm1 would read the run-time value from the counter. figure 9-3 timer1 / pwm1 structure ? timer mode figure 9-4 timer1 / pwm1 structure ? pwm mode
this document information is the inte llectual property of megawin technology. ? megawin technology co., ltd. 2013 all right reserved. qp-7300-03d 24/68 MG64F237 datasheet v1.00 9.2.1 timer1 / pwm1 register tm1(timer 1 count register) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 r w default 00c5h tm1 / pwm1 t17 t16 t15 t14 t13 t12 t11 t10 ? 1111 1111b 00c5h tm1 counter t17 t16 t15 t14 t13 t12 t11 t10 ? 1111 1111b bit[7:0] : t1[7:0] -- timer1 count value. tm1_ctl(timer 1 control register) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 r w default 00c6h tm1_ctl ent1 t1rl -- -- -- t1k2 t1k1 t1k0 ? ? 00xx x000b bit7 : ent1 -- timer1 / pwm1 clock disable/enable. 0: disable. (default) 1: enable. bit6 : t1rl -- timer1 auto-reload enable/disable. 0: enable. (default) 1: disable. bit[5:3] : reserved bit[2:0] : t1k[2:0] -- timer1 / pwm1 clock source selector. t1k2 t1k1 t1k0 selected tm0 input clock source 0 0 0 f osc / 1 (default) 0 0 1 f osc / 2 0 1 0 f osc / 4 0 1 1 f osc / 8 1 0 0 f osc / 32 1 0 1 f osc / 128 1 1 0 f osc / 512 1 1 1 f osc / 1024
this document information is the inte llectual property of megawin technology. ? megawin technology co., ltd. 2013 all right reserved. qp-7300-03d 25/68 MG64F237 datasheet v1.00 10 spi serial interface there is one 8-bit spi interface on this chip. shar e interface pin to gpio, spi _sclk(p25), spi_miso(p21), spi_mosi(p20). 10.1 sfr control register spidat (serial data tx/rx buffer) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 r w default 00e8h spidat : spi_mosi (msb) (lsb) ? 0000 0000b 00e8h spidat : spi_miso (msb) (lsb) ? 0000 0000b write data to this sfr will start transfer data to serial output pad. (p20) read data from this sfr will always read data from serial input pad. (p21) spictl(spi serial interface control register) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 r w default 00e7h spictl spien sclk dord opd -- -- -- -- ? ? 0000 xxxxb bit7 : spien ? spi mode enable/disable control register. 0 : disable. (default) 1 : enable. bit6 : sclk -- spi clock select. 0 : 1.5mhz bit rate. (default) 1 : 750khz bit rate. bit5 : dord -- spi data order. 0 : the msb of the data byte is transmitted first.(default) 1 : the lsb of the data byte is transmitted first. bit4 : opd -- spi interface open-drain select. 0 : cmos output for mosi and sclk.(default) 1 : nmos(open-drain) output for mosi and sclk. note : set opd=0 will auto disabl e mosi/miso/sclk internal 50k pull-up resistor. bit[3:0] : reserved
this document information is the inte llectual property of megawin technology. ? megawin technology co., ltd. 2013 all right reserved. qp-7300-03d 26/68 MG64F237 datasheet v1.00 11 reset there are six reset sources for whole chip as list below. ? power-on reset ? external reset ? watch-dog-timer reset ? software reset ? usb macro reset (usbr) figure 11-1 reset source 11.1 reset register rst_trg(reset trigger source register) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 r w default 00c9h rst_trg pof exrf swrf wrf -- -- lvdf -- ? ? xxxx xxxxb note : rst_trg can be write by firmware only when pwpr is equal to ?5ah?. bit7: pof -- power-on reset flag. 0: this bit must be clear by firmware write ?1?. 1: this bit is set if a power-on reset or lvr occurs. bit6: exrf -- external reset flag. 0: this bit must be clear by firmware write ?1?. 1: this bit is set if a external reset occurs. bit5: swrf -- software reset flag. 0: this bit must be clear by firmware write ?1?. 1: this bit is set if a software reset occurs. bit4: wrf -- wdt reset flag. 0: this bit must be clear by firmware write ?1?. 1: this bit is set by hardware if a wdt reset occurs. bit[3:2]: reserved bit1: lvdf -- low voltage detection flag. 0: this bit must be clear by firmware write ?1?. (default) 1: this bit is set by hardware when vdd had drop below the v lvf bit0: reserved rst_ctl(reset control register)
this document information is the inte llectual property of megawin technology. ? megawin technology co., ltd. 2013 all right reserved. qp-7300-03d 27/68 MG64F237 datasheet v1.00 address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 r w default -- usbr -- -- -- p4rst 0 -- ? x0xx x00xb 00cah rst_ctl swr usbr -- -- -- p4rst 0 -- ? x0xx x00xb note : rst_ctl can be write by firmware only when pwpr is equal to ?5ah?. bit7 : swr -- soft-ware reset. 0: no effect 1: firmware write ?1? to trigger a soft-ware reset event to reset chip. bit6 : usbr -- usb reset. 0: firmware write ?0? to finish usb module reset. (default) 1: firmware write ?1? to start reset usb module. bit[5:3] : reserved bit2 : p4rst -- port 4 reset status flag. 0: p4 output buffer will be cleared by por, external reset, software reset, wdt reset, illegal address reset. (default) 1: p4 output buffer will be cleared by por, external reset. bit1 : reserved, software must write ?0? on these bits. bit0 : reserved
this document information is the inte llectual property of megawin technology. ? megawin technology co., ltd. 2013 all right reserved. qp-7300-03d 28/68 MG64F237 datasheet v1.00 11.2 watchdog timer reset wdt_st (wdt setup register) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 r w default -- -- -- -- -- -- ps1 ps0 ? ? xxxx xx00b 00cdh wdt_st clr -- -- -- -- -- -- -- ? xxxx xxxxb note: this sfr is protected by pwpr . bit7 : clr-- wdt clear bit. write ?1? to this bit will clear wdt. write ?0? has no effect. bit[6:2] : reserved. bit[1:0] : ps[1:0] -- the wdt period selector. 00: about 21.845ms (default) 01: about 43.690ms 10: about 87.380ms 11: about 174.762ms
this document information is the inte llectual property of megawin technology. ? megawin technology co., ltd. 2013 all right reserved. qp-7300-03d 29/68 MG64F237 datasheet v1.00 12 power 12.1 regulator there is a built-in 5v to 3.3v regulat or to supply usb transceiver power. 12.2 halt mode(idle mode) setting the halt bit in pwr_ctl enters idle mode. idle mode halts the internal cpu clock. the cpu state is preserved in its entirety, including the ram, stack pointer, program counter, program status word, and accumulator. the uc can be awakened from halt mode by the following ways: ? interrupts (usb, timer0, timer1, int0, int1) assigned in irq_en. ? io wakeup assigned in wkps register with low-level. ? wdt reset ? external reset 12.3 stop mode(power-down mode) setting the stop bit in pwr_ctl register enters stop (power-down) mode. stop mode stops the oscillator circuit to minimize power consumption. the uc c an be awakened from stop mode by the following ways: ? interrupts (usb, int0, in t1) assigned in irq_en. ? io wakeup assigned in wkps register with low-level. ? external reset figure 12-1 stop mode wakeup source
this document information is the inte llectual property of megawin technology. ? megawin technology co., ltd. 2013 all right reserved. qp-7300-03d 30/68 MG64F237 datasheet v1.00 12.4 power control register program can switch the normal operation mode to the power-saving mode for saving power consumption through the following register. pwr_ctl(power control register) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 r w default 00c8h pwr_ctl -- icko1 icko0 cks0 enps2 enusb stop halt ? x000 0000b note : pwr_ctl can be write by firmware only when pwpr is equal to ?5ah?. bit7 : reserved bit[6:5] : icko[1:0] -- internal clock output icko1 icko0 clock output to p04 0 0 disable (default) 0 1 output f osc (6mhz) 1 0 output f osc /2 (3mhz) 1 1 output f osc /4 (1.5mhz) bit4 : cks0 -- f cpu clock divider selector. 0: f cpu = f osc (default). 1: f cpu = f osc /2 bit3 : enps2 -- enable ps/2 0: disable clock of ps/2 module. (default) 1: enable clock of ps/2 module. bit2 : enusb -- enable usb clock 0: disable clock of usb module. (default) 1: enable clock of usb module. table 12-1 usb/ps2 control table enps2 enusb fse0(in usb sfr) dm/dp 1 x x ps2 mode 0 1 1 force se0 0 1 0 usb mode 0 0 x reserved bit1 : stop -- chip will into stop mode (power-down mode) 0: enable osc (default) 1: disable osc bit0 : halt -- fcpu off-line control bit. 0: fcpu on-line (default) 1: fcpu off-line
this document information is the inte llectual property of megawin technology. ? megawin technology co., ltd. 2013 all right reserved. qp-7300-03d 31/68 MG64F237 datasheet v1.00 pwpr(protect write pattern register) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 r w default 00dfh pwpr pr7 pr6 pr5 pr4 pr3 pr2 pr1 pr0 ? xxxx xxxxb when this byte is wrote by firmware, it would be automa tically cleared by hardware after the ?next write action? of firmware. before setting rst_ctl / wdt_st / pwr_ctl , user must write 0x5a to pwpr . write pwpr is only enable next write instruction. bit[7:0] : pt[7:0] -- protect write pattern. sample code: trigger so ftware reset on mcu. lda #5ah sta pwpr lda #80h sta rst_ctl ;software reset
this document information is the inte llectual property of megawin technology. ? megawin technology co., ltd. 2013 all right reserved. qp-7300-03d 32/68 MG64F237 datasheet v1.00 13 system clock there are two clock source in MG64F237, one is external clock source like resonator /crystal (extosc) and two is build-in 6mhz oscillator (ihrco ). which clock source into f osc is decided by enrco bit. for f cpu clock, it would be divided by 2 if cks0 is set by firmware. after power on, the clock would be de-bounce 16384 clocks (2.736ms). after wakeup, the clock would be de -bounce 16384 clocks (2.736ms). figure 13-1 system clock diagram
this document information is the inte llectual property of megawin technology. ? megawin technology co., ltd. 2013 all right reserved. qp-7300-03d 33/68 MG64F237 datasheet v1.00 14 dpm control (ps/2 control) for usb and ps/2 combo application, the chip provides a way to control dp/ps2_clk and dm/ps2_data pins by user?s firmware. the control focuses on ps/2 interfac e and in system program operations. the dpmi record the dp/ps2_clk and dm/ps2_data pin value respective ly. for ps/2 interface, firmware can judge the dp/ps2_clk and dm/ps2_data pins? connection be usb or ps/2 protocol by reading the value of dpi and dmi. the enps2 and enusb in pwr_ctl register set the controller of dp and dm pins. if they are set to 10, the dp and dm pins are under firmware?s control, thus t he usb function is unavailable. dpmo sets the value of dp/ps2_clk and dm/ps2_data pins when firmware controls the dp/dm pin. 14.1 dpm register {enps2, enusb}: see 12.4 power control register or see 15.3.1 usb sfr r/w procedure dpmo/dpmi (dp/dm output data register) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 r w default dpmo -- -- -- -- -- -- dpo dmo ? xxxx xx00b 00ddh dpmi -- -- -- -- -- -- dpi dmi ? xxxx xx00b note: the dpmo function are only valid in ps2 mode. bit[7:2] : reserved bit1 : dpo -- ps2_clk/dp output data 0: output low (default) 1: pull-high(input mode) bit0 : dmo -- ps2_data/dm output data 0: output low (default) 1: pull-high(input mode) bit1 : dpi -- ps2_clk/dp pin data bit0 : dmi -- ps2_data/dm pin data
this document information is the inte llectual property of megawin technology. ? megawin technology co., ltd. 2013 all right reserved. qp-7300-03d 34/68 MG64F237 datasheet v1.00 15 usb (universal serial bus) 15.1 features ? compliant with usb specification v2.0 ? compliant with usb hid device class specification v1.11. ? usb bus-powered or self-powered option ? supports usb suspend/resume and remote wake-up 15.2 block diagram figure 15-1 usb macro read/write interface 15.3 special function registers the usb block contains sfr of its own as descriptio n in the next page. user can access the usb sfr to implement usb operation with host. before activating the usb operation, the user should enable usb 1.1 transceiver by enusb bit in pwr_ctl sfr.(see 12.4 power control register ) usb_addr (usb sfr address register) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 r w default 00dah usb_addr 0 0 ua5 ua4 ua3 ua2 ua1 ua0 ? xx00 0000b bit[7:6] : reserved. software must write ?0? on these bits. bit[5:0] : ua[6:0] -- usb sfr address. usb_di/usb_do (usb sfr write data register) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 r w default usb_di udi7 udi6 udi5 udi 4 udi3 udi2 udi1 udi0 ? 0000 0000b 00dbh usb_do udo7 udo6 udo5 udo4 udo3 udo2 udo1 udo0 ? 0000 0000b bit[7:0] : udi[7:0] -- usb sfr write data. bit[7:0] : udo[7:0] -- usb sfr read data.
this document information is the inte llectual property of megawin technology. ? megawin technology co., ltd. 2013 all right reserved. qp-7300-03d 35/68 MG64F237 datasheet v1.00 usb_ctl (usb control register) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 r w default -- -- -- -- -- -- uwt urd ? xxxx xx00b 00d9h usb_ctl -- -- -- -- -- -- uwt urd ? xxxx xx00b bit[7:2] : reserved. bit1: uwt -- usb write trigger. write ?1? to start usb sfr write procedure. read ?1? : hardware is in busy usb sfr write procedure. write ?0? : reserve read ?0? : hardware is ready for nex t usb sfr read procedure.(default) bit0: urd -- usb read trigger. write ?1? to start usb sfr read procedure. read ?1? : hardware is in busy usb sfr read procedure. write ?0? : reserve read ?0? : hardware is ready for nex t usb sfr read procedure.(default) 15.3.1 usb sfr r/w procedure usb write procedure: 1. write the address of usb sfr to be accessed into usb_addr 2. write data into usb_di 3. write usb_ctl.uwt=1 4. check usb_ctl.uwt=0 usb read procedure: 1. write the address of usb sfr to be accessed into usb_addr 2. write usb_ctl.urd=1 3. read data from usb_do 4. check usb_ctl.urd=0
this document information is the inte llectual property of megawin technology. ? megawin technology co., ltd. 2013 all right reserved. qp-7300-03d 36/68 MG64F237 datasheet v1.00 15.3.2 usb interrupt upcon uiflg usief urst ursm usus utxd2 utxd1 urxd0 utxd0 se1 txnak2 esie utxie2 utxie1 urxie0 utxie0 txnak1e txnak2e uie usie usb interrupt to uc txnak1 se1e eope eop rxnak0e rxnak0 txnak0e txnak0 erst ersm esus ien ien figure 15-2 usb interrupt source 15.3.3 sfr memory mapping table 15-1 usb sfr mapping table 0/8 1/9 2/a 3/b 4/c 5/d 6/e 7/f xx30h -- epindex txstat txda t txcon -- txcnt -- xx37h xx28h -- -- -- -- -- -- -- -- xx2fh xx20h epcon rxstat rxdat rxcon -- rxcnt -- xx27h xx18h uie -- uiflg -- -- -- -- -- xx1fh xx10h ien -- upcon -- -- -- -- -- xx17h xx08h uaddr -- -- -- -- -- -- -- xx0fh xx00h -- dcon -- -- -- -- -- -- xx07h 0/8 1/9 2/a 3/b 4/c 5/d 6/e 7/f
this document information is the inte llectual property of megawin technology. ? megawin technology co., ltd. 2013 all right reserved. qp-7300-03d 37/68 MG64F237 datasheet v1.00 15.3.4 usb reset event figure 15-3 usb macro reset source 15.3.5 sfr description table 15-2 usb sfr table bit symbol symbol description addr bit-7 bit-6 bit-5 bit-4 bit-3 bit-2 bit-1 bit-0 reset value dcon device control register 01h 0 0 0 puren rpd setno stlden ep2dir 0000 0000b (r/w) uaddr usb address register 08h 0 uadd6 uadd5 uadd4 uadd3 uadd2 uadd1 uadd0 0000 0000b (r/w) upcon usb power control register 12h -- fse0 urwu -- -- urst ursm usus x00x x000b (r/w) ien interrupt enable register 10h -- -- -- -- esie erst ersm esus xxxx 0000b (r/w) uie usb interrupt enable register 18h -- -- -- -- utxie2 urxie2 utxie1 urxie0 utxie0 xxxx 0000b (r/w) uiflg usb interrupt flag register 1ah -- -- -- -- utxd2 urxd2 utxd1 urxd0 utxd0 xxxx 0000b (r/w) usie usb sie event enable register 1bh eope se1e -- -- txnak2e txnak1e rxnak0e txnak0e 00xx 0000b (r/w) usief usb sie event flag 1ch eop se1 -- -- txnak2 txnak1 rxnak0 txnak0 00xx 0000b (r/w) epindex endpoint index register 31h -- -- -- -- -- -- epinx1 epinx0 xxxx xx00b (r/w) note : un-defined bit must be written ?0? when uc program the sfr.
this document information is the inte llectual property of megawin technology. ? megawin technology co., ltd. 2013 all right reserved. qp-7300-03d 38/68 MG64F237 datasheet v1.00 table 15-3 usb sfr table (continue) bit symbol symbol description addr bit-7 bit-6 bit-5 bit-4 bit-3 bit-2 bit-1 bit-0 reset value epindex=0, endpoint 0 input / output control sfr epcon endpoint control register 21h rxstl txstl -- -- -- rxepen -- txepen 00xx 0101b (r/w) rxstat endpoint receive status register 22h rxseq rxsetup stovw edovw rxsovw -- -- -- 0000 0xxxb (r/w) rxdat fifo receive data register 23h rxd7 rxd6 rxd5 rxd4 rxd3 rxd2 rxd1 rxd0 xxxx xxxxb (r/w) rxcon fifo receive control register 24h rxclr -- -- rxffrc -- -- -- -- 0xx0 xxxxb (r/w) rxcnt fifo receive byte count register 26h -- -- -- -- rxbc3 rxbc2 rxbc1 rxbc0 xxxx 0000b (r/w) txstat endpoint transmit status register 32h txseq -- -- -- txsovw -- txerr -- 0xxx 0x0xb (r/w) txdat fifo transmit data register 33h txd7 txd6 txd5 txd4 txd3 txd2 txd1 txd0 xxxx xxxxb (r/w) txcon fifo transmit control register 34h txclr -- -- txffrc -- -- -- -- 0xx0 xxxxb (r/w) epindex=1, endpoint 1 output control sfr epcon endpoint control register 21h -- txstl -- -- -- -- -- txepen x0xx xxx0b (r/w) txstat endpoint transmit status register 32h txseq -- -- -- txsovw -- txerr -- 0xxx 0x0xb (r/w) txdat fifo transmit data register 33h txd7 txd6 txd5 txd4 txd3 txd2 txd1 txd0 xxxx xxxxb (r/w) txcon fifo transmit control register 34h txclr -- -- txffrc -- -- -- -- 0xx0 xxxxb (r/w) epindex=2, dcon.ep2dir=0 : endpoi nt 2 output control sfr epcon endpoint control register 21h -- txstl -- -- -- -- -- txepen x0xx xxx0b (r/w) txstat endpoint transmit status register 32h txseq -- -- -- txsovw -- txerr -- 0xxx 0x0xb (r/w) txdat fifo transmit data register 33h txd7 txd6 txd5 txd4 txd3 txd2 txd1 txd0 xxxx xxxxb (r/w) txcon fifo transmit control register 34h txclr -- -- txffrc -- -- -- -- 0xx0 xxxxb (r/w) epindex=2, dcon.ep2dir=1 : e ndpoint 2 input control sfr epcon endpoint control register 21h rxstl -- -- -- -- rxepen -- -- 0xxx x0xxb (r/w) rxstat endpoint receive status register 22h rxseq -- -- -- rxsovw -- -- -- 0xxx 0xxxb (r/w) rxdat fifo receive data register 23h rxd7 rxd6 rxd5 rxd4 rxd3 rxd2 rxd1 rxd0 xxxx xxxxb (r/w) rxcon fifo receive control register 24h rxclr -- -- rxffrc -- -- -- -- 0xx0 xxxxb (r/w) rxcnt fifo receive byte count register 26h -- -- -- -- rxbc3 rxbc2 rxbc1 rxbc0 xxxx 0000b (r/w) note: un-defined bit must be written ?0? when uc program the sfr.
this document information is the inte llectual property of megawin technology. ? megawin technology co., ltd. 2013 all right reserved. qp-7300-03d 39/68 MG64F237 datasheet v1.00 dcon (device control regi ster, address=01h, sys_rst , read/write) 7 6 5 4 3 2 1 0 0 0 0 puren rpd setno stlden ep2dir w w w r / w r / w r / w r / w r / w bit[7:5] : reserved. software must write ?0? on these bits. bit4 : puren -- enable usb dm 1.5k pull-up resistor 0: disable. (default) 1: enable. bit3 : rpd -- usb dp/dm 500k pull-down resistor. 0: disable. (default) 1: enable. bit2 : setno -- set no-response in ep0 in/out transaction. 1: device will be just only response ack packet with setup transaction but no response with ep0 in/out transaction. 0: device will sent ack/nak/stall packet in in/out transaction. note: this bit will be clear by hw when device receive an setup token. bit1 : stlden -- stall done interrupt enable. 0: disable in/out stall transaction flag setting. 1: in/out stall transaction will set txd0/rxd0 in fiflg. bit0 : ep2dir -- usb endpoint 2 direction select. 0: ep2 will behave as an tx(in) endpoint. def ault is tx(in). only tx sfrs are valid. 1: ep2 will behave as an rx(out) endpoint. only rx sfrs are valid. uaddr (usb address register, address=08h, sys_rst / usb_rst , read/write) 7 6 5 4 3 2 1 0 0 uadd6 uadd5 uadd4 uadd3 uadd2 uadd1 uadd0 w r / w r / w r / w r / w r / w r / w r / w bit7: reserved. software must write ?0? on these bits. bit[6:0] : uadd[6:0] -- usb function address. upcon (usb power control register, address=09h, sys_rst / usb_rst , read/write) 7 6 5 4 3 2 1 0 -- fse0 urwu -- -- urst ursm usus r / w r / w r / w r / w r / w bit7 : reserved. bit6 : fse0 -- force se0 (only reset by sys_rst) 0 : no effect. (default) 1 : force se0 on usb bus bit5: urwu -- usb remote wake-up trigger. 0: end driving remote wake-up signal on usb bus. (default) 1: start driving remote wake-up signal on usb bus. bit[4:3] : reserved.
this document information is the inte llectual property of megawin technology. ? megawin technology co., ltd. 2013 all right reserved. qp-7300-03d 40/68 MG64F237 datasheet v1.00 bit2: urst -- usb reset flag. 0: this bit is cleared when firmware writes '1' to it. 1: set by hardware when the function detects the usb bus reset. bit1: ursm -- usb resume flag. 0: this bit is cleared when firmware writes '1' to it. 1: set by hardware when the function detects the resume state on the usb bus from host. bit0: usus -- usb suspend flag. 0: this bit is cleared when firmware writes '1' to it. 1: set by hardware when the function dete cts the suspend state on the usb bus ien (interrupt enable register, address=10h, sys_rst , read/write) 7 6 5 4 3 2 1 0 -- -- -- -- esie erst ersm esus r / w r / w r / w r / w bit[7:4] : reserved. bit3 : esie -- enable usie event interrupt. 0: disable (default) 1: enable bit2 : erst -- enable upcon.urst interrupt. 0: disable (default) 1: enable bit1 : ersm -- enable upcon.ursm interrupt. 0: disable (default) 1: enable bit0 : esus -- enable upcon.usus interrupt. 0: disable (default) 1: enable uie (usb interrupt enable register, address=18h, sys_rst , read/write) 7 6 5 4 3 2 1 0 -- -- -- -- utxie2 urxie2 utxie1 urxie0 utxie0 r / w r / w r / w r / w bit[7:4] : reserved. bit3: select tx / rx by dcon.ep2dir setting. (default dcon.ep2dir=0) utxie2 -- enable uiflg.utxd2 interrupt. urxie2 -- enable uiflg.urxd2 interrupt. 0: disable. (default) 1: enable. bit2: utxie1 -- enable uiflg.utxd1 interrupt. 0: disable. (default) 1: enable.
this document information is the inte llectual property of megawin technology. ? megawin technology co., ltd. 2013 all right reserved. qp-7300-03d 41/68 MG64F237 datasheet v1.00 bit1: urxie0 -- enable uiflg.urxd0 interrupt. 0: disable. (default) 1: enable. bit0: utxie0-- enable uiflg.utxd0 interrupt. 0: disable. (default) 1: enable. uiflg (usb interrupt flag register, address=1ah, sys_rst / usb_rst , read/write) 7 6 5 4 3 2 1 0 -- -- -- -- utxd2 urxd2 utxd1 urxd0 utxd0 r / w r / w r / w r / w bit[7:4] : reserved. bit3 : select tx / rx by dcon.ep2 dir setting. (default dcon.ep2dir=0) utxd2 -- endpoint 2 transmit done flag. urxd2 -- endpoint 2 receive done flag. 0: this bit is cleared when firmware writes '1' to it. 1: endpoint 2 transmit / receive done flag. bit2 : utxd1 -- endpoint 1 transmit done flag. 0: this bit is cleared when firmware writes '1' to it. 1: endpoint 1 transmit done flag. bit1 : urxd0 -- endpoint 0 receive done flag. 0: this bit is cleared when firmware writes '1' to it. 1: endpoint 0 receive done flag. bit0 : utxd0 -- endpoint 0 transmit done flag. 0: this bit is cleared when firmware writes '1' to it. 1: endpoint 0 transmit done flag. usie (usb sie interrupt enable register, address=1bh, sys_rst / usb_rst = 00xx-0000 , read/write) 7 6 5 4 3 2 1 0 eope se1e -- -- txnak2e txnak1e rxnak0e txnak0e r / w r / w r / w r / w r / w r / w bit7: eope -- enable usief.eop interrupt. 0: disable. (default) 1: enable. bit6 : se1e -- enable usief.se1 interrupt. 0: disable. (default) 1: enable. bit[5:4] : reserved. bit3 : txnak2e -- enable usief.txnak2 interrupt. 0: disable. (default) 1: enable. note : endpoint 2 have tx nak flag not have rx nak flag
this document information is the inte llectual property of megawin technology. ? megawin technology co., ltd. 2013 all right reserved. qp-7300-03d 42/68 MG64F237 datasheet v1.00 bit2 : txnak1e -- enable usief.txnak1 interrupt. 0: disable. (default) 1: enable. bit1 : rxnak0e -- enable usief.rxnak0 interrupt. 0: disable. (default) 1: enable. bit0: txnak0e -- enable usief.txnak0 interrupt. 0: disable. (default) 1: enable. usief (usb sie interrupt flag r egister, address=1ch, sys_rst / usb_rst = 00xx-0000 , read/write) 7 6 5 4 3 2 1 0 eop se1 -- -- txnak2 txnak1 rxnak0 txnak0 r / w r / w r / w r / w r / w r / w bit7 : eop -- eop event flag. 0: this bit is cleared when firmware writes '1' to it. 1: eop event detected flag. bit6 : se1 -- se1 event flag. hardware will set this fl ag to ?1? when dp/dm input voltage is both higher than v ih and remains the same more than 1 usb bit time. 0: this bit is cleared when firmware writes '1' to it. 1: se1 event detected flag. bit[5:4] : reserved. bit3 : txnak2 -- endpoint 2 tx nak event flag. 0: this bit is cleared when firmware writes '1' to it. 1: endpoint 2 tx nak flag. note : endpoint 2 only have tx nak flag, not have rx nak flag bit2 : txnak1 -- endpoint 1 tx nak event flag. 0: this bit is cleared when firmware writes '1' to it. 1: endpoint 1 tx nak flag. bit1 : rxnak0 -- endpoint 0 rx nak event flag. 0: this bit is cleared when firmware writes '1' to it. 1: endpoint 0 rx nak flag. bit0 : txnak0 -- endpoint 0 tx nak event flag. 0: this bit is cleared when firmware writes '1' to it. 1: endpoint 0 tx nak flag. epindex (endpoint index register, address=31h, sys_rst / usb_rst , read/write) 7 6 5 4 3 2 1 0 -- -- -- -- -- -- epinx1 epinx0 r / w r / w bit[7:2] : reserved.
this document information is the inte llectual property of megawin technology. ? megawin technology co., ltd. 2013 all right reserved. qp-7300-03d 43/68 MG64F237 datasheet v1.00 bit[1:0] : epinx[1:0] -- endpoint index bits [2:0] 2?b00: function endpoint 0. (default) 2?b01: function endpoint 1. 2?b10: function endpoint 2. 2?b11: reserved. epcon (endpoint control register, endpoint-indexed , address=21h, sys_rst / usb_rst , read/write) 7 6 5 4 3 2 1 0 rxstl txstl -- -- -- rxepen -- txepen r / w r / w r / w r / w endpoint 0 (epindex=0) bit7 : rxstl -- receive endpoint stall. 0: disable. (default) 1: enable. note : clear this bit only when the host has interv ened through commands sent down endpoint 0. when this bit is set and rxsetup is clear, the receive endpoint will respond with a stall handshake to a valid out token. when this bit is set and rxsetup is set, the receive endpoint will nak. this bit does not affect the reception of set up tokens by a control endpoint. bit6 : txstl -- transmit endpoint stall. 0: disable. (default) 1: enable. note : clear this bit only when the host has interv ened through commands sent down endpoint 0. when this bit is set and rxsetup is cl ear, the transmit endpoint will re spond with a stall handshake to a valid in token. when this bit is set and rxsetup is set, the transmit endpoint will nak. bit[5:3] : reserved. bit2 : rxepen -- receive endpoint enable. 0: disable. 1: enable. (default) bit1 : reserved. bit0 : txepen -- transmit endpoint enable. 0: disable. 1: enable. (default) endpoint 1 (epindex=1) bit7 : reserved. bit6 : txstl -- transmit endpoint stall. 0: disable. (default) 1: enable. bit[5:1] : reserved. bit0 : txepen -- transmit endpoint enable. 0: disable. (default) 1: enable.
this document information is the inte llectual property of megawin technology. ? megawin technology co., ltd. 2013 all right reserved. qp-7300-03d 44/68 MG64F237 datasheet v1.00 endpoint 2 (epindex=2, dcon.ep2dir=0) bit7 : reserved. bit6 : txstl -- transmit endpoint stall. 0: disable. (default) 1: enable. bit[5:1] : reserved. bit0 : txepen -- transmit endpoint enable. 0: disable. (default) 1: enable. endpoint 2 (epindex=2, dcon.ep2dir=1) bit7 : rxstl -- receive endpoint stall. 0: disable. (default) 1: enable. bit[6:3] : reserved. bit2 : rxepen -- receive endpoint enable. 0: disable. (default) 1: enable. bit[1:0] : reserved.
this document information is the inte llectual property of megawin technology. ? megawin technology co., ltd. 2013 all right reserved. qp-7300-03d 45/68 MG64F237 datasheet v1.00 rxstat (endpoint receive status register, endpoint-indexed , address=22h, sys_rst / usb_rst , read/write) 7 6 5 4 3 2 1 0 rxseq rxsetup stovw edovw rxsovw -- -- -- r / w r / w r / w r / w r / w endpoint 0 (epindex=0) bit7 : rxseq -- receive endpoint sequence bit (read, conditional write). the bit will be toggled on completion of an ack handshake in response to an out token. this bit can be written by firmware if the rxovw bit is set when written along with the new rxseq value. bit6 : rxsetup -- received setup transaction. this bit is set by hardware when a valid setup transaction has been received. clear this bit upon detection of a setup tra or the firmware is ready to handle the data/status stage of control transfer. firmware write ?1? to clear this bit. bit5 : stovw -- start overwrite flag (read-only). set by hardware upon receipt of a setup token for the co ntrol endpoint to indicate that the receive fifo is being overwritten with new setup data. this bit is used only for control endpoints. bit4 : edovw -- end overwrite flag. this flag is set by hardware during the ha ndshake phase of a setup transaction. this bit is cleared by firmware write ?1? to read the fifo data. this bit is only used for control endpoints. bit3 : rxsovw -- receive data sequence overwrite bit. write '1' to this bit to allow the value of the rxseq bit to be overwritten. write '0' to this bit has no effect on rxseq. this bit always returns '0' when read. bit[2:0] : reserved. setup data ack rxsetup stovw edovw hw set stovw hw clr stovw hw set edovw hw set rxsetup fw clr edovw rxfifo lock to usb write!!!! in/out nak rxstl txstl in/out stall rxsetup will disable rxstl or txstl function and trigger hw response nak. for endpoint 0, if a transaction begin with in/out token, device will response stall. figure 15-4 usb control trans fer control description
this document information is the inte llectual property of megawin technology. ? megawin technology co., ltd. 2013 all right reserved. qp-7300-03d 46/68 MG64F237 datasheet v1.00 endpoint 2 (epindex=2, dcon.ep2dir=1) bit7: rxseq -- receive endpoint sequen ce bit (read, conditional write). the bit will be toggled on completion of an ack handshake in response to an out token. this bit can be written by firmware if the rxovw bit is set when written along with the new rxseq value. bit[6:4] : reserved. bit3 : rxsovw -- receive data sequence overwrite bit. write '1' to this bit to allow the value of the rxseq bit to be overwritten. write '0' to this bit has no effect on rxseq. this bit always returns '0' when read. bit[2:0] : reserved. rxdat (receive fifo data register, endpoint-indexed , address=23h, sys_rst / usb_rst , read-only) 7 6 5 4 3 2 1 0 rxd7 rxd6 rxd5 rxd4 rxd3 rxd2 rxd1 rxd0 r r r r r r r r bit[7:0] : rxd[7:0] -- receive fifo data. receive fifo data specified by epindex is stored and read from this register. note : rxdat only services the receive endpoints. rxcon (receive fifo control register, endpoint-indexed , address=24h, sys_rst / usb_rst , write-only) 7 6 5 4 3 2 1 0 rxclr -- -- rxffrc -- -- -- -- r / w r / w bit7 : rxclr -- receive fifo clear. set this bit to flush the entire receive fifo. all fifo statuses are reverted to their reset states. hardware clears this bit when the flush operation is completed. note: the rxseq bit in the rxstat register are not affected by this operation. bit[6:5] : reserved. bit4 : rxffrc -- receive fifo read complete. set this bit to release the receive fifo when data set r ead is complete. hardware clears this bit after the fifo release operation has been finished. note: for endpoint 0, rxffrc only wo rks if stovw and edovw are cleared. bit[3:0] : reserved. note: rxcon only services the receive endpoints.
this document information is the inte llectual property of megawin technology. ? megawin technology co., ltd. 2013 all right reserved. qp-7300-03d 47/68 MG64F237 datasheet v1.00 rxcnt (receive fifo byte count register, endpoint-indexed , address=26h, sys_rst / usb_rst , read-only) 7 6 5 4 3 2 1 0 -- -- -- -- rxbc3 rxbc2 rxbc1 rxbc0 r r r r bit[7:4] : reserved. bit[3:0] : rxbc[3:0] -- receive byte count. store the byte count for the data packet receiv ed in the receive fifo specified by epindex. note : rxcnt only services the receive endpoints. txstat (endpoint transmit status register, endpoint-indexed , address=32h, sys_rst / usb_rst , read/write) 7 6 5 4 3 2 1 0 txseq -- -- -- txsovw -- txerr -- r / w r / w r / w bit7 : txseq -- transmit endpoint sequence bit (read, conditional write). the bit will be transmitted in the next pid and toggled on a valid ack handshake of an in transaction. this bit can be written by firmware if the txovw bit is set when written along with the new txseq value. bit[6:4] : reserved. bit3 : txsovw -- transmit data sequence overwrite bit. write '1' to this bit to allow the value of the txseq bit to be overwritten. writing a '0' to this bit has no effect on txseq. this bit always returns '0' when read. note: the sie will handle all sequence bit tracking. this bit should be used only when initializing a new configuration or interface. bit2 : reserved. bit1: txerr -- transmit data timeout error flag. only for ep0, ep1 and ep2 tx function. write ?1? to clear it. bit0 : reserved. note: txstat only services the transmit endpoints. txdat (transmit fifo data register, endpoint-indexed , address=33h, sys_rst / usb_rst , write-only) 7 6 5 4 3 2 1 0 txd7 txd6 txd5 txd4 txd3 txd2 txd1 txd0 w w w w w w w w bit[7:0] : txd[7:0] -- transmit fifo data. data to be transmitted in the fifo specified by epindex is written to this register. note : txdat only services the transmit endpoints.
this document information is the inte llectual property of megawin technology. ? megawin technology co., ltd. 2013 all right reserved. qp-7300-03d 48/68 MG64F237 datasheet v1.00 txcon (transmit fifo control register, endpoint-indexed , address=34h, sys_rst / usb_rst , write-only) 7 6 5 4 3 2 1 0 txclr -- -- txffrc -- -- -- -- r / w r / w bit7 : txclr -- transmit fifo clear. set this bit to flush the entire transmit fifo. all fifo statuses are reverted to their reset states. hardware clears this bit when the flush operation is completed. note: txclr would clear txfifo. the txseq bit in the txstat register are not affected by this operation. bit[6:5] : reserved. bit4 : txffrc -- tx fifo ready complete. bit[3:0] : reserved. note: txcon only services the transmit endpoints.
this document information is the inte llectual property of megawin technology. ? megawin technology co., ltd. 2013 all right reserved. qp-7300-03d 49/68 MG64F237 datasheet v1.00 16 in application programming (iap) MG64F237 has a 8k bytes mtp memory. total 8k bytes support iap function. the iap-memory block can be accessed by cpu to store the us er data and application program. 0xe000 0xffff figure 16-1 iap block diagram 16.1 iap register iap_pr (iap write protect register) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 r w default 00e0h iap_pr pr7 pr6 pr5 pr4 pr3 pr2 pr1 pr0 ? xxxx xxxxb bit[7:0] : pr[7:0] -- write protect pattern. iap-memory block would be written by firmware , when iap_wp is written ?46h? then ?b9h?. the iap_wp will be automatically cleared by next uc write action or flash write time-out. note : clear watch timer before the iap function is used. note : when vdd < vlvd1(2.4v), iap function would be disabled. example: sei lda #5ah sta pwpr lda #80h sta wdt_st lda #46h sta iap_pr lda #b9h sta iap_pr lda #40h ;the data will be written into flash. sta e000h ;iap_area (e000h ~ ffffh) cli
this document information is the inte llectual property of megawin technology. ? megawin technology co., ltd. 2013 all right reserved. qp-7300-03d 50/68 MG64F237 datasheet v1.00 17 hardware option there are two function cont rol by hardware option. lock enabled: code dump on writer is always 0xff, page-erase and program is also disabled. disabled: code dump on writer is transparent. (default) enrco : internal osc function enable/disable enable: enable internal osc to be a clock source. disable: external osc to be a clock source. (default)
this document information is the inte llectual property of megawin technology. ? megawin technology co., ltd. 2013 all right reserved. qp-7300-03d 51/68 MG64F237 datasheet v1.00 18 application circuit 18.1 usb keyboard circuit scroll lock d3 caps lock d2 num lock d1 vdd p42 p41 p40 icp_sda gnd 1 2 dfu function option 1 2 3 4 5 usb cn1 vdd dm dp vss 47 ohm r2 47 ohm r1 + 10 uf c1 l1 need 0.1 uf c2 v33 vss vdd resb 1 uf 0.1 uf c3 c4 vdd need gnd 3 xtal1 xtal2 resonator MG64F237 p34 4 int1/p33 5 int0/p32 6 p31 7 p30 8 p27 9 icp_sda/p26 10 icp_scl/p25 11 26 resb p00 34 p01 33 p02 32 p03 31 p04 30 p05 29 p06 28 p07 27 p10 p40 24 25 36 35 37 44 43 42 41 40 39 38 15 16 17 18 19 20 21 22 23 scan in 7 scan out scan in 6 scan in 5 scan in 4 scan in 3 scan in 2 scan in 1 scan in 0 p40 resb 1 2 scan out scan out scan out scan out scan out option 13 14 12 xtal2/p36 2 xtal1/p35 3 p45 1 resb vcc icp_scl icp_sda icp_comb vss 1 2 3 4 5 6 writer interface option figure 18-1 application circuit - keyboard
this document information is the inte llectual property of megawin technology. ? megawin technology co., ltd. 2013 all right reserved. qp-7300-03d 52/68 MG64F237 datasheet v1.00 18.2 usb multi media dongle icp_sda gnd 1 2 dfu function option 1 2 3 4 5 usb cn1 vdd dm dp vss 47 ohm r2 47 ohm r1 + 10 uf c1 l1 need 0.1 uf c2 v33 vss vdd resb 1 uf 0.1 uf c3 c4 vdd need gnd 3 xtal1 xtal2 resonator p34 4 int1/p33 5 int0/p32 6 p31 7 p30 8 p27 9 icp_sda/p26 10 icp_scl/p25 11 26 resb p00 34 p01 33 p02 32 p03 31 p04 30 p05 29 p06 28 p07 27 p10 p40 24 25 36 35 37 44 43 42 41 40 39 38 15 16 17 18 19 20 21 22 23 resb 1 2 spi_sclk spi_cs option 13 14 12 xtal2/p36 2 xtal1/p35 3 p45 1 resb vdd icp_scl icp_sda icp_comb vss 1 2 3 4 5 6 writer interface option figure 18-2 application circuit - dongle
this document information is the inte llectual property of megawin technology. ? megawin technology co., ltd. 2013 all right reserved. qp-7300-03d 53/68 MG64F237 datasheet v1.00 19 dfu function description dfu is a usb on-line update firmware function. user can use this function in development or ap on-line check/update device firmware version flow. megawin pr ovide ap source code and firmware library. user must insert usb hid dfu command, 2 vector command and dfu library code (1.5k bytes). 19.1 dfu ap description figure 19-1 megawin dfu application program : user's usb device vid(vende r id) and pid(product id). : load user code (code size must be 8kbytes) : start to update firmware. 19.2 dfu firmware library ? usb hid dfu command ? dfu variable define m_ep0_stage .ds 1 ; endpoint 0 usb stage statusstage .equ 0 ;status stage datastage_r .equ 1 ;data stage ( in, txd0 ) datastage_w .equ 2 ;data stage ( out, rxd0 ) setaddress .equ 3 dfu_stage .equ 33h dfu_reset .equ 44h ;---------------------------------------------- m_ep0_rxcnt .ds 1 m_ep0_rxtx .ds 8 ;for save setup 8 bytes command
this document information is the inte llectual property of megawin technology. ? megawin technology co., ltd. 2013 all right reserved. qp-7300-03d 54/68 MG64F237 datasheet v1.00 ? dfu command : endpoint 0 tx done endpoint_0_txd0: endpoint_0_in_token: lda m_ep0_stage cmp #dfu_reset beq dfu_cmd_in_ok_check_cmd ... ;---------------------------------------------- ;(statusstage) jmp ep0_set_statusstage_stall ... ;---------------------------------------------- ;(dfu_stage) : setup + out + in dfu_cmd_in_ok_check_cmd: usb_w_sfr_data_s #dcon,#00h ;disable puren mov_ 01ffh,#5ah ;dfu function flag mov_ 01feh,#a5h ;dfu function flag mov_ pwpr,#5ah ;protect write unlock mov_ rst_ctl,#80h ;software reset ... ? dfu command : endpoint 0 rx done endpoint_0_out_token: lda m_ep0_stage cmp #dfu_stage beq dfu_read_cmd_to_fifo ... ;---------------------------------------------- ; (statusstage) ;setup + out + out + .... + in jmp ep0_set_statusstage_stall ... ;---------------------------------------------- ;(dfu_stage) : setup + out + in dfu_read_cmd_to_fifo: jsr usb_r_rxdat_to_ram ;m_ep0_rxcnt / m_ep0_rxtx lda m_ep0_rxtx+0 sta m_ep0_stage, jsr usb_w_rxffrc_rts ;set rxffrc to clear fifo jmp usb_w_txffrc_rts ;return zero length ack ? dfu command : usb hid set report usb_set_report: lda m_ep0_rxtx+3 ;report type (1=input, 3=feature) cmp #3 beq usb_set_report_feature ;set_report_feature jmp ep0_set_statusstage_stall ... usb_set_report_feature: ;set duf datastage_w stage lda #dfu_stage sta m_ep0_stage rts
this document information is the inte llectual property of megawin technology. ? megawin technology co., ltd. 2013 all right reserved. qp-7300-03d 55/68 MG64F237 datasheet v1.00 ? usb hid descriptor interface_0_hid_report: ... (user applictaion)... ;=== vendor defined : dfu function command === .db 09h,00h ; usage page (vendor defined) .db 95h,08h ; report count (8 bytes) .db 75h,08h ; report size (8 bits) .db b1h,00h ; feature (data, array, absolute) .db c0h ;end collection ? 2 vector and dfu main library ;=== 2 vector for reset and interrupt === .org f9fah jmp reset ;jump to user main program start address jmp irq_isr ;jump to user interrupt vector start address ;=== dfu function library === .org fa00h binclude MG64F237_dfu_v0107.lib 19.3 manual force device into dfu mode operation flow: 1. device connect to usb host. 2. short p26 to vss(ground) 3. short external reset pad to vss(ground) more than 200us, release reset pad to start free run. 4. release p26.
this document information is the inte llectual property of megawin technology. ? megawin technology co., ltd. 2013 all right reserved. qp-7300-03d 56/68 MG64F237 datasheet v1.00 20 instruction set 20.1 instruction set summary addressing mode table address mode instruction times in memory cycle memory utilization in number of program sequence bytes 1 absolute a 4(3) 3 2 absolute indexed indirect (a,x) 5 3 3 absolute indexed with x a,x 4(3) 3 4 absolute indexed with y a,y 4 3 5 absolute indirect (a) 4-5(3) 3 6 accumulator a 2 1 7 immediate # 2 2 8 implied i 2 1 9 program counter relative r 2(2) 2 10 stack s 2-3 1 11 zero page zp 3(3) 2 12 zero page indexed indirect (zp,x) 6 2 13 zero page indexed with x zp,x 4(3) 2 14 zero page indexed with y zp,y 4 2 15 zero page indirect (zp) 5 2 16 zero page indirect indexed with y (zp),y 5 2 notes: (indicated in parenthesis) (1). page boundary, add 1 cycle if page boundary is crossed when forming address (2). branch taken, add 1 cycle if branch is taken (3). read-modify-write, add 2-3 cycles
this document information is the inte llectual property of megawin technology. ? megawin technology co., ltd. 2013 all right reserved. qp-7300-03d 57/68 MG64F237 datasheet v1.00 20.2 instruction set table adc add memory to accumulator with carry lda load accumulator with memory and "and" memory with accumulator ldx load the x register with memory asl arithmetic shift one bit left, memory or accumulator ldy load the y register with memory bbr branch on bit reset lsr logical shift one bit right memory or accumulator bbs branch of bit set ora "or " memory with accumulator bcc branch on carry clear (pc=0) pha push accumulator on stack bcs branch on carry set (pc=1) php push processor status on stack beq branch if equal (pz=1) phx push x register on stack bit bit test phy push y register on stack bmi branch if result minus (pn=1) pla pull accumulator from stack bne branch if not equal (pz=0) plp pull processor status from stack bpl branch if result plus (pn=0) plx pull x register from stack bra branch always ply pu ll y register from stack bvc branch on overflow clear (pv=0) rmb reset memory bit bvs branch on overflow set (pv=1) rol rot ate one bit left memory or accumulator clc clear cary flag ror rotate one bit right memory or accumulator cld clear decimal mode rti return from interrupt cli clear interrupt disable bit rts return from subroutine clv clear overflow flag sbc subtract memory from accumulator with borrow (carry bit) cmp compare memory and accumulator sed set decimal mode cpx compare memory and x register sei set interrupt disable status cpy compare memory and y register smb set memory bit dec decrement memory or accumulate by one sta store accumulator in memory dex decrement x by one stx store the x register in memory dey decrement y by one sty store the y register in memory eor "exclusive or" memory with accu mulate stz store zero in memory inc increment memory or accumulate by one ta x transfer the accumulator to the x register inx increment x register by one tay trans fer the accumulator to the y register iny increment y register by one tsx trans fer the stack pointer to the x register jmp jump to new location txa transfe r the x register to the accumulator jsr jump to new location saving return (jump to subroutine) txs transfer the x register to the stack pointer register nop no operation tya transfer y register to the accumulator
this document information is the inte llectual property of megawin technology. ? megawin technology co., ltd. 2013 all right reserved. qp-7300-03d 58/68 MG64F237 datasheet v1.00 20.3 instruction set summary msd 0 1 2 3 4 5 6 7 8 9 a b c d e f f bbr0 r 4,3 bbr1 r 4,3 bbr2 r 4,3 bbr3 r 4,3 bbr4 r 4,3 bbr5 r 4,3 bbr6 r 4,3 bbr7 r 4,3 bbs0 r 4,3 bbs1 r 4,3 bbs2 r 4,3 bbs3 r 4,3 bbs4 r 4,3 bbs5 r 4,3 bbs6 r 4,3 bbs7 r 4,3 f e asl a 6,3 asl a,x 7,3 rol a 6,3 rol a,x 7,3 lsr a 6,3 lsr a,x 7,3 ror a 6,3 ror a,x 7,3 stx a 4,3 stz a,x 5,3 ldx a 4,3 ldx a,y 4,3 dec a 6,3 dec a,x 7,3 inc a 6,3 inc a,x 7,3 e d ora a 4,3 ora a,x 4,3 and a 4,3 and a,x 4,3 eor a 4,3 eor a,x 4,3 adc a 4,3 adc a,x 4,3 sta a 4,3 sta a,x 4,3 lda a 4,3 lda a,x 4,3 cmp a 4,3 cmp a,x 4,3 sbc a 4,3 sbc a,x 4,3 d c bit a 4,3 bit a,x 4,3 jmp a 3,3 jmp (a) 5,3 jmp (a,x) 6,3 sty a 4,3 stz a 4,3 ldy a 4,3 ldy a,x 4,3 cpy a 4,3 cpx a 4,3 c b b a asl a 2,1 inc a 2,1 rol a 2,1 dec a 2,1 lsr a 2,1 phy s 3,1 ror a 2,1 ply s 3,1 txa i 2,1 txs i 2,1 tax i 2,1 tsx i 2,1 dex i 2,1 phx s 3,1 nop i 2,1 plx s 3,1 a 9 ora # 2,2 ora a,y 4,3 and # 2,2 and a,y 4,3 eor # 2,2 eor a,y 4,3 adc # 2,2 adc a,y 4,3 bit # 2,2 sta a,y 4,3 lda # 2,2 lda a,y 4,3 cmp # 2,2 cmp a,y 4,3 sbc # 2,2 sbc a,y 4,3 9 8 php s 3,1 clc i 2,1 plp s 3,1 sec i 2,1 pha s 3,1 cli i 2,1 pla s 3,1 sei i 2,1 dey i 2,1 tya i 2,1 tay i 2,1 clv i 2,1 iny i 2,1 cld i 2,1 inx i 2,1 sed i 2,1 8 7 rmb0 zp 5,2 rmb1 zp 5,2 rmb2 zp 5,2 rmb3 zp 5,2 rmb4 zp 5,2 rmb5 zp 5,2 rmb6 zp 5,2 rmb7 zp 5,2 smb0zp 5,2 smb1 zp 5,2 smb2 zp 5,2 smb3 zp 5,2 smb4 zp 5,2 smb5 zp 5,2 smb6 zp 5,2 smb7 zp 5,2 7 6 asl zp 5,2 asl zp,x 6,2 rol zp 5,2 rol zp,x 6,2 lsr zp 5,2 lsr zp,x 6,2 ror zp 5,2 ror zp,x 6,2 stx zp 3,2 stx zp,y 4,2 ldx zp 3,2 ldx zp,y 4,2 dec zp 5,2 dec zp,x 6,2 inc zp 5,2 inc zp,x 6,2 6 5 ora zp 3,2 ora zp,x 4,2 and zp 3,2 and zp,x 4,2 eor zp 3,2 eor zp,x 4,2 adc zp 3,2 adc zp,x 4,2 sta zp 3,2 sta zp,x 4,2 lda zp 3,2 lda zp,x 4,2 cmp zp 3,2 cmp zp,x 4,2 sbc zp 3,2 sbc zp,x 4,2 5 4 bit zp 3,2 bit zp,x 4,2 stz zp 3,2 stz zp,x 4,2 sty zp 3,2 sty zp,x 4,2 ldy zp 3,2 ldy zp,x 4,2 cpy zp 3,2 cpx zp 3,2 4 3 3 2 ora (zp) 5,2 and (zp) 5,2 eor (zp) 5,2 adc (zp) 5,2 sta (zp) 5,2 ldx # 2,2 lda (zp) 5,2 cmp (zp) 5,2 sbc (zp) 5,2 2 1 ora (zp,x) 6,2 ora (zp),y 5,2 and (zp,x) 6,2 and (zp),y 5,2 eor (zp,x) 6,2 eor (zp),y 5,2 adc (zp,x) 6,2 adc (zp),y 5,2 sta (zp,x) 6,2 sta (zp),y 5,2 lda (zp,x) 6,2 lda (zp),y 5,2 cmp (zp,x) 6,2 cmp (zp),y 5,2 sbc (zp,x) 6,2 sbc (zp),y 5,2 1 0 bpl r 2,2 jsr a 6,3 bmi r 2,2 rti s 5,1 bvc r 2,2 rts s 5,1 bvs r 2,2 bra r 3,2 bcc r 2,2 ldy # 2,2 bcs r 2,2 cpy # 2,2 bne r 2,2 cpx # 2,2 beq r 2,2 0 msd 0 1 2 3 4 5 6 7 8 9 a b c d e f a: accumulator x: index register x y: index register y zp: address8 or zero page a: adress16 s: stack r: relative i : implied
this document information is the inte llectual property of megawin technology. ? megawin technology co., ltd. 2013 all right reserved. qp-7300-03d 59/68 MG64F237 datasheet v1.00 20.4 symbol description acc: accumulator (acc): contents of accumulator acc.n: accumulator bit n x: index register x y: index register y sp: stack pointer register pc: program counter #data: constant parameter c: carry flag z: zero flag i: interrupt disable status b: break status d: decimal mode status v: overflow flag s: sign flag addr16: absolute address addr8: zero page/relative address addr+(index): combined address addr ? 16: address extend to absolute address (get two addr8 contents continuously) label: address variable ~: 1?s compliment ? : and ? : or ? : exclusive or ? : transfer direction, result
this document information is the inte llectual property of megawin technology. ? megawin technology co., ltd. 2013 all right reserved. qp-7300-03d 60/68 MG64F237 datasheet v1.00 20.5 arithmetic operations mnemonic operand(s) operation description flag byte cycle adc #data (acc) ? (acc) + #data + (c) c, z, v, s 2 2 addr8 (acc) ? (acc) + (addr8) + (c) c, z, v, s 2 3 (addr8) (acc) ? (acc) + [(addr8)] + (c) c, z, v, s 2 5 addr8, x (acc) ? (acc) + [addr8 + (x)] + (c) c, z, v, s 2 4 (addr8, x) (acc) ? (acc) + {[addr8 + (x) ? 16]} + (c) c, z, v, s 2 6 (addr8), y (acc) ? (acc) + [(addr8 ? 16) + (y)] + (c) c, z, v, s 2 5 addr16 (acc) ? (acc) + (addr16) + (c) c, z, v, s 3 4 addr16, x (acc) ? (acc) + [addr16 + (x)] + (c) c, z, v, s 3 4 addr16, y (acc) ? (acc) + [addr16 + (y)] + (c) c, z, v, s 3 4 sbc #data (acc) ? (acc) ? #data ? (~c) c, z, v, s 2 2 addr8 (acc) ? (acc) ? (addr8) ? (~c) c, z, v, s 2 3 (addr8) (acc) ? (acc) ? [(addr8)] ? (~c) c, z, v, s 2 5 addr8, x (acc) ? (acc) ? [addr8 + (x)] ? (~c) c, z, v, s 2 4 (addr8, x) (acc) ? (acc) ? {[addr8 + (x) ? 16]} ? (~c) c, z, v, s 2 6 (addr8), y (acc) ? (acc) ? [(addr8 ? 16) + (y)] ? (~c) c, z, v, s 2 5 addr16 (acc) ? (acc) ? (addr16) ? (~c) c, z, v, s 3 4 addr16, x (acc) ? (acc) ? [addr16 + (x)] ? (~c) c, z, v, s 3 4 addr16, y (acc) ? (acc) ? [addr16 + (y)] ? (~c) c, z, v, s 3 4 inc a (acc) ? (acc) + 1 c, z 1 2 addr8 (addr8) ? (addr8) + 1 z, s 2 5 addr8, x [addr8 + (x)] ? [addr8 + (x)] + 1 z, s 2 6 addr16 (addr16) ? (addr16) + 1 z, s 3 6 addr16, x [addr16 + (x)] ? [addr16 + (x)] + 1 z, s 3 7 inx (x) ? (x) + 1 z, s 1 2 iny (y) ? (y) + 1 z, s 1 2 dec a (acc) ? (acc) ? 1 c, z 1 2 addr8 (addr8) ? (addr8) ? 1 z, s 2 5 addr8, x [addr8 + (x)] ? [addr8 + (x)] ? 1 z, s 2 6 addr16 (addr16) ? (addr16) ? 1 z, s 3 6 addr16, x [addr16 + (x)] ? [addr16 + (x)] ? 1 z, s 3 7 dex (x) ? (x) ? 1 z, s 1 2 dey (y) ? (y) ? 1 z, s 1 2 cmp #data (acc) ? #data c, z, s 2 2 addr8 (acc) ? (addr8) c, z, s 2 3 (addr8) (acc) ? [(addr8)] c, z, s 2 5 addr8, x (acc) ? [addr8 + (x)] c, z, s 2 4 (addr8, x) (acc) ? {[addr8 + (x) ? 16]} c, z, s 2 6 (addr8), y (acc) ? [(addr8 ? 16) + (y)] c, z, s 2 5 addr16 (acc) ? (addr16) c, z, s 3 4 addr16, x (acc) ? [addr16 + (x)] c, z, s 3 4 addr16, y (acc) ? [addr16 + (y)] c, z, s 3 4 note: * add one clock period of page boundary is crossed.
this document information is the inte llectual property of megawin technology. ? megawin technology co., ltd. 2013 all right reserved. qp-7300-03d 61/68 MG64F237 datasheet v1.00 mnemonic operand(s) operation description flag byte cycle cpx #data (x) ? #data c, z, s 2 2 addr8 (x) ? (addr8) c, z, s 2 3 addr16 (x) ? (addr16) c, z, s 3 4 cpy #data (y) ? #data c, z, s 2 2 addr8 (y) ? (addr8) c, z, s 2 3 addr16 (y) ? (addr16) c, z, s 3 4 note: * add one clock period of page boundary is crossed. 20.6 logic operations mnemonic operand(s) operation description flag byte cycle and #data (acc) ? (acc) ? #data z, s 2 2 addr8 (acc) ? (acc) ? (addr8) z, s 2 3 (addr8) (acc) ? (acc) ? [(addr8)] z, s 2 5 addr8, x (acc) ? (acc) ? [addr8 + (x)] z, s 2 4 (addr8, x) (acc) ? (acc) ? {[addr8 + (x) ? 16]} z, s 2 6 (addr8), y (acc) ? (acc) ? [(addr8 ? 16) + (y)] z, s 2 5 addr16 (acc) ? (acc) ? (addr16) z, s 3 4 addr16, x (acc) ? (acc) ? [addr16 + (x)] z, s 3 4 addr16, y (acc) ? (acc) ? [addr16 + (y)] z, s 3 4 ora #data (acc) ? (acc) ? #data z, s 2 2 addr8 (acc) ? (acc) ? (addr8) z, s 2 3 (addr8) (acc) ? (acc) ? [(addr8)] z, s 2 5 addr8, x (acc) ? (acc) ? [addr8 + (x)] z, s 2 4 (addr8, x) (acc) ? (acc) ? {[addr8 + (x) ? 16]} z, s 2 6 (addr8), y (acc) ? (acc) ? [(addr8 ? 16) + (y)] z, s 2 5 addr16 (acc) ? (acc) ? (addr16) z, s 3 4 addr16, x (acc) ? (acc) ? [addr16 + (x)] z, s 3 4 addr16, y (acc) ? (acc) ? [addr16 + (y)] z, s 3 4 eor #data (acc) ? (acc) ? #data z, s 2 2 addr8 (acc) ? (acc) ? (addr8) z, s 2 3 (addr8) (acc) ? (acc) ? [(addr8)] z, s 2 5 addr8, x (acc) ? (acc) ? [addr8 + (x)] z, s 2 4 (addr8, x) (acc) ? (acc) ? {[addr8 + (x) ? 16]} z, s 2 6 (addr8), y (acc) ? (acc) ? [(addr8 ? 16) + (y)] z, s 2 5 addr16 (acc) ? (acc) ? (addr16) z, s 3 4 addr16, x (acc) ? (acc) ? [addr16 + (x)] z, s 3 4 addr16, y (acc) ? (acc) ? [addr16 + (y)] z, s 3 4 rol a (c) ? (acc.7), (acc.(n+1)) ? (acc. n), (acc.0 ) ? (c) c, z, s 1 2 addr8 (c) ? (addr8.7), (addr8.(n+1)) ? (addr8.n), (addr8.0 ) ? (c) c, z, s 2 5 addr8, x (c) ? [addr8 + (x).7], [addr8 + (x).(n+1)] ? [addr8 + (x).n], [addr8 + (x).0] ? (c) c, z, s 2 6 addr16 (c) ? (addr16.7), (addr16.(n+1) ) ? (addr16.n), (addr16.0 ) ? (c) c, z, s 3 6 addr16, x (c) ? [addr16 + (x).7], [addr16 + (x).(n+1)] ? [addr16 + (x).n], [addr16 + (x).0] ? (c) c, z, s 3 7 note: * add one clock period of page boundary is crossed.
this document information is the inte llectual property of megawin technology. ? megawin technology co., ltd. 2013 all right reserved. qp-7300-03d 62/68 MG64F237 datasheet v1.00 mnemonic operand(s) operation description flag byte cycle ror a (acc.7 ) ? (c), (acc. n) ? (acc.(n+1) ), (c) ? (acc.0) c, z, s 1 2 addr8 (addr8.7 ) ? (c), (addr8. n) ? (addr8.(n+1) ), (c) ? (addr8.0) c, z, s 2 5 addr8, x [addr8 + (x).7] ? (c), [addr8 + (x).n] ? [addr8 + (x).(n+1)], (c) ? [addr8 + (x).0] c, z, s 2 6 addr16 (addr16.7 ) ? (c), (addr16. n) ? (addr16.(n+1) ), (c) ? (addr16.0) c, z, s 3 6 addr16, x [addr16 + (x).7] ? (c), [addr16 + (x).n] ? [addr16 + (x).(n+1)], (c) ? [addr16 + (x).0] c, z, s 3 7 asl a (c) ? (acc.7), (acc.(n+1) ) ? (acc. n), (acc.0) ? 0 c, z, s 1 2 addr8 (c) ? (addr8.7), (addr8.(n+1) ) ? (addr8. n), (addr8.0) ? 0 c, z, s 2 5 addr8, x (c) ? [addr8 + (x).7], [addr8 + (x).(n+1)] ? [addr8 + (x).n], [addr8 + (x).0] ? 0 c, z, s 2 6 addr16 (c) ? (acc.7), (acc.(n+1) ) ? (acc. n), (acc.0) ? 0 c, z, s 3 6 addr16, x (c) ? [addr16 + (x).7], [addr16 + (x).(n+1)] ? [addr16 + (x).n], [addr16 + (x).0] ? 0 c, z, s 3 7 lsr a (acc.7 ) ? 0, (acc. n) ? (acc.(n+1) ), (c) ? (acc.0) c, z, s 1 2 addr8 (addr8.7 ) ? 0, (addr8. n) ? (addr8.(n+1) ), (c) ? (addr8.0) c, z, s 2 5 addr8, x [addr8 + (x).7] ? 0, [addr8 + (x).n] ? [addr8 + (x).(n+1)], (c) ? [addr8 + (x).0] c, z, s 2 6 addr16 (addr16.7 ) ? 0, (addr16. n) ? (addr16.(n+1) ), (c) ? (addr16.0) c, z, s 3 6 addr16, x [addr16 + (x).7] ? 0, [addr16 + (x).n] ? [addr16 + (x).(n+1)], (c) ? [addr16 + (x).0] c, z, s 3 7 bit #data (acc) ? #data z 2 2 addr8 (acc) ? (addr8) z 2 3 addr8, x (acc) ? [addr8 + (x)] z 2 4 addr16 (acc) ? (addr16) z 3 4 addr16, x (acc) ? [addr16 + (x)] z 3 4 note: * add one clock period of page boundary is crossed.
this document information is the inte llectual property of megawin technology. ? megawin technology co., ltd. 2013 all right reserved. qp-7300-03d 63/68 MG64F237 datasheet v1.00 20.7 data transfer mnemonic operand(s) operation description flag byte cycle lda #data (acc) ? #data z, s 2 2 addr8 (acc) ? (addr8) z, s 2 3 (addr8) (acc) ? [(addr8)] z, s 2 5 addr8, x (acc) ? [addr8 + (x)] z, s 2 4 (addr8, x) (acc) ? {[addr8 + (x) ? 16]} z, s 2 6 (addr8), y (acc) ? [(addr8 ? 16) + (y)] z, s 2 5 addr16 (acc) ? (addr16) z, s 3 4 addr16, x (acc) ? [addr16 + (x)] z, s 3 4 addr16, y (acc) ? [addr16 + (y)] z, s 3 4 ldx #data (x) ? #data z, s 2 2 addr8 (x) ? (addr8) z, s 2 3 addr8, y (x) ? [addr8 + (y)] z, s 2 4 addr16 (x) ? (addr16) z, s 3 4 addr16, y (x) ? [addr16 + (y)] z, s 3 4 ldy #data (y) ? #data z, s 2 2 addr8 (y) ? (addr8) z, s 2 3 addr8, x (y) ? [addr8 + (x)] z, s 2 4 addr16 (y) ? (addr16) z, s 3 4 addr16, x (y) ? [addr16 + (x)] z, s 3 4 sta addr8 (addr8) ? (acc) - 2 3 (addr8) [(addr8)] ? (acc) - 2 5 addr8, x [addr8 + (x)] ? (acc) - 2 4 (addr8, x) {[addr8 + (x) ? 16]} ? (acc) - 2 6 (addr8), y [(addr8 ? 16) + (y)] ? (acc) - 2 5 addr16 (addr16) ? (acc) - 3 4 addr16, x [addr16 + (x)] ? (acc) - 3 4 addr16, y [addr16 + (y)] ? (acc) - 3 4 stx addr8 (addr8) ? (x) - 2 3 addr8, y [addr8 + (y)] ? (x) - 2 4 addr16 (addr16) ? (x) - 3 4 sty addr8 (addr8) ? (y) - 2 3 addr8, x [addr8 + (x)] ? (y) - 2 4 addr16 (addr16) ? (y) - 3 4 stz addr8 (addr8) ? 00h - 2 3 addr8, x [addr8 + (x)] ? 00h - 2 4 addr16 (addr16) ? 00h - 3 4 addr16, x [addr16 + (x)] ? 00h - 3 5 tax (x) ? (acc) z, s 1 2 txa (acc) ? (x) z, s 1 2 tay (y) ? (acc) z, s 1 2 tya (acc) ? (y) z, s 1 2 tsx (x) ? (sp) z, s 1 2 txs (sp) ? (x) - 1 2 note: * add one clock period of page boundary is crossed.
this document information is the inte llectual property of megawin technology. ? megawin technology co., ltd. 2013 all right reserved. qp-7300-03d 64/68 MG64F237 datasheet v1.00 mnemonic operand(s) operation description flag byte cycle pha [(sp)] ? (acc), (sp) ? (sp) ? 1 - 1 3 php [(sp)] ? (p), (sp) ? (sp) ? 1 - 1 3 phx [(sp)] ? (x), (sp) ? (sp) ? 1 - 1 3 phy [(sp)] ? (y), (sp) ? (sp) ? 1 - 1 3 pla (acc) ? [(sp+1)], (sp) ? (sp) + 1 z, s 1 3 plp (p) ? [(sp+1)], (sp) ? (sp) + 1 c, z, i, d, v, s 1 3 plx (x) ? [(sp+1)], (sp) ? (sp) + 1 z, s 1 3 ply (y) ? [(sp+1)], (sp) ? (sp) + 1 z, s 1 3 note: * add one clock period of page boundary is crossed. 20.8 boolean variable manipulation mnemonic operand(s) operation description flag byte cycle clc (c) ? 0 c 1 2 cli (i) ? 0 i 1 2 cld (d) ? 0 d 1 2 clv (v) ? 0 v 1 2 sec (c) ? 1 c 1 2 sei (i) ? 1 i 1 2 sed (d) ? 1 d 1 2 smb0 addr8 (addr8.0) ? 1 z 2 5 ? smb7 addr8 (addr8.7) ? 1 z 2 5 rmb0 addr8 (addr8.0) ? 0 z 2 5 ? rmb7 addr8 (addr8.7) ? 0 z 2 5 note: if the assembler does not support this instruction, please use db to implement it. the op code of rmb0 ~ rmb7 is 07 ~ 77, and the smb0 ~ smb7 is 87 ~ f7.
this document information is the inte llectual property of megawin technology. ? megawin technology co., ltd. 2013 all right reserved. qp-7300-03d 65/68 MG64F237 datasheet v1.00 20.9 program and machine control mnemonic operand(s) operation description flag byte cycle jmp addr16 (pc) ? label; the label may be address or variable. - 3 3 (addr16) (pc) ? (label) - 3 5 (addr16, x) (pc) ? {[label + (x) ? 16]} - 3 6 bra addr8 (pc) ? (pc)+addr8 - 2 3(1) beq addr8 (pc) ? (pc)+addr8 if z == 1 (+/- relative) - 2 2(2)(3) bne addr8 (pc) ? (pc)+addr8 if z == 0 (+/- relative) - 2 2(2)(3) bcs addr8 (pc) ? (pc)+addr8 if c == 1 (+/- relative) - 2 2(2)(3) bcc addr8 (pc) ? (pc)+addr8 if c == 0 (+/- relative) - 2 2(2)(3) bmi addr8 (pc) ? (pc)+addr8 if (s == 1) (+/- relative) - 2 2(2)(3) bpl addr8 (pc) ? (pc)+addr8 if (s == 0) (+/- relative) - 2 2(2)(3) bvs addr8 (pc) ? (pc)+addr8 if (v == 1) (+/- relative) - 2 2(2)(3) bvc addr8 (pc) ? (pc)+addr8 if (v == 0) (+/- relative) - 2 2(2)(3) bbr0 addr8 (pc) ? (pc)+addr8 if acc.0 == 0 (+/- relative) - 3 4(2)(3) ? bbr7 addr8 (pc) ? (pc)+addr8 if acc.7 == 0 (+/- relative) - 3 4(2)(3) bbs0 addr8 (pc) ? (pc)+addr8 if acc.0 == 1 (+/- relative) - 3 4(2)(3) ? bbs7 addr8 (pc) ? (pc)+addr8 if acc.7 == 1 (+/- relative) - 3 4(2)(3) jsr label stack ? (pc), (pc) ? label - 3 6 rts (pc) ? pop stack - 1 5 rti (pc) ? pop stack, restore status register p c, z, i, d, v, s 1 5 nop no operation - 1 2 note: (1) add 1 cycle for indexing across page boundaries, or write. this cycle contains invalid addresses. note: (2) add 1 cycle if branch is taken. note: (3) add 1 cycle if branch is taken across page boundaries. note: if the assembler does not support this instruction, please use db to implement it. the op code of bbr0 ~ bbr7 is 0f ~ 7f, and the bbs0 ~ bbs7 is 8f ~ ff.
this document information is the inte llectual property of megawin technology. ? megawin technology co., ltd. 2013 all right reserved. qp-7300-03d 66/68 MG64F237 datasheet v1.00 21 electrical characteristics 21.1 dc characteristics vss = 0v, ta = 25 , vdd5v = 5.0v , vddo = 5.0v, f osc = 6mhz and execute nop for each machine cycle, unless otherwise specified table 21-1 dc characteristic (vddo=5v) limits symbol parameter test condition min typ max unit v ih1 input high voltage (all i/o ports except p35 & p36) 2.0 v v ih2 input high voltage (p35 & p36) 3.2 v v ih3 input high voltage (ps2_data & ps2_clk) 1.9 v v ih4 input high voltage (reset) 3.9 v v il1 input low voltage (all i/o ports except p35 & p36) 0.8 v v il2 input low voltage (p35 & p36) 1.4 v v il3 input low voltage (ps2_data & ps2_clk) 0.6 v v il4 input low voltage (reset) 1.1 v i ol1 output low current (all i/o ports except p35 & p36) v pin = 0.4v 4 ma i ol2 output low current (p35 & p36) v pin = 0.4v v pin = 1.2v 20 50 ma i ol3 output low current (ps2_data & ps2_clk)) v pin = 0.4v 30 ma i op operating current 6 ma i idle idle mode current 3 ma i pd power down current 150 ua r io1 internal pull-up resistance (p0 / p1 / p2 / p3) 50 k r io2 internal pull-up resistance (p0 / p1 / p2) 3 m r rst internal reset pull-down resistance 50 k r ps2 ps2_data & ps2_clk pull-up resistance in ps2 mode 7 k r dm dm pull-up resistance in usb mode 1.1 k r pd dp/dm pull-down resistance in usb mode 500 k v 33 3.3v regulator output voltage 3.3 v i 33 3.3v regulator output current 50 ma v por low-voltage reset 2.7 v v lvdf low-voltage flag 3.6 v ihrco built-in osc. frequency 5.91 6 6.09 mhz
this document information is the inte llectual property of megawin technology. ? megawin technology co., ltd. 2013 all right reserved. qp-7300-03d 67/68 MG64F237 datasheet v1.00 vss = 0v, ta = 25 , vdd5v = 5.0v , vddo = 3.0v, f osc = 6mhz and execute nop for each machine cycle, unless otherwise specified table 21-2 dc characteristic (vddo=3v) limits symbol parameter test condition min typ max unit v ih1 input high voltage (all i/o ports except p35 & p36) 1.5 v v ih2 input high voltage (p35 & p36) 2.1 v v ih4 input high voltage (reset) 2.4 v v il1 input low voltage (all i/o ports except p35 & p36) 0.5 v v il2 input low voltage (p35 & p36) 0.6 v v il4 input low voltage (reset) 0.6 v i ol1 output low current (all i/o ports except p35 & p36) v pin = 0.4v 3 ma i ol2 output low current (p35 & p36) v pin = 0.4v v pin = 1.2v 10 30 ma r io1 internal pull-up resistance (p0 / p1 / p2 / p3) 130 k r io2 big internal pull-up resistance for power down wakeup (only p0 / p1 / p2) 10 m r rst internal reset pull-down resistance 130 k 21.2 usb transceiver electrical characteristics vss = 0v, ta = 25 , vdd5v = 5.0v and execute nop for each ma chine cycle, unless otherwise specified limits symbol parameter test condition min typ max unit transmitter v oh output high voltage 2.8 v v ol output low voltage 0.8 v i ol dp/dm output low current v pin = 0.4v 30 ma v crs output cross over point 1.3 2.0 v z drvh output impedance on driving high 28 44 ? z drvl output impedance on driving low 28 44 ? t r output rise time 75 300 ns t f output fall time 75 300 ns receiver v di differential input sensitivity | dp ? dm | 0.2 v v cm differential input common mode range 0.8 2.5 v i l input leakage current pull-up disabled <1.0 ua
this document information is the inte llectual property of megawin technology. ? megawin technology co., ltd. 2013 all right reserved. qp-7300-03d 68/68 MG64F237 datasheet v1.00 22 revision history revision page descriptions date v0.01 preliminary version. 2013/06/25 v1.00 initial version 2013/09/06


▲Up To Search▲   

 
Price & Availability of MG64F237

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