Anda di halaman 1dari 232

ME950

SHENZHEN SOFI TECHNOLOGY CO., LTD.


TEL:
+86-755-84867757
FAX:
+86-755-84867941
WEB: WWW.SOFI-TECH.COM
Email: WILLAR@TOM.COM

www.willar.com()
Publication Release Date: 2012-3
Revision A1

()

www.willar.com()www.mcu01.com

ME950

Mcu Development Kit User tutorial


1.1 ------------------------------------------------------------------------------ 6
1.2 ----------------------------------------------------------------------- 7
1.3 ------------------------------------------------------------------------------- 8
1.3.1 ------------------------------------------------------------------------ 8
1.3.2 ------------------------------------------------------------------------ 8


2.1 ------------------------------------------------------------------------------ 9
2.2 ------------------------------------------------------------------------------12
2.2.1 SFISP----------------------------------------------------------12
2.2.2 51 LED---------------------------------------- 11
2.2.3 AVR-------------------------------------------------------------- 13
2.2.4 PIC------------------------------------------------------------- 13

/ISP
3.1 ------------------------------------------------------------------------- 14
3.2 SFISP ------------------------------------------------------------------- 15
3.3 ----------------------------------------------------------------------- 15
3.3.1 ME950 ---------------------------------------------------------- 15
3.3.2 ISP -------------------------------------------------------------- 16
1) 51/AVR ISP ------------------------------------------------- 25
2) PIC ISP ----------------------------------------------------- 17
3.4 AT89S51/52 ---------------------------------------------------------------- 18


4.1 ICE52 --------------------------------------------------------------- 19
4.2
4.2.1 Keil C51 -------------------------------------------------------------- 19
4.2.2 ICE52D -------------------------------------------------------- 20
4.3 Keil C51 ----------------------------------------------------------------- 22
4.4 ---------------------------------------------------------------------------- 27
4.4.1 --------------------------------------------------------------- 27
1 ------------------------------------------------------------------ 27
2----------------------------------------------------------------- 27
3--------------------------------------------------------------- 28
4.4.2 ----------------------------------------------------------------28
4.4.3 ------------------------------------------------------------------------ 30
1--------------------------------------------------------------- 30
2--------------------------------------------------------------------- 31
3---------------------------------------------------------------------- 31
4 RAM------------------------------------------------------------------ 32
5---------------------------------------------------------------------- 32
6--------------------------------------------------------------------- 32
4.4.4 keil -------------------------------------------------------------- 32

0755-84867757

www.sofi-tech.com

www.mcu01.com

-3-

ME950

Mcu Development Kit User tutorial


5.1

LED ------------------------------------------------------------------- 35

-------------------------------------------------------------------- 39

--------------------------------------------------------------- 42

---------------------------------------------------------------- 46

0-7 ------------------------------------------------------------- 51

-------------------------------------------------------------- 57

------------------------------------------------------------------ 62

-------------------------------------------------------------- 68

1602 LCD -------------------------------------------------------------- 75


12864 LCD------------------------------------------------------------- 84

16x16 LED --------------------------------------------------------- 87


RS232 ------------------------------------------------------------ 95
74HC164 ------------------------------------------------------------ 101
74HC165 ------------------------------------------------------------ 106
------------------------------------------------------------- 111
NE555 ------------------------------------------------------------ 117
93C46 ------------------------------------------------------------ 129
24C04 ------------------------------------------------------------ 140
PCF8591 A/D -------------------------------------------------------151
PCF8591 D/A ------------------------------------------------------ 154
DS1302 --------------------------------------------------------- 156
DS18B20 -------------------------------------------------- 159
------------------------------------------------------- 171
PS2 -------------------------------------------------------- 181
74HC573 ------------------------------------------------------ 194
MAX485 -------------------------------------------------------- 198
5.2

PWMLED-------------------------------------------------- 203
---------------------------------------------------------- 204
--------------------------------------------------------- 205
------------------------------------------------------ 206
---------------------------------------------------------- 207
LCD12864 4 ---------------------------------------- 208
LCD12864 ------------------------------------------------ 209
---------------------------------------------------------- 209
-------------------------------------------------- 210
-------------------------------------------------- 210
0-99 ---------------------------------------------------------- 211
0-99 -------------------------------------------------- 211
8 ------------------------------------------------------- 212
1602 -------------------------------------------------------- 213
8 --------------------------------------------------- 214
1602 ---------------------------------------------------- 214
8 --------------------------------------------------- 215

0755-84867757

www.sofi-tech.com

www.mcu01.com

-4-

ME950

Mcu Development Kit User tutorial

1602 ---------------------------------------------------- 215


8 ------------------------------------------------------- 216
1602 -------------------------------------------------------- 218
DS18B20 () -------------------------------------- 220
DS18B20 (1602 ) ------------------------------------ 221
------------------------------------------------------ 223
-------------------------------------------------- 223
-------------------------------------------------------- 224
-------------------------------------------------------------- 225

5.3
TFT--------------------------------------------------------- 227
TFTSD-------------------------------------------------- 227
TFT---------------------------------------------------- 227
TFT-------------------------------------------------------- 227
TFT------------------------------------------------------------ 227
TFT+------------------------------------------------------- 227
TFT---------------------------------------------------- 227
TFT-------------------------------------------- 227
128x160 --------------------------------------------------- 227
TFT+SD+FAT-----------------------------------------227

1
1PWR------------------------------------------ 230
2.-------------------------------------------------------- 230
3.LED ----------------------------- 230
4.------------------------------------------------------------ 230
5. ID ---------------------------------------------------- 230
6.------------------------------------------------ 230
7. ISP------------------------------------------------------------------------- 231
8
ME950 ----------------------------------- 231
9. C ---------------------------------------------- 231
10.----------------------------------------------------------231
11.----------------------------------------------------231
12.ME950 ICE52 ------------------------------ 231
13----------------------------------------- 232

0755-84867757

www.sofi-tech.com

www.mcu01.com

-5-

ME950

Mcu Development Kit User tutorial


ME950 ()///
/ 51/AVR/PIC
ARM ME950

,, 51/AVR/PIC !

1.1

...
USB2.0 ( USB , USB )
51/AVR/PIC ATMELWinbondNXPPhilips
STC 40 51 AVR ATmega8515 PIC 16F877
3.3V/5V
ICE52 51 , ,32 IOT2
8051
POD52 ,,,
ISP ,
Keil,
SFISP
,,,
C ,,
USB 5V
///ESD , USB
, USB , Win2000/XP/Visata/Win7
32/64
,

1.1 ME950 ( 220x170x42mm)

0755-84867757

1.2 ME950

www.sofi-tech.com

www.mcu01.com

-6-

ME950

Mcu Development Kit User tutorial

1.2

1.3

15

24C04 (Microwire EEPROM)

ICE52 /

16

DS1302 RTC

DB9 MAX232

17

PCB

()

18

NE555

40PIN

19

128x64

LCD1602

20

16

8 7

21

16x16LED

22

DS18B20

23

10

/ PCF85914 AD,1 DA

24

74HC164

11

PS2

25

12

93C46 (I2C EEPROM)

26

4x4

13

27

74HC573

14

74HC165

28

MAX485

0755-84867757

www.sofi-tech.com

www.mcu01.com

-7-

ME950

Mcu Development Kit User tutorial

1.3
1.3.1

ME950

POD52

AT89S52(DIP40 )

1602

32

USB

10Pin ISP

ISP

24

1.3.2

TFT +SD ME950 SD TFT


DIP28 ATmega88 AVR
RDA5807 FM
12864
DS18B20
PIC16F877 PIC

0755-84867757

www.sofi-tech.com

www.mcu01.com

-8-

ME950

Mcu Development Kit User tutorial

ME950 ME950

2.1

2.1
SW1
JK1
J1 USB
J3 ISP
U1 CPU
Y1
JP241602LCD
K9

JP273.3V/5V
J115V
J2 RS232
JP2
J4 40Pin
JP1 CPU 51/AVR/PIC
JP251602LCD
PORT1/ PORT2/ PORT3

ME950 2.1
93C46 JP14 4

1602LCD JP24 OFF 1602LCD 1602LCD


P0P2 LED
12864LCD JP24 OFF 1602LCD JP22
LED JP9 2 VCC 12864LCD

0755-84867757

www.sofi-tech.com

www.mcu01.com

-9-

ME950

Mcu Development Kit User tutorial

SW1

USB USB EXT

JK1

5.5x2.1, 5V
5V
ME950 USB

JP27

3.3V/5V

J11

ME950 5V 300mA

J1

USB ME950 USB 5V


USB 5V 500mA

J3

/ISP ISP ISP


POD52

JP2

ISP ME950
300mA

PWR
STA

PWR STA PWR STR


PWR
K9 SW1

U1

40Pin AT89S51/52 40Pin 51


AVR ATmega8515L AVR POD52
JP1 POD52 JP1 51

JP1

CPU CPU (51/AVR/PIC)

J4

U1 CPU

Y1

K9

J2

RS232 COM

PORT1
PORT2
PORT3

3
RF MP3

2.2
ME950 / ICE52 ATMEL
WinbondNXPPhilips
STC 51 AVR ATmega8515
(
)ME950 PIC PIC16F877
51

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 10 -

ME950

Mcu Development Kit User tutorial

2.2.1 SFISP
SFISP ME900
51 AVR/PIC SFISP Software ,
SFISP_Setup.exe,

2.2

2.2.2 51 LED
SFISP ME950
ME950 51
ME950 USB USB ME950 USB
USB USB
ME950 SW1 USB PWR
ME950

JP9
2.3

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 11 -

ME950

Mcu Development Kit User tutorial

1 JP1MCU 51JP9
1602LCD JP24 OFF 1602LCD LED
2 AT89S52 ME950
PWR 950
3 SFISP
4AT89S52[ZIF] AT89S52[ISP]
5 Examples_A51\EX1_LED\LED.hex
6
16

2.4
LED
1

2
Y1

3
41602LCD JP24 OFFJP9
5

ME950 keil keil

2
4.3.4

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 12 -

ME950

Mcu Development Kit User tutorial

2.2.3 AVR
AVR 1997 ATMEL Flash RISC(Reduced Instruction Set CPU)
8 AVR

ME950 AVR ATmega8515 51 AVR


ME950 ISP AVR
ATmega16
ATmega8515L DIP40 ME950 AVR
1) JP1 AVR/PIC/ARMJP9
2 SFISP ATmega8515[ZIF]( ATmega8515[ISP])
3/Clock source and star-uptime

2.5
4 Example_AVR\EX1_LED\main.hex
5

16

RC RC

3-8M 3-8M

2.2.4 PIC
PIC MICROCHIP
51

ME950 PIC16F877 JP1 AVR/PIC/ARM PIC


SFISP

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 13 -

ME950

Mcu Development Kit User tutorial

/ISP
ME950 USB2.0 / ICE52
SFISP ISP
ISP 51 /VR /PIC ISP

SFISP ISP

3.1

ATMEL

AT89S51[ZIF] AT89S52[ZIF]
AT89S53[ZIF]
AT89S8252[ZIF]
AT89S51[ISP] AT89S52[ISP][ISP] AT89S53[ISP][ISP] AT89S8252[ISP]
ATmega8515[ZIF]
ATmega8515[ISP] ATmega16[ISP]

STC

STC12C5A8S2[ZIF] STC12C5A16S2[ZIF] STC12C5A32S2[ZIF] STC12C5A40S2[ZIF]


STC12C5A48S2[ZIF] STC12C5A52S2[ZIF] STC12C5A56S2[ZIF] STC12C5A60S2[ZIF]

NXP(Philips)

P89V51RB2[ZIF]

NUVOTON(winbond)

W78E052D[ZIF] W78E054D[ZIF] W78E058D[ZIF] W78E516D[ZIF]

MICROCHIP

PIC16F877A[ISP]

P89V51RC2[ZIF]

P89V51RD2[ZIF]

:
1 AVR Keil (Keil 51
) SFISP
2[ISP] ME950 ISP ( ISP )
[ZIF] ISP
3) NXP(Philips)NUVOTON(winbond) ISP ME950
ISP ISP ME950
ISP

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 14 -

ME950

Mcu Development Kit User tutorial

3.2 SFISP
SFISP ME950
V1.00

3.1

3.3
ME950

3.3.1 ME950
ME950 40pin ATMELWinbondNXP
PhilipsSTC 51 AVR
1)
SFISP USB ME950 PWR
SFISP

3.2

USB

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 15 -

ME950

Mcu Development Kit User tutorial

2)
[ZIF][ISP]
ISP
3)

4)
/
STC

5)





AVR PIC

3.3.2 ISP
ME950 ISP J3
ME950 ISP
10Pin ISP , AT89SAT89LS
AVR /PIC ISP
ISPIn-System Programming
ISP
ISP
1) 51/AVR ISP
ME950 ISP 5.3

3.3

MOSI

VCC

GND

GND

RST

GND

SCK

GND

MISO

10 GND

ME950 ISP

5pin ISP ISP 6


MOSISCKRESETMISOVCCGND Datasheet ISP
ISP 10Pin ISP ME950 ISP
JP2 ME950 5V 300mA
JP2 ME950 PWR ME950
ISP ME950 JP2

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 16 -

ME950

3.4

Mcu Development Kit User tutorial

ISP

ME950 AT89S52:

3.5 ISP
2)
ISP ME950
xxx[ISP][ISP] ISP
3.2.1
1) ISP SFISP
2)
3[ISP]

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 17 -

ME950

Mcu Development Kit User tutorial

3.4 AT89S51/52
AT89S51/52 Datasheet
Datasheet

AT89S51/52 ISP
ISP

DIP

TQFP

MOSI

P1.5(6 )

P1.5(1 )

SCK

P1.7(8 )

P1.7(3 )

RESET

(9 )

(4 )

MISO

P1.6(7 )

P1.6(2 )

VCC

(40 )

(38 )

GND

(20 )

(1617 )

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 18 -

ME950

Mcu Development Kit User tutorial

RAM

ME950 USB2.0 ICE52keil


keilPOD52

SSTUSB
ICE52
ICE52 ISP SFISP
, Keil , , KEIL
FLASH DOWNLOAD ,
ME950
LED Keil
ME950 ICE52

4.1 ICE52

USB2.0 ( USB USB )


, Keil
ATMEL, WINBOND, DALLAS, INTEL, SST, PHILIPS 51 52
,

Keil
, ,

POD52

//
()
DPTR, PCA, ALE , SPI , 768 RAM 51
63K , 64K RAM

4.2
ME950 keill C51 keil keil

4.2.1 Keil C51


Keil C51 Keil ARM 8051
8051 ME950 USB
1, Software c51v812.exe,

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 19 -

ME950

Mcu Development Kit User tutorial

4.1 Keil
2, Next , ,
3, Finish
Keil C51 V8.12 2K
Keil V7.5 ME950V7.5

4.2.2 ICE52D
Keil
1 Software ICE52D_DLL_SETUP. exe

4.2 Keil
2 3 Keil /
4.3

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 20 -

ME950

Mcu Development Kit User tutorial

4.3 ICE52
3 Keil Keil
2.9

4.4 Keil

4.5 Keil

4) Keil

4.6

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 21 -

ME950

Mcu Development Kit User tutorial

4.3 Keil C51


1 E Demo

Demo
2 Keil C51 Keil uVision3
3 Keil C51 Project | New uVision ProjectCreate New Project
Demo
Demo

4.7
4Options for Target Target 1 CPU ATMEL
AT89S52 AT89S52 4.8

4.8
5 4.9 8051
Keil C51 C (N)

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 22 -

ME950

Mcu Development Kit User tutorial

C (N)
(Y) (N)

4.9
Keil C51
6File | New,Text 1 File | Save,
Save AsLED.ASM 4.10

4.10
7LED.ASM
Keil C51
Target 1Source Group 1 4.11
Add Files to Group 'Source Group 1' 4.12

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 23 -

ME950

Mcu Development Kit User tutorial

4.11
8Asm Source file (*.s*; *.src; *.a*)
LED.ASMLED.ASMAddClose
LED.ASMSource Group 1 +

4.12
9LED.ASM 1.1

Demo
ORG
LJMP
ORG

0000H
MAIN
0050H

MOV

A,#0FEH

MAIN:
;

LOOP:
MOV
RL
LCALL
LJMP

P0,A
A
DELAY
LOOP

; P0.0 LED
;

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 24 -

ME950
DELAY:

Mcu Development Kit User tutorial

;
MOV

R7, #250

MOV

R6, #250

L1:
L2:
DJNZ
DJNZ
RET

R6, L2
R7, L1
;

END

1.1
10Options for target 4.7

4.13
Options for Target Target 1 4.14

4.14
Xtal CPU 11.0592M Xtal
11.0592
Output Create Hxe File
HEX 4.15

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 25 -

ME950

Mcu Development Kit User tutorial

4.15
11

0 Error(s) , 0

Warning(s). 4.16
1.1

4.16
Demo LED.HEX
Keil C51

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 26 -

ME950

Mcu Development Kit User tutorial

4.4
4.4.1
1
J1 JP1 40
JP1 POD52 POD52
INT POD52 11.0592MHz EXT
ME950

4.17
2
10PIN POD52 ME950 ICE/ISP J3
USB ME950 ME950 ( USB )
:

4.18

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 27 -

ME950

Mcu Development Kit User tutorial

3
ME950 ICE52
CPU 4.19

4.19
ME950 JP2(VTG)

4.4.2
1 4.1 Keil C51 Project

4.20 Keil

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 28 -

ME950
2 Keil

Mcu Development Kit User tutorial

Debug 4.21

SOFI ICE52D Emulator/Programmer , ICE52


, 4.2.2 4.21 .

4.21 Keil
3) Debug Settings ICE52
4.16
ICE52
0x003b 4.3.3
3 0x003b

4.22

ICE52

Options for Target

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 29 -

ME950

Mcu Development Kit User tutorial

, Keil 4.23

4.23

Debug , .
///

Keil 4.24
4.21 Keil USB

4.24

4.4.3
1
ICE52 19 ()()
Debug Insert/Remove Breakpoint
F9 .

4.25

19 Keil
Command :

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 30 -

ME950

4.26

Mcu Development Kit User tutorial

4.27

2
Debug
Debug

Run

Step

Step Over

Run to Cursor line

Reset CPU

Stop Running

()

3
Keil

Debug

Stop Running/
ICE52
003BH C

char code reserve [3] _at_ 0x3b;

//

0050H
ORG 0000H
LJMP
MAIN
ORG 0050H
MAIN:
;
51 EA
0:

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 31 -

ME950

4.28

Mcu Development Kit User tutorial

ICE52 Notice

4 RAM
CPU 51 768 RAM()MOVX
000H~2FFH RAM 2FFH
RAM
RAM RAM AUXR EXTRAM 1
AUXR
EXTRAM

MOVX
00H~2FFH

EXTRAM=0 ()

RAM

EXTRAM=1

MOVX
300H~FFFFH
RAM

RAM

5
POD52 , POD52 CPU ,

Keil Flash Download . ICE52


(POD52), Keil Flash Download , Keil
CPU , CPU
6

4.4.4 keil
ME950 Keil Keil
keil 51
keil
ME950 keil 51 AVR
SFISP
keil Project SFISP
4.2 KEIL C51 Keil AT89S52
1

Unitilies 4.29

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 32 -

ME950

4.29

Mcu Development Kit User tutorial

Keil

2 Use Target Driver for Flash Programming SOFI ICE52


Emulator/Programmer Settings ICE52 / 4.30
ME950 AT89S52
AT89S52[ISP] ISP

4.30

ICE52

3 AT89S52 ME950 ,
JP1MCU 51

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 33 -

ME950

Mcu Development Kit User tutorial

JP9 1602LCD 1602LCD


JP24 OFF

4 Keil

FlashDownload

(AT89S52)Keil 4.31

4.31 Keil
keil 4.32

4.32

SFISP ( keil SFISP


) SSTNXP(Philips)winbond ISP ME950

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 34 -

ME950

Mcu Development Kit User tutorial


5.1

LED

LED (light emitting diode)


LED

LED 10mA
LED R
REUFIF
E UF LED IF LED
1.42.1V, 520mA.
LED

1.
P0P2 LED 300ms 300ms
300ms

2.
CPU
ME830/ME850
CPUUnit
Unit
ME950 CPU
J4
40
39
38
37
36
35
34
33
32
31
30
29
28
27
26
25
24
23
22
21

5.1

VCC
P00
P01
P02
P03
P04
P05
P06
P07
EA
ALE
PSEN
P27
P26
P25
P24
P23
P22
P21
P20

Y1

P10
P11
P12
P13
P14
P15
P16
P17
RST
P30
P31
P32
P33
P34
P35
P36
P37
XTA

C41
C42
30pFx2

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20

U1

MCS51

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
NC
GND 20

ATmega8515

P10
P11
P12
P13
P14
P15
P16
P17
RST
P30
P31
P32
P33
P34
P35
P36
P37
XTA

40
39
38
37
36
35
34
33
32
31
30
29
28
27
26
25
24
23
22
21

VCC

P00
P01
P02
P03
P04
P05
P06
P07
EA
ALE
PSEN
P27
P26
P25
P24
P23
P22
P21
P20

R6
4.7K

ZIF-40

CPU

CPU 40Pin U1 5.1 51 AVR


89C51 51
AT89S521/52 8515 AVR ATmega8515L
Y1 J4 CPU TFT /SD
CPU RST 51AVR

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 35 -

ME950

Mcu Development Kit User tutorial

K9 CPU
ME950 CPU I/O P10 P1.0
P20 P2.0
CPU
5.2 LED CPU P0 P2

LED
ME850
LED8+8
8+8
ME950
LED
D00
D01

RP9
1K*4

P00
P01
P02
P03

D02
D03

P04
P05
P06
P07

D04
D05
D06

RP10
1K*4

D07
D20
D21

VCC3

RP12 1K*4

D22
D23
D24
D25
D26

JP9

D20
D21
D22
D23
D24
D25
D26
D27

VCC
P20
P21
P22
P23
P24
P25
P26
P27

RP11 1K*4

D27

VCC3

5.2

LED

RP9RP10RP11RP12
P0 P2 8
D00D07 D20D27 16 ME950

P0 P2 D00D07 D20D27
P0 P2 D00D07 D20D27

3.
JP9 9 D20D27 P2 VCC
1602LCD JP24 OFF 1602 LED

4.

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 36 -

ME950

Mcu Development Kit User tutorial

P0P2

P0P2
LED

300ms

P0P2
LED

300ms

5.3

EX1_LED

5.
Example_A51\EX1_LED
;*******************************************************************
;*
*
;* ME950 - LED
*
;*
*
;* P0P2 16 LED
*
;*
*
;* V1.0 (2011/06/11)
*
;* gguoqing (Email: gguoqing@willar.com)
*
;* www.sofi-tech.com() www.mcu01.com()*
;* willar@tom.com
*
;*
*
;*Copyright(C) All Rights Reserved
*
;*
*
;*
*
;*******************************************************************
ORG 0000H
AJMP MAIN
ORG 0050H
MAIN:
MOV
MOV

P0,#0FFH
P2,#0FFH

LOOP:
MOV P0,#00H
MOV P2,#00H
ACALL DELAY

;LED

MOV P0,#0FFH
MOV P2,#0FFH
ACALL DELAY

; LED

AJMP

; 300ms

; 300ms

LOOP

;-----------------------------------------------;
; 300ms (11.0592MHz)
;-----------------------------------------------DELAY:
MOV R5,#3

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 37 -

ME950

Mcu Development Kit User tutorial

DEL1:
MOV

R6,#200

MOV

R7,#230

DEL2:
DEL3:
DJNZ
DJNZ
DJNZ
RET

R7,DEL3
R6,DEL2
R5,DEL1

;
;
;

END

6. C
Example_C51\EX1_LED
/*******************************************************************
*
*
* ME950 - LED
*
*
*
* P0P2 8 LED
*
*
*
* V1.0 (2011/06/11)
*
* gguoqing (Email: gguoqing@willar.com)
*
* www.sofi-tech.com() www.mcu01.com() *
* willar@tom.com
*
*
*
*Copyright(C) All Rights Reserved
*
*
*
*
*
*********************************************************************/
#include <reg52.h>
char code reserve [3] _at_ 0x3b;

// 0x3b 3

/--------------------------------------------------------
---------------------------------------------------------/
void delayms(unsigned int ms)
{
unsigned char k;
while(ms--)
{
for(k = 0; k < 114; k++);
}
}
/--------------------------------------------------------
---------------------------------------------------------/
void main()
{
P0 = 0xff;
//
P2 = 0xff;
while(1)
{
P0 = 0x00;
P2 = 0x00;
delayms(300);
P0 = 0xff;
P2 = 0xff;
delayms(300);

//LED
// 300ms
// LED
// 300ms

}
}

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 38 -

ME950

Mcu Development Kit User tutorial

LED
1.
P0P2 LED

2.
5.1

3.
JP9 9 D20D27 P2 VCC
1602LCD JP24 OFF 1602 LED

4.

FEH

7FH

P0P2

P0P2

300ms

300ms

P0P2

P0P2

300ms

300ms

5.4

0755-84867757

EX2_LEDX8
www.sofi-tech.com

www.mcu01.com

- 39 -

ME950

Mcu Development Kit User tutorial

5.
Example_A51\EX2_LEDX8
;*******************************************************************
;*
*
;* ME950 - LED
*
;*
*
;* P0P2 8 LED
*
;*
*
;* V1.0 (2011/06/11)
*
;* gguoqing (Email: gguoqing@willar.com)
*
;* www.sofi-tech.com() www.mcu01.com()*
;* willar@tom.com
*
;*
*
;*Copyright(C) All Rights Reserved
*
;*
*
;*
*
;*******************************************************************
ORG 0000H
AJMP MAIN
ORG 0050H
;-----------------------------------------------MAIN:
MOV P0,#0FFH
;
MOV P2,#0FFH
LOOP:
MOV A,#0FEH
;
MOV R0,#08H
;
LOOPL:
;
MOV P0,A
;
MOV P2,A
RL A
;
ACALL DELAY
; 300ms
DJNZ R0,LOOPL
; 8
MOV P0,#0FFH
MOV P2,#0FFH
ACALL DELAY

MOV
MOV

;
;
;
;

A,#7FH
R0,#08H

LOOPR:
MOV P0,A
MOV P2,A
RR A
ACALL DELAY
DJNZ R0,LOOPR
MOV P0,#0FFH
MOV P2,#0FFH
ACALL DELAY
AJMP

; 300ms

;
; 300ms
; 8
;
; 300ms

LOOP

;-----------------------------------------------;
; 300ms (11.0592MHz)
;-----------------------------------------------DELAY:
MOV R5,#3
DEL1:
MOV R6,#200
DEL2:
MOV R7,#230
DEL3:
DJNZ R7,DEL3
;
DJNZ R6,DEL2
;
DJNZ R5,DEL1
;
RET
;-----------------------------------------------END
;
;------------------------------------------------

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 40 -

ME950

Mcu Development Kit User tutorial

6. C
Example_C51\EX2_LEDX8
/*******************************************************************
*
*
* ME950 - LED
*
*
*
* P0P2 8 LED
*
*
*
* V1.0 (2011/06/11)
*
* gguoqing (Email: gguoqing@willar.com)
*
* www.sofi-tech.com() www.mcu01.com() *
* willar@tom.com
*
*Copyright(C) www.willar.com All Rights Reserved *
*
*
*******************************************************************/
#include <reg52.h>
#include <intrins.h>
unsigned char scan_num;
char code reserve [3] _at_ 0x3b; // 0x3b 3
/---------------------------------------------------------
----------------------------------------------------------/
void delayms(unsigned int ms)
{
unsigned char k;
while(ms--)
{
for(k = 0; k < 114; k++);
}
}
/---------------------------------------------------------
----------------------------------------------------------/
void main(void)
{
unsigned char i;
P0 = 0xff;
//
P2 = 0xff;
while(1)
{
scan_num = 0xfe;

//

for(i = 0;i < 8;i++)


{
P0 = scan_num;
P2 = scan_num;
scan_num<<=1;
scan_num|=0x01;
delayms(300);
}
P0 = 0xff;
P2 = 0xff;
delayms(300);

//

scan_num = 0x7f;

//

for(i = 0;i < 8;i++)


{
P0 = scan_num;
P2 = scan_num;
scan_num >>=1;
scan_num|=0x80;
delayms(300);
}
P0 = 0xff;
P2 = 0xff;
delayms(300);

//

//
//
//"1"
// 300ms
// LED
// 300ms

//
//
//"1"
// 300ms
// LED
// 300ms

}
}

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 41 -

ME950

Mcu Development Kit User tutorial

1.

K1- K2-
K1 DL11
K2 DL11

2.

ME950
ME830/ME850

Relay

VCC

JP16
R29
4.7K

P36

Q6
8550
RY1

J12
1

D10
4148

DL11

2
3

R23 1K

5.5

C51 I/O

5.5 P36 0 Q6 RY1


DL11 P36 1 Q6 RY1 DL11

3.
JP16
JP8 8

4.

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 42 -

ME950

Mcu Development Kit User tutorial

K1

DL11

5.6

K2

DL11

EX3_RELAY

5.
Example_A51\EX3_RELAY
;********************************************************************
;*
*
;* ME950 -
*
;*
*
;* K1- K2-
*
;*
*
;* V1.0 (2011/08/16)
*
;* gguoqing (Email: gguoqing@willar.com)
*
;* www.sofi-tech.com() www.mcu01.com() *
;* willar@tom.com
*
;*
*
;*Copyright(C) All Rights Reserved
*
;*
*
;*
*
;********************************************************************
KEY_NEW EQU 40H
KEY_OLD EQU 41H
K1
K2
RELAY

BIT
BIT
BIT

P1.4
P1.5
P3^6

;
;
;

;---------------------------------------------------------ORG 0000H
AJMP MAIN
ORG 0050H
;---------------------------------------------------------;
;---------------------------------------------------------MAIN:
MOV SP,#60H
;
MOV P0,#0FFH
;
MOV P2,#0FFH
;
MOV KEY_OLD,#03H
;

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 43 -

ME950
KEY_CHK:

Mcu Development Kit User tutorial

;
;
;
;, KEY_CHK

ACALL SCAN_KEY
XRL A,KEY_OLD
JZ KEY_CHK
ACALL DELAY
ACALL SCAN_KEY
XRL A,KEY_OLD
JZ KEY_CHK

;
;

MOV
KEY_OLD,KEY_NEW
ACALL PROC_KEY
AJMP KEY_CHK

;--------------------------------------------------------;
; :
A ---
;--------------------------------------------------------SCAN_KEY:
CLR A
MOV C,K1
MOV ACC.0,C
MOV C,K2
MOV ACC.1,C
MOV KEY_NEW,A
; key_new=03H
RET
;--------------------------------------------------------;
;--------------------------------------------------------PROC_KEY:
MOV A,KEY_NEW
JNB ACC.0,PROC_K1
;K1
JNB ACC.1,PROC_K2
;K2
RET
PROC_K1:
; K1
CLR RELAY
;
RET
PROC_K2:
SETB
RET

; K2
;

RELAY

;--------------------------------------------------------; (10MS)
;--------------------------------------------------------DELAY:
MOV R6,#10
DEL1:
MOV
R7,#185
DEL2:
NOP
NOP
NOP
DJNZ R7,DEL2
DJNZ R6,DEL1
RET
;--------------------------------------------------------END

;---------------------------------------------------------

6. C
Example_C51\EX3_RELAY

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 44 -

ME950

Mcu Development Kit User tutorial

/*******************************************************************
*
*
* ME950 -
*
*
*
* K1- K2-
*
*
*
* V1.0 (2011/08/16)
*
* gguoqing (Email: gguoqing@willar.com)
*
* www.sofi-tech.com() www.mcu01.com() *
* willar@tom.com
*
*
*
*Copyright(C) www.willar.com All Rights Reserved *
*
*
*
*
*******************************************************************/
#include <reg52.h>
char code reserve[3]_at_ 0x3b; // 0x3b 3
sbit K1 = P1 ^ 4;
sbit K2 = P1 ^ 5;
sbit relay = P3 ^ 6;
unsigned char key_new, key_old;
/---------------------------------------------------------
----------------------------------------------------------/
void delayms(unsigned int ms)
{
unsigned char k;
while (ms--)
{
for (k = 0; k < 114; k++);
}
}
/-------------------------------------------------------
--------------------------------------------------------/
unsigned char scan_key()
{
key_new = 0x00;
key_new |= K2;
key_new <<= 1;
// 1
key_new |= K1;
return key_new;
// key_new=0x03
}
/---------------------------------------------------------
----------------------------------------------------------/
void main(void)
{
P0 = 0xff;
//
P2 = 0xff;
P1 = 0xf0;
// P1
key_old = 0x03;
//
relay = 1;
//
while (1)
{
scan_key();
if (key_new != key_old)
{
delayms(10);
scan_key();
if (key_new != key_old)
{
key_old = key_new;
if ((key_new &0x01) == 0)
relay = 0;
if ((key_new &0x02) == 0)
relay = 1;

//
//
//
//K1
//
//K2
//

}
}
}
}

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 45 -

ME950

Mcu Development Kit User tutorial

ME950

1.
300msP0 D00 D07
300msP0 D00 D07
300ms

2.
ME950

ME830/ME850

VCC

BELL

5.7

JP15

Q7
8550

B1

Buzzer

P37
R30
4K7

R31
10

I/O PNP
8550
P3.7 R30 Q7 B1 R31
Q7
Q7 R30 P3.7 P3.7 Q7
P3.7 Q7
P3.7 Q7
P3.7
P3.7
P3.7
ME950 KC-1206
Model Nunber
KC-1206
Rated Voltage (V)
5V
Operating Voltage (V)
4-8V

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 46 -

ME950
Max.Rated Current (mA)
Coil Resistance (DC) ()
Coil impedance(AC) ()
Min. Sound Pressure Level (dB/cm)
Resonant Frequency (Hz)
Perating Temperature ()
Weight (g)

Mcu Development Kit User tutorial

40mA
424
80
85db/10cm
2400
-20 - +60
2

KC-1206 2400 Hz KC-1206


2400 Hz
800 Hz

3.
JP15
JP9 VCCVCC3 VCC

4.

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 47 -

ME950

300ms

300ms

P3.7
D00 D07

P3.7=1
D00D07

615s

615s

-1=0?

-1=0?

Mcu Development Kit User tutorial

5.8

5.
Example_A51\EX4_BELL
;*******************************************************************
;*
*
;* ME950 -
*
;*
*
;*
*
;*
*
;* V1.1 (2011/07/04)
*
;* gguoqing (Email: gguoqing@willar.com)
*
;* www.sofi-tech.com() www.mcu01.com()*
;* willar@tom.com
*
;*
*
;*Copyright(C) All Rights Reserved
*
;*
*
;*
*
;*******************************************************************
BEEP BIT P3.7
ORG 0000H
AJMP MAIN
ORG 0050H
MAIN:
MOV
MOV
MOV

SP,#60H
P0,#0FFH
P2,#0FFH

MOV

R2,#10

; 300ms

MOV

R3,#49

LOOP1:
LOOP2:
LOOP3:
CPL BEEP
MOV P0,#7EH
ACALL DELAY
DJNZ R3,LOOP3
DJNZ R2,LOOP2

; 800Hz
; D00 D07
; 615us

MOV

; 300ms

R2,#10

LOOP4:

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 48 -

ME950
MOV

Mcu Development Kit User tutorial

R3,#49

LOOP5:
SETB BEEP
MOV P0,#0FFH
ACALL DELAY
DJNZ R3,LOOP5
DJNZ R2,LOOP4

;
;
; 615us

SJMP LOOP1
;---------------------------------------------------------; 615us
;---------------------------------------------------------DELAY:
MOV R7,#189
DEL:
NOP
DJNZ R7,DEL
RET
END

;---------------------------------------------------------;
;800Hz 1230us
;615-49-10=301350us=301ms
;----------------------------------------------------------

6. C
Example_C51\EX4_BELL
/*******************************************************************
*
*
* ME950 -
*
*
*
*
*
*
*
* V1.1 (2011/07/04)
*
* gguoqing (Email: gguoqing@willar.com)
*
* www.sofi-tech.com() www.mcu01.com() *
* willar@tom.com
*
*
*
*Copyright(C) www.willar.com All Rights Reserved *
*
*
*
*
********************************************************************/
#include <reg52.h>
#include <intrins.h>
sbit BEEP = P3 ^ 7;
char code reserve[3]_at_ 0x3b; // 0x3b 3
/--------------------------------------------------------310us
11.0592MHz
---------------------------------------------------------/
void delay(void)
{
unsigned char i;
for (i = 143; i > 0; i--)
;
}
/--------------------------------------------------------
---------------------------------------------------------/
void main(void)
{
unsigned int j;
P0 = 0xff; //
P1 = 0xff;
P2 = 0xff;

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 49 -

ME950

Mcu Development Kit User tutorial

while (1)
{
for (j = 490; j > 0; j--)
// 300ms
{
BEEP = ~BEEP; // 800Hz
P0 = 0x7E; // D00 D07
delay(); // 310us
delay(); // 310us
}
for (j = 490; j > 0; j--)
// 300ms
{
BEEP = 1; //
P0 = 0xff; //
delay(); // 310us
delay(); // 310us
}
}
}

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 50 -

ME950

Mcu Development Kit User tutorial

0-7

1.
0-7 8 07

2.

ME830/ME850
7-SEG Led Display
ME950
8

VCC2

c
dp

RP8 4.7K*4

RP6 1K*4

f
e

g
d

DIG5
a
b
c
dp

f
e

g
d

f
e

g
d

dp

b
c

f
e

DS2
DYP7_2

c
dp

dp

DS1
DPY7

f
e

Q20
8550

DIG2
a

dp g f e d c b a

Q21
8550

DIG3
a

DIG4
a
c

Q22
8550

12

Q23
8550

9
DIG6
a

VCC2

dp
g
f
e
d
c
b
a

DIG7
a

Q24
8550

DIG1
a

f
e

dp

g
d

DIG0
a
b
c
dp

c
dp

dp g f e d c b a
3
5
10
1
2
4
7
11

JP22

DIG0
DIG1
DIG2
DIG3
DIG4
DIG5
DIG6
DIG7

Q25
8550

3
5
10
1
2
4
7
11

VCC
P07
P06
P05
P04
P03
P02
P01
P00

JP21

Q26
8550

12

P20
P21
P22
P23
P24
P25
P26
P27

Q27
8550

RP7
4.7K*4

RP5 1K*4

5.9

ME950 8
5.9

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 51 -

ME950

Mcu Development Kit User tutorial

8 , 8 8 RP5RP6
AT89S52 P0 P0 () COM AT89S52 P2 (
) RP7RP8 Q20Q27 8 ()

2.1
8

2.2
a
b

f
g
e

c
dp
d

5.10

7 8
8
1
COM
10
a

dp

COM

5.11

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 52 -

ME950

Mcu Development Kit User tutorial

2
COM
01
a

dp

COM

5.12

dp

0C0H

0F9H

0A4H

0B0H

99H

92H

82H

0F8H

80H

90H

88H

83H

0C6H

0A1H

86H

8EH

1 00C0H P0 P2.0
P2.0 Q20 5V0
MOV P0,#0C0H
; P0
MOV P2,#0FEH
; P2.0

3.
JP21 8 P2
JP22 9
P0 VCC
JP24 OFF LCD1602

4.

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 53 -

ME950

Mcu Development Kit User tutorial

1
2
3
4
5

5.

(R0=40H)
(R1=FEH)
(R2=08H)

P0
P2

5.13 EX5_7SEG

6.
Example_A51\EX5_7SEG
;*******************************************************************
;* ME950 - 8
*
;* 8 0-7
*
;*
*
;* V1.0 (2011/07/20)
*
;* gguoqing (Email: gguoqing@willar.com)
*
;* www.sofi-tech.com() www.mcu01.com()*
;* willar@tom.com
*
;*
*
;*Copyright(C) All Rights Reserved
*
;*
*
;*******************************************************************

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 54 -

ME950

Mcu Development Kit User tutorial

DISSTART EQU 40H


;
LED_DATA EQU P0
;
;---------------------------------------------------------ORG 0000H
AJMP MAIN
ORG 0050H
;---------------------------------------------------------;
;---------------------------------------------------------MAIN:
MOV SP,#60H
MOV P0,#0FFH
;
MOV P2,#0FFH
MOV R2,#08H
;8
MOV R0,#DISSTART
MOV R1,#00H

MAIN1:
MOV
MOV
INC
INC
DJNZ

A,R1
@R0,A
R1
R0
R2,MAIN1

; 0-7
;

LOOP:
ACALL
SJMP

PLAY
LOOP

;---------------------------------------------------------;
;---------------------------------------------------------PLAY:
MOV R0,#DISSTART
;
MOV R1,#0FEH
;
MOV R2,#08H
; 8
DISP1:
MOV A,@R0
;
MOV DPTR,#TAB_NU
;
MOVC A,@A+DPTR
;
MOV LED_DATA,A
;
MOV P2,R1
;
MOV A,R1
;
RL A
MOV R1,A
;
INC R0
;
ACALL DELAY
;
DJNZ R2,DISP1
;8
MOV P2,#0FFH
;
RET
;
;--------------------------------------------------------;1MS
;--------------------------------------------------------DELAY:
MOV R6,#5
DEL1:
MOV R7,#93
DEL2:
DJNZ R7,DEL2
;
DJNZ R6,DEL1
;
RET
;--------------------------------------------------------;
;--------------------------------------------------------TAB_NU:
DB 0C0H,0F9H,0A4H,0B0H,099H,092H,082H,0F8H,080H
DB 090H,088H,083H,0C6H,0A1H,086H,08EH,0FFH
;--------------------------------------------------------END
;
;---------------------------------------------------------

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 55 -

ME950

Mcu Development Kit User tutorial

7. C
Example_C51\EX5_7SEG
/*******************************************************************
*
*
* ME950 - 8
*
*
*
* 8 0-7
*
*
*
* V1.0 (2011/07/20)
*
* gguoqing (Email: gguoqing@willar.com)
*
* www.sofi-tech.com() www.mcu01.com() *
* willar@tom.com
*
*
*
*Copyright(C) www.willar.com All Rights Reserved *
*
*
*
*
*******************************************************************/
#include <reg52.h>
#include <intrins.h>
char code reserve[3]_at_ 0x3b; // 0x3b 3
unsigned char code display[] =
{
0xC0, 0xF9, 0xA4, 0xB0, 0x99, 0x92, 0x82, 0xF8, 0x80, 0x90
};
/---------------------------------------------------------
----------------------------------------------------------/
void delayms( unsigned int ms )
{
unsigned char k;
while (ms--)
{
for (k = 0; k < 114; k++)
;
}
}
/---------------------------------------------------------
----------------------------------------------------------/
void main(void)
{
unsigned char k, shift;
P0 = 0xff;
P2 = 0xff;

//

while (1)
{
shift = 0xfe;
//
P2 = 0xff;
//
for (k = 0; k < 8; k++)
{
P0 = display[k];
//
P2 = shift;
//
shift = _crol_(shift, 1); //
delayms(1);
// 1ms
}
}
}
/----------------------------------------------------------/

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 56 -

ME950

Mcu Development Kit User tutorial

1.
LED
K1 - K8 P0 LED D00 - D07
K1 D00
......
K8 D07

2.

Push Button
ME830/ME850
ME950

P14
P15
P16
P17
P32
P33
P34
P35

JP8

K1
K2
K3
K4
K5
K6
K7
K8

K1

K1

P14

K5

K5

P32

K2

K2

P15

K6

K6

P33

P16

K7

K7

P34

P17

K8

K8

P35

K3
K4

K3
K4

5.14 ME950
ME950 8 K1K8 JP8 P14-P17P32P35
LED 5.1

3
JP8 8
JP9 VCC-VCC3 VCC D00-D07
JP15
PS2 JP12

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 57 -

ME950

Mcu Development Kit User tutorial

4.

Y
20ms

5.16 EX6_KEY

5.
Example_A51\EX6_KEY
;********************************************************************
;*
*
;* ME950 K1-K8
*
;*
*
;* LED
*
;*
*
;* V1.0 (2011/09/30)
*
;* gguoqing (Email: gguoqing@willar.com)
*
;* www.sofi-tech.com() www.mcu01.com() *
;* willar@tom.com
*
;*
*
;*Copyright(C) All Rights Reserved
*
;*
*
;*
*
;********************************************************************
BEEP BIT
P3.7
;--------------------------------------------------------ORG 0000H
AJMP MAIN
ORG 0050H
;--------------------------------------------------------MAIN:
MOV SP,#60H
MOV P2,#0FFH
LOOP0:
MOV P0,#0FFH
; LED
MOV P1,#0FFH
;
MOV P3,#0FFH
ACALL SCANKEY
CJNE A,#0FFH,LOOP1
AJMP LOOP0

LOOP1:
MOV R5,#2
ACALL DELAY

; 20ms

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 58 -

ME950
ACALL SCANKEY
CJNE A,#0FFH,LOOP2
AJMP LOOP0

Mcu Development Kit User tutorial

LOOP2:
MOV P0,A
ACALL BEEP_BL
AJMP LOOP0

;--------------------------------------------------------;
;--------------------------------------------------------SCANKEY:
MOV P1,#0FFH
;
MOV P3,#0FFH
MOV
MOV

R0,P1
R1,P3

MOV A,R0
ANL A,#0F0H
SWAP A
MOV R0,A
MOV A,R1
RL A
RL A
ANL A,#0F0H
ORL A,R0
RET

; P1
; P3
;
;
;(K1-K4)
;
;(K5-K8)
; A

;---------------------------------------------------------;
;
;
;---------------------------------------------------------BEEP_BL:
MOV R6,#200
BL1:
ACALL BL2
CPL BEEP
;
DJNZ R6,BL1
SETB BEEP
;
MOV R5,#15
; 150ms,
ACALL DELAY
RET
BL2:
MOV R7,#220
BL3:
NOP
DJNZ R7,BL3
RET
;---------------------------------------------------------;
;---------------------------------------------------------DELAY:
; R510MS
MOV R6,#50
DEL1:
MOV R7,#93
DEL2:
DJNZ R7,DEL2
DJNZ R6,DEL1
DJNZ R5,DELAY
RET
;--------------------------------------------------------END
;
;---------------------------------------------------------

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 59 -

ME950

Mcu Development Kit User tutorial

6. C
Example_C51\EX6_KEY
/*******************************************************************
*
*
* ME950 - K1-K8
*
*
*
* LED
*
*
*
* V1.0 (2011/09/29)
*
* gguoqing (Email: gguoqing@willar.com)
*
* www.sofi-tech.com() www.mcu01.com() *
* willar@tom.com
*
*
*
*Copyright(C) www.willar.com All Rights Reserved *
*
*
*
*
*******************************************************************/
#include <reg52.h>
char code reserve[3]_at_ 0x3b; // 0x3b 3
sbit BEEP = P3 ^ 7;
/**********************************************************

**********************************************************/
void delayms(unsigned int ms)
{
unsigned int t;
while (ms--)
{
for (t = 0; t < 114; t++)
;
}
}
/**********************************************************
x*0.14MS
**********************************************************/
void delayus(unsigned char x)
{
unsigned char i;
while (x--)
{
for (i = 0; i < 14; i++)
{
;
}
}
}
/**********************************************************

**********************************************************/
void beep()
{
unsigned char i;
for (i = 0; i < 200; i++)
{
delayus(6);
BEEP = !BEEP; //BEEP
}
BEEP = 1; //
delayms(150); //
}

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 60 -

ME950

Mcu Development Kit User tutorial

/**********************************************************

**********************************************************/
unsigned char scankey()
{
unsigned char keynum, keynum1, keynum2;
P1 = 0xff; //
P3 = 0xff; //
keynum1 = P1; // P1
keynum2 = P3; // P3
keynum1 = (keynum1 &0xf0) >> 4; //(K1-K4)
keynum2 = (keynum2 &0x3c) << 2; //(K5-K8)
keynum = keynum1 | keynum2; //
return (keynum);
}
/**********************************************************

**********************************************************/
void main()
{
unsigned char key;
P0 = 0xff; // LED
P2 = 0xff;
while (1)
{
key = scankey(); //
if (key != 0xff)
{
delayms(20); // 20ms
key = scankey(); //
if (key != 0xff)
{
P0 = key; //
beep();
}
}
P0 = 0xff; // LED
}
}
/*********************************************************/

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 61 -

ME950

Mcu Development Kit User tutorial

1.

K5 1 0
K6 1 1
3 255

2.
5.9 5.14

3.
JP21 8 DG0DG7 P2
JP22 9 ADP P0 VCC
JP8 8
1602LCD JP24 OFF 1602LCD 1602LCD

4.

INT0

INT1

INT0

INT1

5.17 EX7_KEY_INT

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 62 -

ME950

Mcu Development Kit User tutorial

5.
Example_A51\EX7_KEY_INT
;*******************************************************************
;*
*
;* ME950 - INT0 INT1
*
;*
*
;* 3 ( 255)
*
;*
*
;* V1.0 (2011/08/20)
*
;* gguoqing (Email: gguoqing@willar.com)
*
;* www.sofi-tech.com() www.mcu01.com()*
;* willar@tom.com
*
;*
*
;*Copyright(C) All Rights Reserved
*
;*
*
;*
*
;*******************************************************************
K5
K6

BIT
BIT

DISSTART
LED_DATA
COUNT

P3.2
P3.3
EQU
EQU
EQU

40H
P0
30H

;
;
;

;*******************************************************************
ORG
AJMP
ORG
AJMP
ORG
AJMP
ORG

0000H
MAIN
0003H
INT0_EX0
0013H
INT1_EX1
0050H

;*********************************************************
;
;*********************************************************
MAIN:
MOV SP,#60H
MOV P0,#0FFH
MOV P2,#0FFH
MOV COUNT,#00H
;
MOV

R0,#DISSTART

CLR1:
MOV @R0,#00H
;
INC R0
CJNE R0,#DISSTART+3,CLR1
;
;

CLR
SETB
CLR
SETB
SETB
SETB
SETB

IT0
IT0
IT1
IT1
EA
EX0
EX1

;INT0
;INT0
;INT1
;INT1

MAIN1:
ACALL
ACALL
AJMP

CONVT
PLAY
MAIN1

;*********************************************************
; INT0

()

;*********************************************************
INT0_EX0:
PUSH ACC
;
PUSH PSW
SETB RS0
;

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 63 -

ME950
CLR
CLR
INC

RS1
EX0
COUNT

MOV

R4,#70

Mcu Development Kit User tutorial

; INT0
; 1

EX0_PLAY:
MOV A,COUNT
ACALL CONVT
ACALL PLAY
DJNZ R4,EX0_PLAY

SETB EX0
POP PSW
POP ACC
RETI

; INT0
;

;*********************************************************
; INT1

()

;*********************************************************
INT1_EX1:
PUSH ACC
;
PUSH PSW
SETB RS0
;
CLR
RS1
CLR EX1
; INT1
DEC COUNT
; 1
MOV

R4,#70

EX1_PLAY:
MOV A,COUNT
ACALL CONVT
ACALL PLAY
DJNZ R4,EX1_PLAY

SETB EX1
POP PSW
POP ACC
RETI

; INT1
;

;*********************************************************
; (HEX TO BCD)
;*********************************************************
CONVT:
MOV A,COUNT
;
MOV B,#100
DIV AB
MOV DISSTART+2,A
; DISSTART+2
MOV A,#10
XCH A,B
DIV AB
MOV DISSTART+1,A
; DISSTART+1
MOV DISSTART,B
; DISSTART
MOV
CJNE
MOV
MOV
CJNE
MOV

A,DISSTART+2
A,#00H,CONVT1
DISSTART+2,#0AH
A,DISSTART+1
A,#00H,CONVT1
DISSTART+1,#0AH

; 0

CONVT1:
RET
;*********************************************************
;
;*********************************************************
PLAY:
MOV R0,#DISSTART
;
MOV R1,#0FEH
;

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 64 -

ME950
MOV R2,#03H

; 3

MOV A,@R0
MOV DPTR,#TAB_NU
MOVC A,@A+DPTR
MOV LED_DATA,A
MOV P2,R1
MOV A,R1
RL A
MOV R1,A
INC R0
ACALL DELAY1MS
DJNZ R2,DISP1
MOV P2,#0FFH
RET

;
;
;
;
;
;

Mcu Development Kit User tutorial

DISP1:

;
; 1 MS
;
;
;

;*********************************************************
;
;*********************************************************
DELAY1MS:
MOV R6,#5
DEL1:
MOV R7,#93
DJNZ R7,$
DJNZ R6,DEL1
RET
;*********************************************************
TAB_NU:
DB 0C0H,0F9H,0A4H,0B0H,099H,092H,082H,0F8H
DB 080H,090H,0FFH
;*********************************************************
END

;*********************************************************

6. C
Example_C51\EX7_KEY_INT
/************************************************************************
*
*
* ME950 - INT0 INT1
*
*
*
* 51 INT0 INT1 K5 K6 *
* 7
*
*
*
* INT0(K5) :
*
* INT1(K6) :
*
*
*
* V1.0 (2011/09/16)
*
* gguoqing (Email: gguoqing@willar.com)
*
* www.sofi-tech.com() www.mcu01.com()
*
* willar@tom.com
*
*
*
*Copyright(C) www.willar.com All Rights Reserved
*
*
*
*
*
************************************************************************/
#include < reg52.h >
#include <intrins.h>
unsigned char code LEDData[] =
{
0xC0, 0xF9, 0xA4, 0xB0, 0x99, 0x92, 0x82, 0xF8, 0x80, 0x90, 0xff
};
//

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 65 -

ME950

Mcu Development Kit User tutorial

unsigned char data display[3]; //


unsigned char code scan_bit[8] =
{
0xfe, 0xfd, 0xfb, 0xf7, 0xef, 0xdf, 0xbf, 0x7f
};
//
unsigned char count; //
char code reserve[3]_at_ 0x3b; // 0x3b 3
/********************************************************
*
*
*
*
*
*
********************************************************/
void delayms(unsigned int ms)
{
unsigned char k;
while (ms--)
{
for (k = 0; k < 114; k++)
;
}
}
/********************************************************

********************************************************/
void disp_count()
{
unsigned char n, temp;
temp = count;
for (n = 0; n <= 1; n++)
//
{
display[n] = temp % 10;
temp = temp / 10;
}
display[2] = temp; //
for (n = 2; n > 0; n--)
// 0
{
if (display[n] == 0)
display[n] = 0x0a;
else
break;
}
for (n = 0; n < 3; n++)
{
P0 = LEDData[display[n]]; //
P2 = scan_bit[n]; //
delayms(1);
P2 = 0xff; //
}
}
/********************************************************
*
*
*
*
*
*
********************************************************/
void main(void)
{
P0 = 0xff;
P1 = 0xff;
P2 = 0xff;

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 66 -

ME950
IT0 = 0; //
//
IT0=1;
IT1 = 0; //
//
IT1=1;

Mcu Development Kit User tutorial

//
//

EA = 1; //
EX1 = 1; // INT1
EX0 = 1; // INT0
while (1)
{
disp_count(); //
}
}
/********************************************************
*
*
* INT0
()
*
*
*
********************************************************/
void INT0_ISR(void)interrupt 0
{
unsigned char x;
EX0 = 0; // INT0
count++; // 1
for (x = 0; x < 70; x++)
//
{
disp_count();
}
EX0 = 1; // INT0
}
/********************************************************
*
*
* INT1
()
*
*
*
********************************************************/
void INT1_ISR(void)interrupt 2
{
unsigned char x;
EX1 = 0; // INT1
count--; // 1
for (x = 0; x < 70; x++)
//
{
disp_count();
}
EX1 = 1; // INT1
}
/********************************************************/

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 67 -

ME950

Mcu Development Kit User tutorial

1.
1
"-"

2.

ME830/ME850
4x4 Matrix Keypad
ME950
4x4

S1

S2

S3

S4

S5

S6

S7

S8

S9

S10

S11

S12

S13

S14

S15

S16

COL1
COL2
COL3
COL4
ROW1
ROW2
ROW3
ROW4

JP7

P10
P11
P12
P13
P14
P15
P16
P17

5.18

44
1
P1 P1 P1
P1
16

1
P1 P1.4P1.7 P1.0P1.3
P1 11010DH
P1 P1.4P1.7 P10P13
P1 1110E0H

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 68 -

ME950

Mcu Development Kit User tutorial

P0 EDH
15
2
16 1.5

3
1
2

3.
JP21 8 DG0DG7 P2
JP22 9 ADP P0 VCC
JP7 8 P1
JP6
JP24 OFF LCD1602

4.

P1

Y
10ms

5.19 EX8_KEY_4X4

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 69 -

ME950

Mcu Development Kit User tutorial

5.
Example_A51\ EX8_KEY_4X4
;*******************************************************************
;* ME950 - 4x4
*
;*
*
;*
*
;*
*
;* V1.1 (2011/07/02)
*
;* gguoqing (Email: gguoqing@willar.com)
*
;* www.sofi-tech.com() www.mcu01.com()*
;* willar@tom.com
*
;*
*
;*Copyright(C) All Rights Reserved
*
;*
*
;*
*
;*******************************************************************
;
;
;P1.0-P1.3 ,P1.4-P1.7 ;
;**********************************************************
BEEP
KEYNUM

BIT
EQU

P3.7
30H

ORG 0000H
AJMP MAIN
ORG 0050H
;**********************************************************
;
;**********************************************************
MAIN:
MOV SP,#60H
MOV KEYNUM,#10H
;"-"
ACALL KEY_PLAY
LOOP:
ACALL KEY_SCAN
AJMP LOOP
;**********************************************************
;
; 30H
;**********************************************************
KEY_SCAN:
MOV P1,#0F0H
; 0 1
MOV A,P1
; P1
ANL A,#0F0H
; 4
MOV B,A
;
MOV P1,#0FH
; 1 0
MOV A,P1
; P1
ANL A,#0FH
; 4
ORL A,B
;
CJNE A,#0FFH,KEY_IN1 ;0FFH
AJMP KEY_END
KEY_IN1:
MOV B,A
;
MOV DPTR,#KEYTABLE
;
MOV R3,#0FFH
;
KEY_IN2:
INC R3
; 1
MOV A,R3
MOVC A,@A+DPTR
;
CJNE A,B,KEY_IN3
;
MOV A,R3
;
MOV KEYNUM,A
;
ACALL KEY_PLAY
;
ACALL BEEP_BL
;
AJMP KEY_END
KEY_IN3:
CJNE A,#00H,KEY_IN2 ; ;00H
KEY_END:
RET

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 70 -

ME950

Mcu Development Kit User tutorial

;**********************************************************
;
;**********************************************************
KEYTABLE:
DB
DB
DB
DB

0EEH,0EDH,0EBH,0E7H,0DEH
0DDH,0DBH,0D7H,0BEH,0BDH
0BBH,0B7H,07EH,07DH,07BH
077H,00H
;00H

;**********************************************************
;;;
;**********************************************************
BEEP_BL:
MOV R6,#200
BL1:
ACALL BL2
CPL BEEP
;
DJNZ R6,BL1
SETB BEEP
;
MOV R5,#25
ACALL DELAY
RET
BL2:
MOV R7,#220
BL3:
NOP
DJNZ R7,BL3
RET
;**********************************************************
;
;**********************************************************
DELAY:
; R510MS
MOV R6,#50
DEL1:
MOV R7,#100
DJNZ R7,$
DJNZ R6,DEL1
DJNZ R5,DELAY
RET
;**********************************************************
;
;**********************************************************
KEY_PLAY:
MOV A,KEYNUM
;
MOV DPTR,#TABLE
;
MOVC A,@A+DPTR
;
MOV P0,A
; P0
CLR P2.0
;
RET
;**********************************************************
;
;**********************************************************
TABLE:
DB 0C0H,0F9H,0A4H,0B0H,99H,92H,82H,0F8H
DB 80H,90H,88h,83h,0c6h,0a1h,86h,8eh,0BFH ;0F,;**********************************************************
END
;
;**********************************************************

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 71 -

ME950

Mcu Development Kit User tutorial

6. C
Example_C51\ EX8_KEY_4X4
/*******************************************************************
*
*
* ME950 - 4x4
*
*
*
*
*
*
*
* V1.2 (2011/07/01)
*
* gguoqing (gguoqing@willar.com)
*
* www.sofi-tech.com() www.mcu01.com() *
* willar@tom.com
*
*
*
*Copyright(C) www.willar.com All Rights Reserved *
*
*
*
*
********************************************************************
*
*
*
*
* *
*
*
*
*
*
*
*******************************************************************/
#include <reg52.h>
#include <intrins.h>
sbit BEEP = P3 ^ 7; //
unsigned char key;
unsigned char code disp_code[] =
{
//
0xc0, 0xf9, 0xa4, 0xb0, 0x99, 0x92, 0x82, 0xf8, 0x80, 0x90, 0x88,
0x83, 0xc6, 0xa1, 0x86, 0x8e, 0xbf
};
unsigned char code key_code[] =
{
//
0xee, 0xed, 0xeb, 0xe7, 0xde, 0xdd, 0xdb, 0xd7, 0xbe, 0xbd, 0xbb,
0xb7, 0x7e, 0x7d, 0x7b, 0x77
};
char code reserve[3]_at_ 0x3b; // 0x3b 3
/**********************************************************

**********************************************************/
void delayms(unsigned int ms)
{
unsigned char t;
while (ms--)
{
for (t = 0; t < 114; t++)
;
}
}
/**********************************************************
x*0.14MS
**********************************************************/
void delayus(unsigned char x)
{
unsigned char i;
while (x--)
{

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 72 -

ME950

Mcu Development Kit User tutorial

for (i = 0; i < 14; i++)


{
;
}
}
}
/**********************************************************

**********************************************************/
void beep()
{
unsigned char i;
for (i = 0; i < 250; i++)
{
delayus(6);
BEEP = !BEEP; //BEEP
}
BEEP = 1; //
delayms(150); //
}
/**********************************************************

**********************************************************/
unsigned char keyscan()
{
unsigned char scan1, scan2, keycode, j;
P1 = 0xf0;
scan1 = P1;
if (scan1 != 0xf0)
//
{
delayms(10); // 10ms
scan1 = P1;
if (scan1 != 0xf0)
//
{
P1 = 0x0f;
scan2 = P1;
keycode = scan1 | scan2; //
for (j = 0; j < 16; j++)
{
if (keycode == key_code[j])
//
{
key = j;
return (key); //
}
}
}
}
else
P1 = 0xff;
return (key = 16); //
}
/**********************************************************

**********************************************************/
void main(void)
{
P0 = 0xbf; //"-"
P2 = 0xfe;
P1 = 0xff;

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 73 -

ME950

Mcu Development Kit User tutorial

while (1)
{
keyscan();
if (key < 16)
//
{
P0 = disp_code[key]; //
beep(); //
}
}
}
/*********************************************************/

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 74 -

ME950

Mcu Development Kit User tutorial

1602 LCD

1.
1602LCD
WELCOME TO
WWW.WILLAR.COM
ME950 MCU
DEVELOPMENT KIT

2.

LCD1602
ME850
ME950
1602LCD
1602 LCD

R28
1K

P00
P01
P02
P03
P04
P05
P06
P07

VCC

P20
P21

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

VSS
VDD
VL
RS
R/W
EN
D0
D1
D2
D3
D4
D5
D6
D7
BL+
BL-

www.willar.com
J5

JP25
VCC

ON OFF
JP24

Backlight

P22

5.20 1602LCD

3.
JP24 ON LCD1602
JP25 LCD1602

4.

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 75 -

ME950

Mcu Development Kit User tutorial

N
Y

Y
Y

RS=1
RW=0
E=1

N
RS=0
RW=0
E=1

E=0

E=0

5.21

5.22

0x38
162
857

5ms

0xc0

0x06

5ms

0x01

5ms

5ms

5.23

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 76 -

ME950

Mcu Development Kit User tutorial

RS=0
RW=1
E=1

BF

N
E=0

5.24

5.
Example_A51\EX9_LCD1602
/********************************************************************
*
*
* ME950 - LCD1602
*
*
*
* V1.0 (2011/08/12)
*
* gguoqing (gguoqing@willar.com)
*
* www.sofi-tech.com() www.mcu01.com() *
* willar@tom.com
*
*
*
*Copyright(C) www.willar.com All Rights Reserved *
*
*
*
*
*******************************************************************/
#include <reg52.h>
#include <intrins.h>
//#define uchar unsigned char
//#define uint unsigned int
#define DATA_PORT

P0

sbit LCD_RS = P2 ^ 0;
sbit LCD_RW = P2 ^ 1;
sbit LCD_EN = P2 ^ 2;
unsigned char code
{
"
WELCOME TO
};
unsigned char code
{
" WWW.WILLAR.COM
};

cdis1[] =
"
cdis2[] =
"

unsigned char code cdis3[] =


{
"
ME950 MCU
"
};
unsigned char code cdis4[] =

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 77 -

ME950

Mcu Development Kit User tutorial

{
"DEVELOPMENT KIT "
};
char code reserve[3]_at_ 0x3b; // 0x3b 3
/**********************************************************
us

(4.34us)

**********************************************************/
void delayNOP()
{
_nop_();
_nop_();
_nop_();
_nop_();
}
/**********************************************************
ms
**********************************************************/
void delayms(unsigned int ms)
{
unsigned char k;
while (ms--)
{
for (k = 0; k < 114; k++)
;
}
}
/**********************************************************
LCD
lcd_busy 1
lcd-busy 0 ,
**********************************************************/
void lcd_busy()
{
bit busy;
busy = 1;
while (busy)
{
LCD_RS = 0;
LCD_RW = 1;
LCD_EN = 1;
busy = (bit)(DATA_PORT &0x80);
delayNOP();
}
LCD_EN = 0;
}
/**********************************************************
LCD
RS=LRW=LEN D0-D7=
Check=1
**********************************************************/
void lcd_wcmd(unsigned char cmd, bit Check)
{
if (Check)
lcd_busy();
//
LCD_RS = 0;
LCD_RW = 0;
LCD_EN = 1;
DATA_PORT = cmd;

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 78 -

ME950

Mcu Development Kit User tutorial

delayNOP();
LCD_EN = 0;
}
/**********************************************************
LCD
RS=HRW=LEN D0-D7=
**********************************************************/
void lcd_wdat(unsigned char dat)
{
lcd_busy();
//
LCD_RS = 1;
LCD_RW = 0;
LCD_EN = 1;
DATA_PORT = dat;
delayNOP();
LCD_EN = 0;
}
/**********************************************************
LCD
**********************************************************/
void lcd_init()
{
delayms(15);
lcd_wcmd(0x38, 0); //16*2 5*7 8
delayms(5);
lcd_wcmd(0x38, 0); //
delayms(5);
lcd_wcmd(0x38, 0);
delayms(5);
lcd_wcmd(0x38,
delayms(5);
lcd_wcmd(0x0c,
delayms(5);
lcd_wcmd(0x06,
delayms(5);
lcd_wcmd(0x01,
delayms(5);

1); //
1); //
1); //
1); // LCD

}
/**********************************************************

**********************************************************/
void lcd_pos(unsigned char xpos, unsigned char ypos)
{
if (ypos == 0x01)
lcd_wcmd((xpos | 0x80), 1);
if (ypos == 0x02)
lcd_wcmd((xpos | 0xc0), 1);
}
/**********************************************************

**********************************************************/
void wr_string(unsigned char str[])
{
unsigned char num = 0;
while (str[num])
{
lcd_wdat(str[num++]);
delayms(150);
}

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 79 -

ME950

Mcu Development Kit User tutorial

}
/**********************************************************

**********************************************************/
void main()
{
P0 = 0xff; // P0
P2 = 0xff; // P2
delayms(100); //
lcd_init(); // LCD
while (1)
{
lcd_pos(0, 1); //
wr_string(cdis1);
lcd_pos(0, 2); //
wr_string(cdis2);
delayms(2000); // 2000ms
lcd_wcmd(0x01, 1); // LCD
delayms(5);
lcd_pos(0, 1); //
wr_string(cdis3);
lcd_pos(0, 2); //
wr_string(cdis4);
delayms(2000); // 2000ms
lcd_wcmd(0x01, 1); // LCD
delayms(5);
}
}
/*********************************************************/

6. C
Example_C51\EX9_LCD1602
/********************************************************************
*
*
* ME950 - LCD1602
*
*
*
* V1.0 (2011/08/12)
*
* gguoqing (gguoqing@willar.com)
*
* www.sofi-tech.com() www.mcu01.com() *
* willar@tom.com
*
*
*
*Copyright(C) www.willar.com All Rights Reserved *
*
*
*
*
*******************************************************************/
#include <reg52.h>
#include <intrins.h>
//#define uchar unsigned char
//#define uint unsigned int
#define DATA_PORT

P0

sbit LCD_RS = P2 ^ 0;
sbit LCD_RW = P2 ^ 1;
sbit LCD_EN = P2 ^ 2;
unsigned char code cdis1[] =

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 80 -

ME950

Mcu Development Kit User tutorial

{
"
WELCOME TO
"
};
unsigned char code cdis2[] =
{
" WWW.WILLAR.COM "
};
unsigned char code
{
"
ME950 MCU
};
unsigned char code
{
"DEVELOPMENT KIT
};

cdis3[] =
"
cdis4[] =
"

char code reserve[3]_at_ 0x3b; // 0x3b 3


/**********************************************************
us

(4.34us)

**********************************************************/
void delayNOP()
{
_nop_();
_nop_();
_nop_();
_nop_();
}
/**********************************************************
ms
**********************************************************/
void delayms(unsigned int ms)
{
unsigned char k;
while (ms--)
{
for (k = 0; k < 114; k++)
;
}
}
/**********************************************************
LCD
lcd_busy 1
lcd-busy 0 ,
**********************************************************/
void lcd_busy()
{
bit busy;
busy = 1;
while (busy)
{
LCD_RS = 0;
LCD_RW = 1;
LCD_EN = 1;
busy = (bit)(DATA_PORT &0x80);
delayNOP();
}
LCD_EN = 0;
}
/**********************************************************
LCD

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 81 -

ME950

Mcu Development Kit User tutorial

RS=LRW=LEN D0-D7=
Check=1
**********************************************************/
void lcd_wcmd(unsigned char cmd, bit Check)
{
if (Check)
lcd_busy();
//
LCD_RS = 0;
LCD_RW = 0;
LCD_EN = 1;
DATA_PORT = cmd;
delayNOP();
LCD_EN = 0;
}
/**********************************************************
LCD
RS=HRW=LEN D0-D7=
**********************************************************/
void lcd_wdat(unsigned char dat)
{
lcd_busy();
//
LCD_RS = 1;
LCD_RW = 0;
LCD_EN = 1;
DATA_PORT = dat;
delayNOP();
LCD_EN = 0;
}
/**********************************************************
LCD
**********************************************************/
void lcd_init()
{
delayms(15);
lcd_wcmd(0x38, 0); //16*2 5*7 8
delayms(5);
lcd_wcmd(0x38, 0); //
delayms(5);
lcd_wcmd(0x38, 0);
delayms(5);
lcd_wcmd(0x38,
delayms(5);
lcd_wcmd(0x0c,
delayms(5);
lcd_wcmd(0x06,
delayms(5);
lcd_wcmd(0x01,
delayms(5);

1); //
1); //
1); //
1); // LCD

}
/**********************************************************

**********************************************************/
void lcd_pos(unsigned char xpos, unsigned char ypos)
{
if (ypos == 0x01)
lcd_wcmd((xpos | 0x80), 1);
if (ypos == 0x02)
lcd_wcmd((xpos | 0xc0), 1);
}
/**********************************************************

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 82 -

ME950

Mcu Development Kit User tutorial

**********************************************************/
void wr_string(unsigned char str[])
{
unsigned char num = 0;
while (str[num])
{
lcd_wdat(str[num++]);
delayms(150);
}
}
/**********************************************************

**********************************************************/
void main()
{
P0 = 0xff; // P0
P2 = 0xff; // P2
delayms(100); //
lcd_init(); // LCD
while (1)
{
lcd_pos(0, 1); //
wr_string(cdis1);
lcd_pos(0, 2); //
wr_string(cdis2);
delayms(2000); // 2000ms
lcd_wcmd(0x01, 1); // LCD
delayms(5);
lcd_pos(0, 1); //
wr_string(cdis3);
lcd_pos(0, 2); //
wr_string(cdis4);
delayms(2000); // 2000ms
lcd_wcmd(0x01, 1); // LCD
delayms(5);
}
}
/*********************************************************/

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 83 -

ME950

Mcu Development Kit User tutorial

12864 LCD
1.
12864LCD 2

WWW.WILLAR.COM
ME950_
TEL:077584867757

2.

ME830/ME850
ME950
12864LCD LCD12864

128*64 LCD

J6

P25
P24
P23
P07
P06
P05
P04
P03
P02
P01
P00
P22
P21
P20

20
19
18
17
16
15
14
13
12
11
10
9
8
7
6
5
4
3
2
1

BLK
BLA
VEE
RSTB
CS2
CS1
DB7
DB6
DB5
DB4
DB3
DB2
DB1
DB0
E
R/W
D/I
VO
VDD
VSS

www.willar.com

R27
4.7K

R26
10K

VCC

5.25 LCD12864

3.
12864 J6 ST7920
ST7920

JP25 LCD1602 , JP24 OFF LCD1602


JP22 Vcc

4.

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 84 -

ME950

Mcu Development Kit User tutorial

RS=0
RW=0
E=1

RS=1
RW=0
E=1

E=0

E=0

5.26

5.27

RS=0
RW=1
E=1

BF

N
E=0

5.28

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 85 -

ME950

Mcu Development Kit User tutorial

PSB=1
8

LCD

0xc0

0x06

5ms

0x01

5ms

5ms

5.29 LCD

5.
Example_A51\EX10_LCD12864

6. C
Example_C51\EX10_LCD12864

12864LCD zimo221 Tool


Example_A51\EX10_LCD12864 Example_C51\EX10_LCD12864

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 86 -

ME950

Mcu Development Kit User tutorial

16x16 LED
1.
16X16

2.

RP13
4.7K*4

Q3
Q14

SRCLK

U7 74HC595

13

RCLK
12

SRCLK

SRCLR
10

SER

U6 74HC595

Q7

9
Q7

O0
O1
O2
O3
O4
O5
O6
O7

A
B
C
D
EN
SER
RCLK
SRCLK
VCC1

14

JP23

11

P20
P21
P22
P23
P24
P25
P26
P27
VCC

RP19
470*4
RP20
470*4

RP18
470*4

RP17
470*4

Q16
8550

RCLK

RP16
4.7K*4

13

E1
E2

ROW15
Q15
8550
ROW16

12

E3

15
14
13
12
11
10
9
7

15
1
2
3
4
5
6
7

4
5

Y0
Y1
Y2
Y3
Y4
Y5
Y6
Y7

SRCLR

A
B
C

DS2
LED16x16

RP15
4.7K*4

11

1
2
3

74LS138

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

U9

10

RP14
4.7K*4

VCC1

ROW2

Q2
8550

COL8
COL9
COL10
COL11
COL12
COL13
COL14
COL15
COL16

15
14
13
12
11
10
9
7

17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32

15
1
2
3
4
5
6
7

E3

Y0
Y1
Y2
Y3
Y4
Y5
Y6
Y7

ROW1
ROW2
ROW3
ROW4
ROW5
ROW6
ROW7
ROW8
ROW9
ROW10
ROW11
ROW12
ROW13
ROW14
ROW15
ROW16

SER

E1
E2

74LS138

ROW1

14

4
5

A
B
C

Q1
8550

COL1
COL2
COL3
COL4
COL5
COL6
COL7

U8
1
2
3

VCC1

O0
O1
O2
O3
O4
O5
O6
O7

ME830/ME850 16x16 LED Dot Matrix

ME950 16x16LED

5.29 16x16LED

3.
JP23 9 P2 VCC

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 87 -

ME950

Mcu Development Kit User tutorial

4.

5.30 EX11_LED16X16

5.
Example_A51\EX11_LED16X16
;********************************************************************
;*
*
;* ME950 -
*
;*
*
;* 1616LED
*
;*
*
;* V1.0 (2011/10/05)
*
;* gguoqing (gguoqing@willar.com)
*
;* www.sofi-tech.com() www.mcu01.com() *
;* willar@tom.com
*
;*
*
;*Copyright(C) All Rights Reserved
*
;*
*
;*
*
;********************************************************************
SDATA_595
SCLK_595
RCK_595

EQU
EQU
EQU

P2.5
P2.7
P2.6

;
;
;

G_74138

EQU

P2.4

ROW_END

BIT

COUN_COMP EQU

20H.0

30H

;**********************************************************

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 88 -

ME950
ORG
AJMP
ORG
AJMP

Mcu Development Kit User tutorial

0000H
MAIN
000BH
TIMER0

;**********************************************************
MAIN:
MOV SP,#70H
MOV
MOV
MOV
MOV
MOV
CLR
CLR

A,#0FFH
P1,A
P2,A
P3,A
P0,A
ROW_END
RCK_595

MOV
MOV
MOV
MOV

TMOD,#01H
TH0,#0FCH
TL0,#18H
IE,#82H

; 0 1
;1ms
; 0

MOV
MOV

DPTR,#TAB
R0,#00H

LCALL
AJMP

DISPLAY
MAIN1

MAIN1:

;**********************************************************
;
; R0 DPH
; R2
; B R1

R1 DPL
R3

;**********************************************************
DISPLAY:
MOV B,#00H
; 00
MOV R1,B
MOV COUN_COMP,#00H
D_LOOP:
MOV

R3,#5AH

D_LOOP1:
MOV R2,#00H
MOV R1,B
SETB TR0

; 0

JBC ROW_END,D_LOOP3
AJMP D_LOOP2

; 1

DJNZ

D_LOOP2:
D_LOOP3:
R3,D_LOOP1

MOV A,R1
MOV B,A
CJNE A,COUN_COMP,D_LOOP
MOV R1,#00H
INC R0
MOV A,R0
CJNE A,#2,D_LOOP4
MOV R0,#00H
MOV DPTR,#TAB
AJMP LOOPEND

;8
;
;

D_LOOP4:
INC DPH
MOV COUN_COMP,#32
AJMP D_LOOP

;, 9
;1 32

LOOPEND:
RET

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 89 -

ME950

Mcu Development Kit User tutorial

;**********************************************************
; T0
; R1

R2

;**********************************************************
TIMER0:
PUSH ACC
MOV
MOV

TH0,#0FCH
TL0,#18H

;1ms

INC R1
MOV A,R1
MOVC A,@A+DPTR
LCALL WR_595

DEC R1
MOV A,R1
MOVC A,@A+DPTR
LCALL WR_595

SETB G_74138
NOP
NOP
SETB RCK_595
NOP
NOP
CLR RCK_595

MOV
MOV
CLR

A,R2
P2,A
G_74138

;
;
;

INC
INC

R1
R1

INC
MOV
ANL
JNZ
SETB
CLR

R2
A,R2
A,#0FH
T0_END
ROW_END
TR0

;
;

;
;
;,
;

T0_END:
POP ACC
RETI
;**********************************************************
;
;**********************************************************
WR_595:
MOV R4,#08H
WR_LOOP:
RLC A
MOV SDATA_595,C
SETB SCLK_595
;
NOP
NOP
CLR SCLK_595
DJNZ R4,WR_LOOP
RET
;**********************************************************
TAB:
;
DB 0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH
DB 0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH
DB 0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH
DB 0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH
;

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 90 -

ME950
DB
DB
DB
DB
;
DB
DB
DB
DB
;
DB
DB
DB
DB
;
DB
DB
DB
DB

Mcu Development Kit User tutorial

0F7H,0FBH,002H,001H,0EFH,0DFH,0EFH,0BBH
0DEH,001H,0DAH,0FBH,0C0H,0DBH,09AH,0DBH
05AH,0DBH,0DAH,0DBH,0DAH,0DBH,0DAH,0DBH
0C3H,0DFH,0DBH,0A7H,0FFH,07BH,0FCH,0FDH
0FFH,0DFH,000H,00FH,0FFH,0DFH,0FFH,0DBH
0FFH,0D3H,0FFH,0CFH,0FFH,0DFH,0FFH,0CFH
0FFH,0D3H,0FFH,0DBH,0FFH,0DFH,0FFH,0DFH
0FFH,0EFH,0FFH,0EDH,0FFH,0F5H,0FFH,0FBH
0FBH,0EFH,0F1H,0EFH,007H,06FH,0F7H,0AFH
0F7H,0EFH,001H,06FH,0F7H,0AFH,0E3H,0EBH
0E5H,0E1H,0D6H,00FH,0D7H,0EFH,0B7H,0EFH
077H,0EFH,0F7H,0EFH,0F7H,0EFH,0F7H,0EFH
0EFH,0BFH,0EFH,0BFH,0EFH,0B7H,0ECH,003H
003H,0BFH,0EFH,0BFH,0EFH,0BFH,0ECH,007H
0E5H,0F7H,0CEH,0EFH,02EH,0EFH,0EFH,05FH
0EFH,0BFH,0EFH,04FH,0AEH,0F1H,0D9H,0FBH

;
DB
DB
DB
DB

0F7H,0BFH,0F7H,0BFH,0F7H,0BBH,0E8H,001H
0EFH,0BFH,0CFH,0B7H,0A8H,003H,06FH,0BFH
0EFH,0BBH,0E0H,001H,0EFH,0BBH,0EFH,0BBH
0EFH,0ABH,0EFH,0B7H,0EFH,0BFH,0EFH,0BFH

;
DB
DB
DB
DB

0EFH,0BFH,0EFH,0BFH,0DFH,0BBH,0DCH,001H
0B5H,0BBH,005H,0BBH,0EDH,0BBH,0DDH,0BBH
0BDH,05BH,005H,06BH,0FCH,0EBH,0FDH,0FBH
0E5H,0FBH,01DH,0FBH,0BDH,0EBH,0FDH,0F7H

;
DB
DB
DB
DB

0FDH,0FFH,0FDH,0FFH,0FDH,0EFH,080H,007H
0BDH,0EFH,0BDH,0EFH,080H,00FH,0BDH,0EFH
0BDH,0EFH,080H,00FH,0BDH,0EFH,0FDH,0FFH
0FDH,0FBH,0FDH,0FBH,0FEH,003H,0FFH,0FFH

;
DB
DB
DB
DB

0FFH,0FFH,0C0H,00FH,0FFH,0EFH,0FFH,0DFH
0FFH,0BFH,0FEH,07FH,0FEH,0FBH,000H,001H
0FEH,0FFH,0FEH,0FFH,0FEH,0FFH,0FEH,0FFH
0FEH,0FFH,0FEH,0FFH,0FAH,0FFH,0FDH,0FFH

;**********************************************************
END

;**********************************************************

6. C
Example_C51\EX11_LED16X16
/********************************************************************
*
*
* ME950 - -
*
*
*
* 1616LED
*
*
*
* V1.0 (2011/08/20)
*
* gguoqing (gguoqing@willar.com)
*
* www.sofi-tech.com() www.mcu01.com() *
* willar@tom.com
*
*
*
*Copyright(C) www.willar.com All Rights Reserved *
*
*
*
*
*******************************************************************/
#include <reg52.h>
#include <intrins.h>

//51
// _nop_();

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 91 -

ME950
#define BLKN 2
sbit
sbit
sbit
sbit

Mcu Development Kit User tutorial

//

G_74138 = P2 ^ 4;
SDATA_595 = P2 ^ 5;
RCK_595 = P2 ^ 6;
SCLK_595 = P2 ^ 7;

//
//
//
//

char code reserve[3]_at_ 0x3b; // 0x3b 3


unsigned char data dispram[32]; //
unsigned char temp;
unsigned char code Bmp[][32] =
{
{
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
}
, //
{
0xF7, 0xFB, 0x02, 0x01, 0xEF, 0xDF, 0xEF, 0xBB, 0xDE, 0x01, 0xDA, 0xFB,
0xC0, 0xDB, 0x9A, 0xDB, 0x5A, 0xDB, 0xDA, 0xDB, 0xDA, 0xDB, 0xDA, 0xDB,
0xC3, 0xDF, 0xDB, 0xA7, 0xFF, 0x7B, 0xFC, 0xFD
}
,

//

{
0xFF, 0xDF, 0x00, 0x0F, 0xFF, 0xDF, 0xFF, 0xDB, 0xFF, 0xD3, 0xFF, 0xCF,
0xFF, 0xDF, 0xFF, 0xCF, 0xFF, 0xD3, 0xFF, 0xDB, 0xFF, 0xDF, 0xFF, 0xDF,
0xFF, 0xEF, 0xFF, 0xED, 0xFF, 0xF5, 0xFF, 0xFB
}
,

//

{
0xFB, 0xEF, 0xF1, 0xEF, 0x07, 0x6F, 0xF7, 0xAF, 0xF7, 0xEF, 0x01, 0x6F,
0xF7, 0xAF, 0xE3, 0xEB, 0xE5, 0xE1, 0xD6, 0x0F, 0xD7, 0xEF, 0xB7, 0xEF,
0x77, 0xEF, 0xF7, 0xEF, 0xF7, 0xEF, 0xF7, 0xEF
}
,

//

{
0xEF, 0xBF, 0xEF, 0xBF, 0xEF, 0xB7, 0xEC, 0x03, 0x03, 0xBF, 0xEF, 0xBF,
0xEF, 0xBF, 0xEC, 0x07, 0xE5, 0xF7, 0xCE, 0xEF, 0x2E, 0xEF, 0xEF, 0x5F,
0xEF, 0xBF, 0xEF, 0x4F, 0xAE, 0xF1, 0xD9, 0xFB
}
,

//

{
0xf7, 0xbf, 0xf7, 0xbf, 0xf7, 0xbb, 0xe8, 0x1, 0xef, 0xbf, 0xcf, 0xb7, 0xa8,
0x3, 0x6f, 0xbf, 0xef, 0xbb, 0xe0, 0x1, 0xef, 0xbb, 0xef, 0xbb, 0xef,
0xab, 0xef, 0xb7, 0xef, 0xbf, 0xef, 0xbf
}
,

//

{
0xef, 0xbf, 0xef, 0xbf, 0xdf, 0xbb, 0xdc, 0x1, 0xb5, 0xbb, 0x5, 0xbb, 0xed,
0xbb, 0xdd, 0xbb, 0xbd, 0x5b, 0x5, 0x6b, 0xfc, 0xeb, 0xfd, 0xfb, 0xe5,
0xfb, 0x1d, 0xfb, 0xbd, 0xeb, 0xfd, 0xf7
}
,

//

{
0xfd, 0xff, 0xfd, 0xff, 0xfd, 0xef, 0x80, 0x7, 0xbd, 0xef, 0xbd, 0xef, 0x80,
0xf, 0xbd, 0xef, 0xbd, 0xef, 0x80, 0xf, 0xbd, 0xef, 0xfd, 0xff, 0xfd,
0xfb, 0xfd, 0xfb, 0xfe, 0x3, 0xff, 0xff
}
,

//

{
0xff, 0xff, 0xc0, 0xf, 0xff, 0xef, 0xff, 0xdf, 0xff, 0xbf, 0xfe, 0x7f, 0xfe,
0xfb, 0x00, 0x01, 0xfe, 0xff, 0xfe, 0xff, 0xfe, 0xff, 0xfe, 0xff, 0xfe,
0xff, 0xfe, 0xff, 0xfa, 0xff, 0xfd, 0xff

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 92 -

ME950

Mcu Development Kit User tutorial

} //
};
/**********************************************************

**********************************************************/
void delayms(unsigned int ms)
{
unsigned char k;
while (ms--)
{
for (k = 0; k < 114; k++)
;
}
}
/**********************************************************

**********************************************************/
void main(void)
{
unsigned char i, k;
RCK_595 = 1;
SCLK_595 = 0;
P2 = 0xF0;

//

TMOD = 0x01;
TH0 = 0xFC;
TL0 = 0x66;
IE = 0x82;
TR0 = 1;

// T0 1
//1ms
// T0
// T0

while (1)
{
for (k = 0; k < 9; k++)
//""
{
for (i = 0; i < 32; i++)
// 32
{
dispram[i] = Bmp[k][i]; //
}
delayms(1000);
//
}
}
}
/**********************************************************
74HC595
**********************************************************/
void WR_595(void)
{
unsigned char x;
for (x = 0; x < 8; x++)
{
temp = temp << 1; // CY
SDATA_595 = CY;
SCLK_595 = 1;
_nop_();
_nop_();
SCLK_595 = 0;

//

}
}
/**********************************************************

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 93 -

ME950

Mcu Development Kit User tutorial

**********************************************************/
void leddisplay(void) interrupt 1
{
unsigned char row, j = BLKN;
TH0 = 0xFC; //1ms
TL0 = 0x66;
row = P2; //
row = ++row &0x0f; // 1 4
G_74138 = 1; //
temp = dispram[row *BLKN + 1]; //
WR_595();
temp = dispram[row *BLKN]; //
WR_595();
P2 &= 0xf0; //
RCK_595 = 1; //
P2 |= row; //
RCK_595 = 0;
G_74138 = 0; //
}
/*********************************************************/

16x16LED 16x16 Tool


Example_A51\EX11_LED16X16 Example_C51\EX11_LED16X16

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 94 -

ME950

Mcu Development Kit User tutorial

RS232

1.

welcome to www.willar.com

2.

ME950
RS232 Interface
ME830/ME850
RS232 Interface
U3

J2
1
6
2
7
3
8
4
9
5

DB9

8
13
7
14

(RXD)
(TXD)

C12
0.1uF
C11
0.1uF
VCC

3
2
16

C10
0.1uF

R2 IN
R1 IN
T2 OUT
T1 OUT
C1+

R2 OUT
R1 OUT
T2 IN
T1 IN
C2+

C1 -

C2 -

V+
VCC

VGND

9
12

JP26

RXD
TXD

P30
P31

10
11
4
5
6
15

C13
0.1uF
C14
0.1uF

MAX232

5.31 RS232

3.
JP26 RXD-P3.0TXD-P3.1 RS232 MAX232C JP19
JP20
TTcom TT
1 TT
COM1 () 9600
8
None
1
2
3

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 95 -

ME950

5.32

Mcu Development Kit User tutorial

TT

4.

1
SCON=0x50
9600

SBUF
N

SBUF

TI=0

RI=0

5.33 EX12_UART

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 96 -

ME950

Mcu Development Kit User tutorial

5.
Example_A51\EX12_UART
;*******************************************************************
;*
*
;* ME950 -
*
;*
*
;* AT89S52
11.0592MHz
*
;*
*
;* V1.0 (2011/08/17)
*
;* gguoqing (Email: gguoqing@willar.com)
*
;* www.sofi-tech.com() www.mcu01.com()*
;* willar@tom.com
*
;*
*
;*Copyright(C) All Rights Reserved
*
;*
*
;*
*
;*******************************************************************
;*
*
;*
*
;*
*
;* 1
*
;* 2
*
;*
*
;******************************************************************/
ORG
AJMP
ORG

0000H
MAIN
0050H

;*********************************************************
;

;*********************************************************
MAIN:
MOV SP,#60H
MOV P0,#0FFH
MOV P2,#0FFH
MOV
MOV
MOV

TMOD,#20H
TH1,#0FDH
TL1,#0FDH

; 1 8 ,

MOV
ANL

SCON,#50H
PCON,#00H

; 1,
;

SETB
SETB

; 9600

EA
TR1

;
; 1

MOV R5,#100
ACALL DELAY
MOV DPTR,#TAB_ENG
ACALL SEND_STRING
MOV R5,#100
ACALL DELAY
MOV DPTR,#TAB_CHS
ACALL SEND_STRING
MOV R5,#100
ACALL DELAY
MOV A,#'O'
ACALL TXD_CHAR
MOV A,#'K'
ACALL TXD_CHAR
MOV A,#0AH
ACALL TXD_CHAR

;O
;K
;

LOOP:
ACALL RXD_CHAR
ACALL TXD_CHAR
AJMP
LOOP

;
;

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 97 -

ME950

Mcu Development Kit User tutorial

;*********************************************************
;
;*********************************************************
TXD_CHAR:
MOV SBUF,A
;
JNB TI,$
;
CLR TI
;
RET
;*********************************************************
;
;*********************************************************
RXD_CHAR:
JNB RI,$
;
MOV A,SBUF
;
CLR RI
;
RET
;**********************************************************
;
;**********************************************************
SEND_STRING:
CLR A
MOVC A,@A+DPTR
JZ S_END
; 00H ,
ACALL TXD_CHAR
INC DPTR
;
SJMP SEND_STRING
S_END:
RET
;*********************************************************
; 10MS
;*********************************************************
DELAY:
MOV R6,#50
DEL1:
MOV R7,#93
DEL2:
DJNZ R7,DEL2
DJNZ R6,DEL1
DJNZ R5,DELAY
RET
;**********************************************************
TAB_ENG:
DB "welcome to www.willar.com "
DB 0AH
;
DB 00H
TAB_CHS:
DB " "
DB 0AH
;
DB 00H
;*********************************************************
END

;*********************************************************

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 98 -

ME950

Mcu Development Kit User tutorial

6. C
Example_C51\EX12_UART
/********************************************************************
*
*
* ME950 -
*
*
*
* AT89S52
11.0592MHz
*
*
*
* V1.0 (2011/09/01)
*
* gguoqing (gguoqing@willar.com)
*
* www.sofi-tech.com() www.mcu01.com() *
* willar@tom.com
*
*
*
*Copyright(C) www.willar.com All Rights Reserved *
*
*
*
*
********************************************************************
*
*
*
*
*
*
* 1
*
* 2
*
*
*
*******************************************************************/
#include <reg52.h>
#include <intrins.h>
unsigned char code str1[] = " welcome to www.willar.com

\n ";

unsigned char code str2[] = " \n ";


unsigned char code reserve[3]_at_ 0x3b; // 0x3b 3
/**********************************************************

**********************************************************/
void delayms(unsigned int ms)
{
unsigned char k;
while (ms--)
{
for (k = 0; k < 114; k++)
;
}
}
/*********************************************************

*********************************************************/
void txdata(unsigned char dat)
{
SBUF = dat; //
while (!TI)
;
//
TI = 0; //
}
/*********************************************************

*********************************************************/
unsigned char rxdata()
{
unsigned char dat;
while (!RI)

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 99 -

ME950

Mcu Development Kit User tutorial

;
//
dat = SBUF; //
RI = 0; //
return (dat);
}
/********************************************************

/********************************************************/
void send_str(unsigned char str[])
{
unsigned char i = 0;
while (str[i] != '\0')
{
SBUF = str[i++];
while (!TI)
;
//
TI = 0; //
}
}
/*********************************************************

*********************************************************/
void main(void)
{
unsigned char buff;
P0 = 0xff;
P2 = 0xff;
SCON = 0x50; // 1
PCON = 0x00; //
TMOD = 0x20; // 1 8 ,
EA = 1;
TL1 = 0xfd;
TH1 = 0xfd; // 9600
TR1 = 1;
delayms(100);
send_str(str1); //
delayms(1000);
send_str(str2); //
delayms(1000);
txdata('O');
txdata('K');
txdata('\n'); //
delayms(1000);
while (1)
{
buff = rxdata(); //
txdata(buff);
//
}
}
/*********************************************************/

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 100 -

ME950

Mcu Development Kit User tutorial

74HC164

1.
TTL 74HC164
0 74HC164 8 DL0 DL7

2.

ME830/ME850
ME950
74HC164 74HC164

P30
P31
P12

JP20

1
2
DAT
CLK
MCLR
VCC

C29
0.1uF

8
9
14
7

U17

A
B
CLK
MR
VCC
GND

DL0
RP21
1.5K*4

Q0
Q1
Q2
Q3
Q4
Q5
Q6
Q7

3
4
5
6
10
11
12
13

DL2
DL3
DL4
DL5
RP22
1.5K*4

74HC164

DL1

DL6
DL7

5.34 74HC164

3.
JP20 74HC164 RXD-P3.0TXD-P3.1
JP6JP26MAX232
JP1974HC165

4.

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 101 -

ME950

Mcu Development Kit User tutorial

SCON=0x00

SBUF

TI=0

300ms

5.35

EX13_HC164

5.
Example_A51\EX13_HC164
;******************************************************************
;*
*
;* ME950 - 74HC164
*
;*
*
;* V1.0 (2011/08/06)
*
;* gguoqing (gguoqing@willar.com)
*
;* www.sofi-tech.com() www.mcu01.com()*
;* willar@tom.com
*
;*
*
;*Copyright(C) All Rights Reserved
*
;*
*
;*
*
;*******************************************************************
;*
*
;* 74HC164 *
;*
*
;*
*
;* 8
*
;*
*
;*******************************************************************
DATA_164
CLK_164
MR_164

BIT
BIT
BIT

P3.0
P3.1
P1.2

;RXD
;TXD
;MCLR

;**********************************************************
ORG 0000H
AJMP MAIN

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 102 -

ME950
ORG

Mcu Development Kit User tutorial

0050H

;**********************************************************
;
;**********************************************************
MAIN:
MOV SP,#60H
MOV

SCON,#00H

; 0

CLR MR_164
ACALL DELAY1MS
SETB MR_164

; 164

MOV
MOV

;
;8

MAIN1:
R0,#80H
R2,#08H

MAIN2:
ACALL WR_Byte
ACALL DELAY
MOV A,R0
RR
A
MOV R0,A
DJNZ R2,MAIN2

; 300ms
;
;
;

CLR MR_164
ACALL DELAY1MS
SETB MR_164

; 164

ACALL

; 300ms

AJMP

DELAY
MAIN1

;**********************************************************
;
;**********************************************************
WR_Byte:
MOV A,R0
;
MOV SBUF,A
;
W_WAIT:
JNB TI,W_WAIT
;
CLR TI
;
RET
;**********************************************************
;
(300ms)
;**********************************************************
DELAY:
MOV R5,#03
DEL1:
MOV R6,#200
DEL2:
MOV R7,#230
DEL3:
DJNZ R7,DEL3
DJNZ R6,DEL2
DJNZ R5,DEL1
RET
;**********************************************************
;
(1ms)
;**********************************************************
DELAY1MS:
MOV R6,#2
DEL4:
MOV R7,#230
DEL5:
DJNZ R7,DEL5
DJNZ R6,DEL4
RET
;**********************************************************
END
;
;**********************************************************

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 103 -

ME950

Mcu Development Kit User tutorial

6. C
Example_C51\EX13_HC164
/*******************************************************************
*
*
* ME950 - 74HC164
*
*
*
* V1.0 (2011/08/06)
*
* gguoqing (gguoqing@willar.com)
*
* www.sofi-tech.com() www.mcu01.com() *
* willar@tom.com
*
*
*
*Copyright(C) www.willar.com All Rights Reserved *
*
*
*
*
********************************************************************
*
*
* 74HC164 *
*
*
*
*
* 8
*
*
*
*******************************************************************/
#include <reg52.h>
#include <intrins.h>

//51
// _nop_();

sbit data_164 = P3 ^ 0;
sbit clk_164 = P3 ^ 1;
sbit mr_164 = P1 ^ 2;
char code reserve[3]_at_ 0x3b; // 0x3b 3
/**********************************************************
t
11.0592MHz 1ms
**********************************************************/
void delayms(unsigned int t)
{
unsigned char k;
while (t--)
{
for (k = 0; k < 114; k++)
;
}
}
/**********************************************************

**********************************************************/
void wr_byte(unsigned char num)
{
SBUF = num; //
while (!TI)
;
//
TI = 0; //
}
/**********************************************************

**********************************************************/
void main(void)
{
unsigned char n, temp;
SCON = 0x00; // 0

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 104 -

ME950

Mcu Development Kit User tutorial

mr_164 = 0; // 164
delayms(1);
mr_164 = 1;
while (1)
{
temp = 0x80; //
for (n = 0; n < 8; n++)
{
wr_byte(temp); //
delayms(300);
temp >>= 1; //
// temp=temp|0x80;
// 1
}
wr_byte(0x00); //
delayms(300);
}
}
/**********************************************************
temp=temp|0x80 8 LED
**********************************************************/

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 105 -

ME950

Mcu Development Kit User tutorial

74HC165

1.
TTL 74HC165
0 74HC165 8 2
P2 D20D27
P0 D00D07 P0 D00D07

2.

ME830/ME850
ME950
74HC165 74HC165
RP23
10K*4

RP24
10K*4

10

SW2

1
2
3
4
5
6
7
8

VCC

11
12
13
14
3
4
5
6

16
15
14
13
12
11
10
9

U18

Ds

VCC

D0
D1
D2
D3
D4
D5
D6
D7

GND
CE
PL
CP
Q7
Q7

16

C28

0.1uF

8
15
1
2
9
7

PL
CLK

JP19

P13
P31
P30

Q7

74HC165

SW DIP-8

5.36

74HC165

3.
JP19 74HC165 CPU RXD-P3.0TXD-P3.1
JP9 9 D20D27 P2 VCC
JP6JP26MAX232CJP2074HC164

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 106 -

ME950

Mcu Development Kit User tutorial

4.

P2

RI

P0=0xFF

P0

SBUF

5.37

EX14_HC165

5.
Example_A51\ EX14_HC165
;*******************************************************************
;*
*
;* ME950 -
*
;*
*
;*
*
;* V1.0 (2011/08/16)
*
;* gguoqing
*
;* www.sofi-tech.com() www.mcu01.com()*
;* willar@tom.com
*
;*
*
;*Copyright(C) All Rights Reserved
*
;*
*
;*
*
;*******************************************************************
;*
*
;* 74LS165 *
;*
*
;* :
*
;* ME500 D00-D07
*
;*
*
;*******************************************************************
DATA_165
CLK_165
LD_165

BIT
BIT
BIT

P3.0
P3.1
P1.3

;**********************************************************
ORG 0000H
AJMP MAIN
ORG 0050H
;**********************************************************
;
;**********************************************************
MAIN:

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 107 -

ME950
MOV
MOV
MOV

Mcu Development Kit User tutorial

SP,#6FH
P0,#0FFH
P2,#0FFH

MAIN1:
ACALL RD_BYTE
MOV B,A
MOV P2,A
ACALL DELAY10MS
ACALL RD_BYTE
CJNE A,B,MAIN1
MOV P0,A
AJMP MAIN1

;
; P2
;
;
;
; P0

;**********************************************************
;
;**********************************************************
RD_BYTE:
CLR LD_165
;
NOP
NOP
SETB LD_165
;
MOV

SCON,#10H

JNB
MOV
RET

RI, R_WAIT
A,SBUF

; 0 RI

R_WAIT:
; RI
;

;**********************************************************
;10MS
;**********************************************************
DELAY10MS:
MOV R6,#20
DEL1:
MOV R7,#250
DJNZ R7,$
DJNZ R6,DEL1
RET
;**********************************************************
END
;**********************************************************
;

; CLR

; MOV

RI

SCON,#11H

; RI , RX
; mode0,REN=1
;RI=1 RX

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 108 -

ME950

Mcu Development Kit User tutorial

6. C
Example_C51\EX14_HC165
/********************************************************************
*
*
* ME950 -
*
*
*
* V1.0 (2011/08/07)
*
* gguoqing (gguoqing@willar.com)
*
* www.sofi-tech.com() www.mcu01.com() *
* willar@tom.com
*
*
*
*Copyright(C) www.willar.com All Rights Reserved *
*
*
*
*
********************************************************************
*
*
* 74LS165 *
*
*
* :
*
* ME950 D00-D07
********************************************************************/
#include <reg52.h>
#include <intrins.h>

//51
// _nop_();

sbit DATA_165 = P3 ^ 0; //
sbit CLK_165 = P3 ^ 1; //
sbit LD_165
= P1 ^ 3; // P1^3 SH/LD
char code reserve[3]_at_ 0x3b; // 0x3b 3
/**********************************************************
t
11.0592MHz 1ms
**********************************************************/
void delayms(unsigned int t)
{
unsigned char k;
while (t--)
{
for (k = 0; k < 114; k++)
{
;
}
}
}
/***********************************************************

***********************************************************/
unsigned char ReadByte(void)
{
unsigned char RD_buf;
LD_165 = 0; //
delayms(1);
LD_165 = 1; //
SCON = 0x10; // mode0 RI
while (!RI)
;
// RI
RD_buf = SBUF; //
return (RD_buf); //
}
/**********************************************************

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 109 -

ME950

Mcu Development Kit User tutorial

**********************************************************/
void main(void)
{
unsigned char temp1, temp2;
P0 = 0xff;
P2 = 0xff;
while (1)
{
temp1 = ReadByte(); //
P2 = temp1; // P2
delayms(10);
temp2 = ReadByte(); //
if (temp1 == temp2)
//
P0 = temp2;
// P0
else
P0 = 0xff;
}
}
//*********************************************************

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 110 -

ME950

Mcu Development Kit User tutorial

1.

360 180

2.

ME950
Step Motor
ME830/ME850
6
5
4
3
2
1

J7
C30
0.1uF

Step Motor

U13
16
15
14
13
12
11
10
9

OUT1
OUT2
OUT3
OUT4
OUT5
OUT6
OUT7
COM

IN1
IN2
IN3
IN4
IN5
IN6
IN7
GND

1
2
3
4
5
6
7

VCC4

5V

JP6
A
B
C
D

P10
P11
P12
P13

ULN2003A

5.38

P1.0-P1.3 JP6 ULN2003 IN1-IN4 ULN2003


J7 ULN2003 COM COM1COM2
VCC 5.39
P1.0 ULN2003 IN1 ULN2003
OUT1 A
2.1 ME950
2 6
7.5
12V 5V
240g/cm

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 111 -

ME950

Mcu Development Kit User tutorial

80g/cm
3515mm
2.2
5.39 A-COM1-C B-COM2-D

A
COM1
C

5.39

COM2

3.
JP6 P1 VCC
JP6 P1.0-P1.3

4.

=8

360

P1

1000ms

180

1000ms

5.40

0755-84867757

5.41

www.sofi-tech.com

www.mcu01.com

- 112 -

ME950

Mcu Development Kit User tutorial

5.
Example_A51\EX15_Motor
;******************************************************************
;*
*
;* ME950 -
*
;*
*
;* V1.0 (2011/08/20)
*
;* gguoqing (Email: gguoqing@willar.com)
*
;* www.sofi-tech.com() www.mcu01.com()*
;* willar@tom.com
*
;*
*
;*Copyright(C) All Rights Reserved
*
;*
*
;*
*
;******************************************************************
;*
*
;* 7.5
*
;*
*
;*
*
;* A-AB-B-BC-C-CD-D-DA (, 3.75 )
*
;*
*
;******************************************************************
ORG 0000H
AJMP MAIN
ORG 0050H
;**********************************************************
MAIN:
MOV P0,#0FFH
;
MOV P2,#0FFH
MOV P1,#0F0H
LOOP:
MOV R3,#12
; 360 30*12=360
FFW:
ACALL MOTOR_F
DJNZ R3,FFW
MOV P1,#0F0H
ACALL DELAY1
MOV

;
; 2s

R3,#6

; 180 30*6=180

REV:
ACALL MOTOR_R
DJNZ R3,REV
MOV P1,#0F0H
ACALL DELAY1
AJMP LOOP

;
; 2s

;**********************************************************
; 30
; 3.75 ,8 30
;**********************************************************
MOTOR_F:
MOV R0,#00H
FFW1:
MOV A,R0
MOV DPTR,#TABLE_F
MOVC A,@A+DPTR
MOV P1,A
ACALL DELAY
INC R0
CJNE R0,#08H,FFW1
RET
;**********************************************************
; 30
; 3.75 ,8 30
;**********************************************************
MOTOR_R:
MOV R0,#00H
REV1:

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 113 -

ME950

Mcu Development Kit User tutorial

MOV A,R0
MOV DPTR,#TABLE_R
MOVC A,@A+DPTR
MOV P1,A
ACALL DELAY
INC R0
CJNE R0,#08H,REV1
RET
;**********************************************************
; ()
;**********************************************************
DELAY:
MOV R7,#14
DEL1:
MOV R6,#230
DEL2:
DJNZ R6,DEL2
DJNZ R7,DEL1
RET
;**********************************************************
; 2s
;**********************************************************
DELAY1:
MOV
R5,#20
DEL3:
MOV
R7,#200
DEL4:
MOV
R6,#230
DJNZ R6,$
DJNZ R7,DEL4
DJNZ R5,DEL3
RET
;**********************************************************
;
;**********************************************************
TABLE_F:
DB 0F1H,0F3H,0F2H,0F6H,0F4H,0FCH,0F8H,0F9H
;
DB 00
;
TABLE_R:
DB 0F9H,0F8H,0FCH,0F4H,0F6H,0F2H,0F3H,0F1H
;
DB 00
;
;**********************************************************
END

;**********************************************************

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 114 -

ME950

Mcu Development Kit User tutorial

6. C
Example_C51\EX15_Motor
/******************************************************************
*
*
* ME950
*
*
*
* V1.0 (2011/08/20)
*
* gguoqing (gguoqing@willar.com)
*
* www.sofi-tech.com() www.mcu01.com() *
* willar@tom.com
*
*
*
*Copyright(C) www.willar.com All Rights Reserved *
*
*
*
*
********************************************************************
*
*
* 7.5
*
*
*
*
*
* A-AB-B-BC-C-CD-D-DA (, 3.75 )
*
*
*
******************************************************************/
#include <reg52.h>
//51
#include <intrins.h>
// _nop_();
unsigned char
{
0xf1, 0xf3,
};
unsigned char
{
0xf9, 0xf8,
};

code FFW[8] =
0xf2, 0xf6, 0xf4, 0xfc, 0xf8, 0xf9
code REV[8] =
0xfc, 0xf4, 0xf6, 0xf2, 0xf3, 0xf1

char code reserve[3]_at_ 0x3b; // 0x3b 3


/**********************************************************
t
11.0592MHz 1ms
**********************************************************/
void delayms(unsigned int t)
{
unsigned char k;
while (t--)
{
for (k = 0; k < 114; k++)
;
}
}
/**********************************************************
( n*30 )
**********************************************************/
void motor_ffw(unsigned int n)
{
unsigned char i;
unsigned int j;
for (j = 0; j < n; j++)
// n*30
{
for (i = 0; i < 8; i++)
// 30
{
P1 = FFW[i]; //
delayms(8); //
}
}
P1 = 0xf0; //
}

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 115 -

ME950

Mcu Development Kit User tutorial

/**********************************************************
( n*30 )
**********************************************************/
void motor_rev(unsigned int n)
{
unsigned char i;
unsigned int j;
for (j = 0; j < n; j++)
// n*30
{
for (i = 0; i < 8; i++)
// 30
{
P1 = REV[i]; //
delayms(8); //
}
}
P1 = 0xf0; //
}
/**********************************************************

**********************************************************/
void main(void)
{
P1 = 0xf0; //
P0 = 0xff;
P2 = 0xff;
while (1)
{
motor_ffw(12); // 360
delayms(1000); //
motor_rev(6); // 180
delayms(1000); //
}
}
/*********************************************************/

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 116 -

ME950

Mcu Development Kit User tutorial

NE555

1.
C51 T0T1 NE555 LCD1602

1 C51 / 0
1S / 1 1S /
1

2.

ME830/ME850
ME950
NE555 NE555
R19
R18
1K

VCC

2K

C38
0.1uF

U15
7

VR2
200K

6
2

C21
2700pF

DIS

VCC

THR

TRIG

GND

CVolt

NE555

8
4
3

P35

OUT

JP3

C20
0.01uF

5.42 NE555

3.
JP24 ON LCD1602
JP25 LCD1602
JP3 NE555 P3.5T1
JP1724C04

4.

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 117 -

ME950

Mcu Development Kit User tutorial

TIMER0

TIMER1

1S?

Y
/

1S

ASCII
LCD1602

5.43

5.
Example_A51\EX16_NE555
;******************************************************************
;*
*
;* ME950 -
*
;*
*
;* LCD1602
*
;*
*
;* 12MHz
*
;*
*
;* V1.0 (2011/08/22)
*
;* gguoqing (Email: gguoqing@willar.com)
*
;* www.sofi-tech.com() www.mcu01.com()*
;* willar@tom.com
*
;*
*
;*Copyright(C) All Rights Reserved
*
;*
*
;*
*
;******************************************************************
LCD_RS
LCD_RW
LCD_EN
BUSY

BIT
BIT
BIT
BIT

DATAPORT EQU

P2.0
P2.1
P2.2
P0.7

LCD_X

P0

EQU

3FH

BUSY_CHECK

BIT

;LCD

; LCD
;LCD
20H.0

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 118 -

ME950
TIMER_H
TIMER_L
TIMCOUNT

EQU
EQU
EQU

30H
31H
32H

INT_G
INT_H
INT_L

EQU
35H
EQU
34H
EQU
33H

;
;
;

T_S
T_M
T_H
T_G

EQU
EQU
EQU
EQU

36H
37H
38H
39H

;
;
;
;

TEMP_H
TEMP_L

EQU
EQU

3AH
3BH

Mcu Development Kit User tutorial

;
;
;50ms

;**********************************************************
ORG 0000H
AJMP MAIN
ORG 000BH
AJMP TIMER_INT
ORG 001BH
AJMP TIMER1
ORG 0050H

;
; T0
; T1

;**********************************************************
MAIN:
MOV SP,#60H
; SP
ACALL PRO_SET
;
ACALL LCD_INIT
;LCD
MAIN1:
MOV B,#00H
MOV DPTR,#INFO1
; 1
ACALL W_STRING1
MOV B,#00H
MOV DPTR,#INFO2
; 2
ACALL W_STRING2
ACALL

TIMER_SET

MAIN2:
ACALL SBIN_SBCD
ACALL PLAY
AJMP MAIN2
;**********************************************************
INFO1:
INFO2:

DB
DB

"
CYMOMETER
",0
"FREQ:
HZ ",0

;LCD
;LCD

;**********************************************************
;
;**********************************************************
PRO_SET:
MOV P0,#0FFH
;
MOV P1,#0FFH
MOV P2,#0FFH
MOV A,#00H
MOV B,#00H
MOV 2AH,A

MOV INT_H,A
MOV INT_L,A
MOV INT_G,A
MOV T_S,A
MOV T_H,A
MOV T_M,A
MOV T_G,A
MOV TIMCOUNT,A
MOV TIMER_H,#04CH

; 50 MS

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 119 -

ME950
MOV TIMER_L,#10H
SETB P3.5
RET

Mcu Development Kit User tutorial

;P3.5
;T1(TIMER1

;**********************************************************
;
; 0 1, 1 1
;**********************************************************
TIMER_SET:
MOV TMOD,#51H
MOV TH0,TIMER_H
;
MOV TL0,TIMER_L
;
MOV TH1,#00H
; T1
MOV TL1,#00H
MOV IE,#8AH
; T0
SETB PT1
;TIMER1
SETB TR1
SETB TR0
;
RET
;**********************************************************
; LCD
;busy 1 busy 0 ,
;**********************************************************
LCD_BUSY:
MOV DATAPORT,#0FFH
BUSY_1:
CLR LCD_RS
SETB LCD_RW
CLR LCD_EN
NOP
SETB LCD_EN
JB BUSY,BUSY_1
CLR LCD_EN
RET
;**********************************************************
;LCD
;LCD_RS=L,LCD_RW=L,D0-D7=E=
; BUSY_CHECK =1,
;**********************************************************
WCOM:
JNB BUSY_CHECK,WCOM_1
ACALL LCD_BUSY
WCOM_1:
MOV
DATAPORT,A
;
CLR
LCD_RS
CLR
LCD_RW
NOP
SETB LCD_EN
NOP
CLR
LCD_EN
RET
;**********************************************************
;LCD
;LCD_RS=H,LCD_RW=L,D0-D7=E=
;**********************************************************
WDATA:
ACALL LCD_BUSY
MOV DATAPORT,A
;

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 120 -

ME950
SETB
CLR
NOP
SETB
NOP
CLR
RET

Mcu Development Kit User tutorial

LCD_RS
LCD_RW
LCD_EN
LCD_EN

;**********************************************************
; LCD
;**********************************************************
SET_X1:
MOV A,LCD_X
ORL A,#80H
ACALL WCOM
RET
;**********************************************************
; LCD
;**********************************************************
SET_X2:
MOV A,LCD_X
ORL A,#0C0H
ACALL WCOM
RET
;**********************************************************
; 1
;**********************************************************
W_STRING1:
MOV A,#80H
; LCD
ORL A,B
ACALL WCOM
;
ACALL FILL_CHAR
RET
;**********************************************************
; 2
;**********************************************************
W_STRING2:
MOV A,#0C0H
; LCD
ORL A,B
ACALL WCOM
;
ACALL FILL_CHAR
RET
;**********************************************************
;
;**********************************************************
FILL_CHAR:
CLR A
;
MOVC A,@A+DPTR
;
CJNE A,#0,F_CHAR
;
RET
F_CHAR:
ACALL WDATA
;
INC DPTR
; 1
AJMP FILL_CHAR
;
RET
;**********************************************************
; LCD

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 121 -

ME950

Mcu Development Kit User tutorial

;**********************************************************
LCD_INIT:
CLR BUSY_CHECK
;
MOV A,#38H
; 3
ACALL WCOM
ACALL DELAY1
MOV A,#38H
; 5*7
ACALL WCOM
ACALL DELAY1
MOV A,#38H
; 5*7
ACALL WCOM
ACALL DELAY1
SETB BUSY_CHECK
MOV A,#0CH
ACALL WCOM
ACALL DELAY1
MOV A,#06H
ACALL WCOM
ACALL DELAY1
MOV A,#01H
ACALL WCOM
ACALL DELAY1
RET

;
;
;
; LCD

;**********************************************************
; 5MS
;**********************************************************
DELAY1:
MOV R6,#25
DEL3:
MOV R7,#93
DEL4:
DJNZ R7,DEL4
DJNZ R6,DEL3
RET
;**********************************************************
; 0
;**********************************************************
TIMER_INT:
CLR TR0
;
PUSH ACC
MOV TL0,TIMER_L
;
MOV TH0,TIMER_H
;
INC TIMCOUNT
; 50msj
MOV A,TIMCOUNT
;
CPL P1.4
;
CJNE A,#20,T_END
; 1S
CLR TR1
MOV TIMCOUNT,#00H
MOV INT_L,TL1
MOV INT_H,TH1
MOV INT_G,2AH
MOV TH1,#00H
MOV TL1,#00H
MOV 2AH,#00H
SETB TR1

; T1
; 1S
;
;
;

T_END:
POP ACC
SETB TR0
RETI

;**********************************************************
;T1
; T1

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 122 -

ME950

Mcu Development Kit User tutorial

;**********************************************************
TIMER1:
INC 2AH
RETI
;**********************************************************
;
;**********************************************************
PLAY:
MOV A,#0C6H
;
ACALL WCOM
MOV A,T_H
ACALL CONV
MOV A,TEMP_H
ACALL WDATA
MOV A,TEMP_L
ACALL WDATA
MOV A,T_M
ACALL CONV
MOV A,TEMP_H
ACALL WDATA
MOV A,TEMP_L
ACALL WDATA
MOV A,T_S
ACALL CONV
MOV A,TEMP_H
ACALL WDATA
MOV A,TEMP_L
ACALL WDATA
RET
;**********************************************************
;
; A-( BCD )
; TEMP_H - ASCII TEMP_L - ASCII
;**********************************************************
CONV:
MOV B,#16
; BCD
DIV AB
ADD A,#30H
; ASCII
MOV TEMP_H,A
;
MOV A,B
ADD A,#30H
; ASCII
MOV TEMP_L,A
;
RET
;**********************************************************
; BCD
; INT_LINT_HINT_G
;BCD T_ST_MT_HT_G
;**********************************************************
SBIN_SBCD:
CLR A
;
MOV T_G,A
MOV T_H,A
;
MOV T_M,A
MOV T_S,A
MOV
MOV
MOV
MOV
CLR

R7,INT_L
;
R6,INT_H
R5,INT_G
R2,#24 ; 3()*8(bit)
C

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 123 -

ME950
SBIN_SBCD1:
MOV A,R7
RLC A
MOV R7,A

Mcu Development Kit User tutorial

MOV
RLC
MOV

A,R6
A
R6,A

MOV
RLC
MOV

A,R5
A
R5,A

MOV A,T_S
ADDC A,T_S
DA A
MOV T_S,A

;
;
;
;

MOV A,T_M
ADDC A,T_M
DA A
MOV T_M,A

;
;
;
;

MOV A,T_H
ADDC A,T_H
DA A
MOV T_H,A

;
;
;
;

MOV A,T_G
ADDC A,T_G
DA A
MOV T_G,A

;
;
;
;

DJNZ R2,SBIN_SBCD1

RET
;**********************************************************
END

;**********************************************************

6. C
Example_C51\EX16_NE555
/*******************************************************************
*
*
* ME950
*
*
*
* LCD1602
*
*
*
* 2011/09/17
*
* gguoqing (gguoqing@willar.com)
*
* www.sofi-tech.com() www.mcu01.com() *
* willar@tom.com
*
*
*
*Copyright(C) www.willar.com All Rights Reserved *
*
*
*
*
*******************************************************************/
#include <reg52.h>
#include <intrins.h>
sbit BEEP = P3 ^ 7; //
unsigned char code cdis1[] =
{
"
CYMOMETER
"
};
unsigned char code cdis2[] =

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 124 -

ME950

Mcu Development Kit User tutorial

{
"FREQ:

Hz "

};
sbit LCD_RS = P2 ^ 0;
sbit LCD_RW = P2 ^ 1;
sbit LCD_EN = P2 ^ 2;
bit sec = 0;
unsigned char
unsigned long
unsigned char
{
0x00, 0x00,
};

msec = 0, Hdata = 0, Ldata = 0, Count = 0;


temp = 0;
data display[] =
0x00, 0x00, 0x00, 0x00

char code reserve[3]_at_ 0x3b; // 0x3b 3


/*********************************************************
us

(4.34us)

*********************************************************/
void delayNOP()
{
_nop_();
_nop_();
_nop_();
_nop_();
}
/*********************************************************
ms
*********************************************************/
void delayms(unsigned int ms)
{
unsigned char n;
while (ms--)
{
for (n = 0; n < 114; n++)
;
}
}
/**********************************************************
*
*
* LCD
*
* lcd_busy 1
*
* lcd-busy 0 ,
*
*
*
**********************************************************/
bit lcd_busy()
{
bit result;
LCD_RS = 0;
LCD_RW = 1;
LCD_EN = 1;
delayNOP();
result = (bit)(P0 &0x80);
LCD_EN = 0;
return (result);
}
/**********************************************************
*
*
* LCD
*
*RS=LRW=LE=D0-D7=
*
*
*
**********************************************************/
void lcd_wcmd(unsigned char cmd)
{
while (lcd_busy())

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 125 -

ME950

Mcu Development Kit User tutorial

;
LCD_RS = 0;
LCD_RW = 0;
LCD_EN = 1;
P0 = cmd;
delayNOP();
LCD_EN = 0;
}
/**********************************************************
*
*
* LCD
*
*RS=HRW=LE=D0-D7=
*
*
*
**********************************************************/
void lcd_wdat(unsigned char dat)
{
while (lcd_busy())
;
LCD_RS = 1;
LCD_RW = 0;
LCD_EN = 1;
P0 = dat;
delayNOP();
LCD_EN = 0;
}
/**********************************************************
*
*
* LCD
*
*
*
**********************************************************/
void lcd_init()
{
delayms(15);
lcd_wcmd(0x38); //16*2 5*7 8
delayms(5);
lcd_wcmd(0x38);
delayms(5);
lcd_wcmd(0x38);
delayms(5);
lcd_wcmd(0x0c); //
delayms(5);
lcd_wcmd(0x06); //
delayms(5);
lcd_wcmd(0x01); // LCD
delayms(5);
}
/**********************************************************
*
*
*
*
*
*
**********************************************************/
void lcd_pos(unsigned char pos)
{
lcd_wcmd(pos | 0x80); //=80+
}
/**********************************************************
*
*
*
*
*
*
**********************************************************/
void play()
{
unsigned char n;
for (n = 0; n <= 4; n++)
//
{

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 126 -

ME950

Mcu Development Kit User tutorial

display[n] = temp % 10+0x30;


temp = temp / 10;
}
display[5] = temp + 0x30;
for (n = 5; n > 0; n--)
//"0"
{
if (display[n] == 0x30)
display[n] = 0x20;
else
break;
}
lcd_pos(0x46); //
for (n = 5; n != 0xff; n--)
lcd_wdat(display[n]);
}
/*********************************************************
*
*
*
*
*
*
*********************************************************/
void main()
{
unsigned char m;
unsigned long frq_num;
P3 = 0xff;
lcd_init();
lcd_pos(0x00); //
for (m = 0; m < 16; m++)
lcd_wdat(cdis1[m]);
//
lcd_pos(0x40); //
for (m = 0; m < 16; m++)
lcd_wdat(cdis2[m]);
//
TMOD = 0x51; // 0
// 1
TH0 = 0x4c; //50ms
TL0 = 0x00;
TH1 = 0x00; //
TL1 = 0x00;
ET0 = 1; // TIMER0
ET1 = 1; // TIMER1
EA = 1; //
PT1 = 1; // TIMER1
TR0 = 1;
TR1 = 1;
while (1)
{
if (sec)
{
Hdata = TH1; //
Ldata = TL1;
frq_num = ((Count *65535+Hdata * 256+Ldata) *108 / 100);
TH1 = 0;
TL1 = 0;
sec = 0;
Count = 0;
TR1 = 1;
TR0 = 1;
}
temp = frq_num;
play();
}
}
/**********************************************************

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 127 -

ME950

Mcu Development Kit User tutorial

*
*
* Time0
*
*
*
**********************************************************/
void Time0()interrupt 1
{
TH0 = 0x4c; //50ms
TL0 = 0x00;
msec++;
if (msec == 20)
//50*20=1S
{
TR0 = 0; // TIMER0
TR1 = 0; // TIMER1
msec = 0;
sec = 1; //
}
}
/**********************************************************
*
*
* Time1
*
*
*
**********************************************************/
void Time1()interrupt 3
{
Count++;
}
/*********************************************************/

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 128 -

ME950

Mcu Development Kit User tutorial

93C46

1.
0x00 8 "0-7" 0x00 8 8
8 8 0-7

2.
ME950
93C46
ME830/ME850
U11

VCC
8
7
6
5

93C46

93C46

VCC
NC
ORG
GND

CS
SK
DI
DO

CS
SK
DI
DO

1
2
3
4

JP14

P33
P34
P35
P36

5.44 93C46

3.
JP21 8 DG0DG7 P2
JP22 9 ADP P0 VCC
JP14 4 P3.3P3.6
JP3NE555 93C46
JP24 OFF LCD1602

4.

Indata
=0

Outdata
=0

DI=Indata&0x80
DB7DI

SK=1
SK=0

SK=1
SK=0

Outdata
Outdata+DO

Indata
+1

+1

=8

=8
Y

5.45 1

0755-84867757

5.46 1

www.sofi-tech.com

www.mcu01.com

- 129 -

ME950

1
DI = 1

CS=0;
DO=1;
CS=1;

Mcu Development Kit User tutorial

op_h

DO=1

op_l

Y
SK=1;
SK=0;

CS=0;

5.47

5.48

5.49

5.
Example_A51\EX17_93C46
;*******************************************************************
;*
*
;* ME950 - 93C46
*
;*
*
;* 8
*
;*
*
;* V1.0 (2011/09/20)
*
;* gguoqing (Email: gguoqing@willar.com)
*
;* www.sofi-tech.com() www.mcu01.com()*
;* willar@tom.com
*
;*
*
;*Copyright(C) All Rights Reserved
*
;*
*
;*
*
;*******************************************************************
;*
*
;* 93C46
*
;*
*

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 130 -

ME950

Mcu Development Kit User tutorial

;* ORG=0 8
*
;*
*
;* EWEN
*
;*
*
;******************************************************************/
CS
SK
DI
DO

BIT
BIT
BIT
BIT

P3.3
P3.4
P3.5
P3.6

ADDR
INDATA
DIS_BUFF

EQU
EQU
EQU

30H
31H
40H

OP_EWEN_H
OP_EWEN_L

EQU
EQU

00H
60H

; 00
; 11X XXXX

write enable
write enable

OP_EWDS_H
OP_EWDS_L

EQU
EQU

00H
00H

; 00
; 00X XXXX

disable
disable

OP_WRITE_H
OP_READ_H
OP_ERASE_H

EQU
EQU
EQU

40H
80H
0c0H

; 01 A6-A0
; 10 A6-A0
; 11 A6-A0

write data
read data
erase a word

OP_ERAL_H
OP_ERAL_L

EQU
EQU

00H
40H

; 00
; 10X XXXX

erase all
erase all

OP_WRAL_H
OP_WRAL_L

EQU
EQU

00H
20H

; 00
; 01X XXXX

write all
write all

;**********************************************************
ORG 0000H
AJMP MAIN
ORG 0050H
;**********************************************************
;
;**********************************************************
MAIN:
MOV
SP,#60H
;
CLR
CLR
SETB
SETB

CS
SK
DI
DO

ACALL EWEN
ACALL ERASE
CLR
MOV

;
;

A
ADDR,A

; 00H

WRITE_LP:
MOV
A,ADDR
MOV
DPTR,#TABLE
MOVC A,@A+DPTR
MOV R7,A
ACALL WRITE
INC
ADDR
MOV R4,ADDR
CJNE R4,#08H,WRITE_LP

ACALL EWDS

MOV
CLR
MOV

R0,#DIS_BUFF
A
ADDR,A

; R7
;
;8

; 00H

READ_LP:
ACALL READ
MOV
A,R7
MOV
@R0,A

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 131 -

ME950
INC R0
INC
ADDR
MOV R4,ADDR
CJNE R4,#08H,READ_LP

;
;

MOV
MOV
MOV

;
;8
;

Mcu Development Kit User tutorial

;8

LEDOUT1:
R0,#DIS_BUFF
R4,#08H
A,#0FEH

LEDOUT2:
MOV P0,@R0
MOV P2,A
INC R0
RL
A
ACALL DELAY1MS
DJNZ R4,LEDOUT2
MOV P2,#0FFH
SJMP LEDOUT1

;
;

;8
;

;**********************************************************
; addr
;**********************************************************
WRITE:
MOV indata,R7
;
MOV R5,ADDR
MOV R7,#OP_WRITE_H
;40H
ACALL INOP
;
MOV R7,indata
;
ACALL SHIN
ACALL BUSY
;
RET
;**********************************************************
; addr
;**********************************************************
READ :
MOV R5,ADDR
MOV R7,#OP_READ_H
;80H
ACALL INOP
;
ACALL SHOUT
;
CLR
CS
RET
;**********************************************************
;
;**********************************************************
EWEN:
MOV R5,#OP_EWEN_L
;60H
MOV R7,#OP_EWEN_H
;00H
ACALL INOP
CLR
CS
RET
;**********************************************************
;
;**********************************************************
EWDS:
MOV R5,#OP_EWDS_L
;00H
MOV R7,#OP_EWDS_H
;00H
ACALL INOP
CLR
CS
RET
;**********************************************************
;

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 132 -

ME950

Mcu Development Kit User tutorial

;**********************************************************
ERASE:
MOV R5,#OP_ERAL_L
;40H
MOV R7,#OP_ERAL_H
;00H
ACALL INOP
ACALL BUSY
RET
/*********************************************************

D0=0
D0=1
*********************************************************/
BUSY:
CLR CS
SETB DO
; 1
NOP
NOP
SETB CS
BUSY1:
JNB DO,BUSY1
;DO=0
CLR CS
RET
;**********************************************************
;
;R7
;R5 7 7
;**********************************************************
INOP:
CLR
SK
SETB DI
;"1"
SETB CS
;
NOP
NOP
SETB SK
;
NOP
NOP
CLR
SK
;
MOV
RLC
MOV
SETB
RLC
CLR
MOV
SETB
NOP
NOP
CLR

A,R7
A
DI,C
SK
A
SK
DI,C
SK

MOV
RLC
MOV
CLR
MOV

A,R5
A
R5,A
A
R7,A

MOV
RLC
MOV
MOV
SETB
NOP
NOP
CLR
INC
CJNE

A,R5
A
R5,A
DI,C
SK

; 7

SK

;
;

INOP_LP:

;
;

SK
R7
R7,#07H,INOP_LP

;7

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 133 -

ME950
SETB
RET

Mcu Development Kit User tutorial

DI

;**********************************************************
;
; R7_R6_
;**********************************************************
SHIN :
CLR
A
;
MOV
R6,A
MOV
A,R7
; R7
SHIN_LP:
RLC
A
MOV
DI,C
;
SETB SK
NOP
NOP
CLR
SK
INC
R6
CJNE R6,#08H,SHIN_LP
SETB DI
RET
;**********************************************************
;
; R7_R6_
;**********************************************************
SHOUT:
CLR
A
;
MOV
R6,A
SHOUT_LP:
SETB SK
NOP
NOP
CLR
SK
MOV
C,DO
;
RLC
A
INC
R6
CJNE R6,#08H,SHOUT_LP
MOV
R7,A
; R7
RET
;**********************************************************
; 1ms
;**********************************************************
DELAY1MS:
MOV R7,#2
DL3:
MOV R6,#230
DL4:
DJNZ R6,DL4
DJNZ R7,DL3
RET
;**********************************************************
TABLE:

DB

0C0H,0F9H,0A4H,0B0H,99H,92H,82H,0F8H,80H

;TABLE1:

DB

7EH,0BDH,0DBH,0E7H,0DBH,0BDH,7EH,0FFH

;**********************************************************
END

;**********************************************************

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 134 -

ME950

Mcu Development Kit User tutorial

6. C
Example_C51\EX17_93C46
/*******************************************************************
*
*
* ME950 - 93C46
*
*
*
* 8
*
*
*
* V1.0 (2011/09/20)
*
* gguoqing (gguoqing@willar.com)
*
* www.sofi-tech.com() www.mcu01.com() *
* willar@tom.com
*
*
*
*Copyright(C) www.willar.com All Rights Reserved *
*
*
*
*
********************************************************************
*
*
* 93C46
*
*
*
* ORG=0 8
*
*
*
* EWEN
*
*
*
*******************************************************************/
#include <reg52.h>
#include <intrins.h>
//define OP code
#define OP_EWEN_H
#define OP_EWEN_L

0x00 // 00
0x60 // 11X XXXX

write enable
write enable

#define OP_EWDS_H
#define OP_EWDS_L

0x00 // 00
0x00 // 00X XXXX

disable
disable

#define OP_WRITE_H
#define OP_READ_H
#define OP_ERASE_H

0x40 // 01 A6-A0
0x80 // 10 A6-A0
0xc0 // 11 A6-A0

write data
read data
erase a word

#define OP_ERAL_H
#define OP_ERAL_L

0x00 // 00
0x40 // 10X XXXX

erase all
erase all

#define OP_WRAL_H
#define OP_WRAL_L

0x00 // 00
0x20 // 01X XXXX

write all
write all

//define pin
sbit CS = P3
sbit SK = P3
sbit DI = P3
sbit DO = P3

^
^
^
^

3;
4;
5;
6;

unsigned char code dis_code[] =


{
0xc0, 0xf9, 0xa4, 0xb0, 0x99, 0x92, 0x82, 0xf8, 0x80
};
unsigned char data display[8];
char code reserve[3]_at_ 0x3b; // 0x3b 3
/*********************************************************

*********************************************************/
void delayms(unsigned int ms)
{
unsigned char i;
while (ms--)
{
for (i = 0; i < 114; i++)
;
}

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 135 -

ME950

Mcu Development Kit User tutorial

}
/*********************************************************

op_h op_l 7
op_h
op_l 7 7
*********************************************************/
void inop(unsigned char op_h, unsigned char op_l)
{
unsigned char i;
/************************************************

************************************************/
SK = 0;
DI = 1; //"1"
CS = 1; //
_nop_();
_nop_();
SK = 1; //
_nop_();
_nop_();
SK = 0; //
/************************************************
op_h

************************************************/
for (i = 0; i < 2; i++)
{
DI = (bit)(op_h &0x80);
SK = 1;
op_h <<= 1;
SK = 0;
}
/************************************************
op_l

************************************************/
for (i = 0; i < 7; i++)
{
DI = (bit)(op_l &0x40); //
SK = 1;
op_l <<= 1;
SK = 0;
}
DI = 1;
}
/*********************************************************

*********************************************************/
void shin(unsigned char indata)
{
unsigned char i;
for (i = 0; i < 8; i++)
{
DI = (bit)(indata &0x80); //
SK = 1;

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 136 -

ME950

Mcu Development Kit User tutorial

indata <<= 1;
SK = 0;
}
DI = 1;
}
/*********************************************************

*********************************************************/
unsigned char shout(void)
{
unsigned char i, out_data;
for (i = 0; i < 8; i++)
{
SK = 1;
out_data <<= 1; //
SK = 0;
out_data |= DO;
}
return (out_data);
}
/*********************************************************

D0=0
D0=1
*********************************************************/
void busy()
{
CS = 0;
DO = 1; // 1
_nop_();
CS = 1;
while (DO == 0)
//DO=0
{
SK = 1;
SK = 0;
}
CS = 0;
}
/*********************************************************

,CS .
*********************************************************/
void ewen()
{
inop(OP_EWEN_H, OP_EWEN_L);
CS = 0;
}
/*********************************************************

,CS .
*********************************************************/
void ewds()
{
inop(OP_EWDS_H, OP_EWDS_L);
CS = 0;
}
/*********************************************************

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 137 -

ME950

Mcu Development Kit User tutorial

*********************************************************/
void eral()
{
inop(OP_ERAL_H, OP_ERAL_L);
CS = 0;
busy(); //
}
/*********************************************************

*********************************************************/
/*
void erase(uchar addr)
{
inop(OP_ERASE_H, addr);
CS=0;
busy();
//
}
*/
/*********************************************************

*********************************************************/
/*
void wral(uchar indata)
{
eral();
//
inop(OP_WRAL_H, OP_WRAL_L);
shin(indata);
//
CS=0;
busy();
//
}
*/
/*********************************************************
indata addr
*********************************************************/
void write(unsigned char addr, unsigned char indata)
{
inop(OP_WRITE_H, addr); //
shin(indata); //
busy(); //
}
/*********************************************************
addr
*********************************************************/
unsigned char read(unsigned char addr)
{
unsigned char out_data;
inop(OP_READ_H, addr); //
out_data = shout(); //
CS = 0;
return (out_data);
}
/*********************************************************

*********************************************************/
void main(void)
{
unsigned char i, shift;
CS = 0; //

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 138 -

ME950

Mcu Development Kit User tutorial

SK = 0;
DI = 1;
DO = 1;
ewen(); //
eral(); //
for (i = 0; i < 8; i++)
// AT93C46
write(i, dis_code[i]);
ewds(); //
for (i = 0; i < 8; i++)
display[i] = read(i);
// AT93C46
while (1)
{
shift = 0xfe;
P2 = 0xff;
for (i = 0; i < 8; i++)
{
P0 = display[i];
P2 = shift;
shift = _crol_(shift, 1);
delayms(1); //
// delayms(400);
//
}
}
}
/*********************************************************/

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 139 -

ME950

Mcu Development Kit User tutorial

24C04

1.
0x00 8 "0-7" 0x00 8 8
8
8 0-7

2.
ME950
24C04
ME830/ME850
U10
1
2
3
4

24C04

24C04

A0
A1
A2
GND

VCC

VCC
WP
SCL
SDA

8
7
6
5

SCL
SDA

JP17

5.50

P34
P35

3.
JP21 8 DG0DG7 P2
JP22 9 ADP P0 VCC
JP17 2 P3.4P3.5
JP3NE555 24C04
JP24 OFF LCD1602
2

C51 I C I C

4.
iic_start

iic_stop

iic_ack

iic_noack

SDA=1

SDA=0

SDA=0

SDA=1

SCL=1

SCL=1

SCL=1
SCL

SCL=1
SCL

SDA=0
SDA

SDA=1
SDA

SCL=0

SCL=0

SCL=0

SCL=0

SDA=1

SDA=0

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 140 -

ME950
1

Indata
=0

Outdata
=0

SDA=Indata&0x80
DB7SDA

SCL=1

Mcu Development Kit User tutorial

Outdata
Outdata+SDA

SCL=1
SCL=0

SCL=0

Indata
+1
N

+1

=8

=8
Y

5.51 IIC

iic_start

iic_start

iic_start

0xA0

0xA0

0xA1

iic_ack

iic_ack

iic_ack

iic_ack

iic_ack

iic_noack
iic_stop

iic_stop
5.52

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 141 -

ME950

Mcu Development Kit User tutorial

5.
Example_A51\EX18_24C04
;*******************************************************************
;*
*
;* ME950 - 24C04
*
;*
*
;* 8
*
;*
*
;* V1.0 (2011/08/20)
*
;* gguoqing (Email: gguoqing@willar.com)
*
;* www.sofi-tech.com() www.mcu01.com()*
;* willar@tom.com
*
;*
*
;*Copyright(C) All Rights Reserved
*
;*
*
;*
*
;*******************************************************************
;*
*
;* 24C04
*
;*
*
;*******************************************************************
SDA BIT P3.5
SCL BIT P3.4
DISSTART
LED_DATA

EQU
EQU

; 24C04
; 24C04
40H
P0

;
;

;**********************************************************
ORG 0000H
AJMP MAIN
ORG 0050H
;**********************************************************
MAIN:
MOV SP,#60H
MOV P0,#0FFH
ACALL WRITE_DATA
; 24C04
MOV R4,#04H
; 20ms
ACALL DELAY_5MS
; 24C04
ACALL READ_DATA
LOOP:
ACALL PLAY
;
AJMP LOOP
;**********************************************************
; N
; 24C02
;**********************************************************
WRITE_DATA:
MOV R0,#00H
;
MOV R1,#8
; 8
MOV DPTR,#TAB_NU
;
WR_LOOP:
CLR A
MOVC A,@A+DPTR
MOV B,A
ACALL WRITE_BYTE
; 24C02
INC R0
;+1
INC DPTR
;+1
DJNZ R1,WR_LOOP
;8 ?
RET
;**********************************************************
; N
; 24C02
;**********************************************************
READ_DATA:

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 142 -

ME950
MOV R0,#00H
MOV R3,#8
MOV R1,#DISSTART

;
;

ACALL READ_BYTE
ACALL STOP
MOV @R1,A
INC R1
INC R0
MOV R4,#04H
ACALL DELAY_5MS
DJNZ R3,RD_LOOP
RET

; EEPROM

Mcu Development Kit User tutorial

RD_LOOP:
;
;+1
; 20ms

;**********************************************************
;
;: R0---B---
;**********************************************************
WRITE_BYTE:
ACALL START
MOV A,#0A0H
ACALL SENDBYTE
ACALL WAITACK
MOV A,R0
ACALL SENDBYTE
ACALL WAITACK
MOV A,B
ACALL SENDBYTE
ACALL WAITACK
ACALL STOP
MOV R4,#1
ACALL DELAY_5MS
RET

; 1 MS

;**********************************************************
;
;R0---,
;: A---
;**********************************************************
READ_BYTE:
ACALL START
MOV A,#0A0H
ACALL SENDBYTE
ACALL WAITACK
MOV A,R0
ACALL SENDBYTE
ACALL WAITACK
ACALL START
MOV A,#0A1H
ACALL SENDBYTE
ACALL WAITACK
ACALL RCVBYTE
RET
;**********************************************************
; IIC
;A--- A
;**********************************************************
RCVBYTE:
MOV R7,#08
; 8
CLR A
SETB SDA
; SDA

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 143 -

ME950

Mcu Development Kit User tutorial

R_BYTE:
CLR SCL
ACALL DELAY_5US
SETB SCL
ACALL DELAY_5US
MOV C,SDA
RLC A
SETB SDA
DJNZ R7,R_BYTE
RET

;
; SDA C
;
; SDA
; 8

;**********************************************************
; IIC
;A--- A
;**********************************************************
SENDBYTE:
MOV R7,#08
S_BYTE:
RLC A
MOV SDA,C
SETB SCL
ACALL DELAY_5US
CLR SCL
DJNZ R7,S_BYTE
;8 ?
RET
;**********************************************************
;
;
;**********************************************************
WAITACK:
CLR SCL
SETB SDA
; SDA
ACALL DELAY_5US
SETB SCL
ACALL DELAY_5US
MOV C,SDA
JC WAITACK
;SDA
CLR SDA
CLR SCL
RET
;**********************************************************
;
;**********************************************************
START:
SETB SDA
SETB SCL
ACALL DELAY_5US
CLR SDA
ACALL DELAY_5US
CLR SCL
RET
;**********************************************************
;
;**********************************************************
STOP:
CLR SDA
NOP
SETB SCL
ACALL DELAY_5US
SETB SDA
ACALL DELAY_5US
CLR SCL
CLR SDA

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 144 -

ME950

Mcu Development Kit User tutorial

RET
;**********************************************************
; 5US
;**********************************************************
DELAY_5US:
NOP
NOP
NOP
NOP
RET
;**********************************************************
; 5MS
;R4---R4*5MS
;**********************************************************
DELAY_5MS:
MOV R6,#10
DE_LP:
MOV R5,#250
DJNZ R5,$
DJNZ R6,DE_LP
DJNZ R4,DELAY_5MS
RET
;**********************************************************
;
;**********************************************************
PLAY:
MOV R0,#DISSTART
;
MOV R1,#0FEH
;
MOV R2,#08H
;8
DISP1:
MOV A,@R0
;
MOV LED_DATA,A
;
MOV P2,R1
;
MOV A,R1
;
RL A
MOV R1,A
;
INC R0
;
ACALL DELAY2MS
; 2 MS
DJNZ R2,DISP1
;8
MOV P2,#0FFH
;
RET
;
;**********************************************************
;
;**********************************************************
DELAY2MS:
MOV R6,#10
DEL1:
MOV R7,#93
DJNZ R7,$
DJNZ R6,DEL1
RET
;**********************************************************
TAB_NU:
DB 0C0H,0F9H,0A4H,0B0H,099H,092H,082H,0F8H
DB 080H,090H,0FFH,088H,083H,0C6H,0A1H,086H,08EH
;**********************************************************
END
;
;**********************************************************

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 145 -

ME950

Mcu Development Kit User tutorial

6. C
Example_C51\EX18_24C04
/*******************************************************************
*
*
* ME950 - 24C04
*
*
*
* 8
*
*
*
* 2011/08/20
*
* gguoqing (gguoqing@willar.com)
*
* www.sofi-tech.com() www.mcu01.com() *
* willar@tom.com
*
*
*
*Copyright(C) www.willar.com All Rights Reserved *
*
*
*
*
********************************************************************
*
*
* 0-7 24C04
*
*
*
*******************************************************************/
#include <reg52.h>
#include <intrins.h>
#define OP_WRITE 0xa0
#define OP_READ 0xa1

//
//

unsigned char data display[] =


{
0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0
};
unsigned char code sendbuf[] =
{
0xc0, 0xF9, 0xA4, 0xB0, 0x99, 0x92, 0x82, 0xF8, 0x80, 0x90
};
sbit SDA = P3 ^ 5;
sbit SCL = P3 ^ 4;
char code reserve[3]_at_ 0x3b; // 0x3b 3
/**********************************************************

(4.34us)

**********************************************************/
void delayNOP(void)
{
_nop_();
_nop_();
_nop_();
_nop_();
}
/**********************************************************

**********************************************************/
void delayms(unsigned int ms)
{
unsigned char k;
while (ms--)
{
for (k = 0; k < 114; k++)
;
}
}
/**********************************************************

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 146 -

ME950

Mcu Development Kit User tutorial

SCL SDA
**********************************************************/
void iic_start()
{
SDA = 1;
SCL = 1;
delayNOP();
SDA = 0;
delayNOP();
SCL = 0;
}
/**********************************************************

SCL SDA
**********************************************************/
void iic_stop()
{
SDA = 0;
SCL = 1;
delayNOP();
SDA = 1;
delayNOP();
SCL = 0;
}
/**********************************************************
IIC
**********************************************************/
void iic_init()
{
SCL = 0;
iic_stop();
}
/**********************************************************

SDA SCL
**********************************************************/
void iic_ack()
{
SDA = 0;
SCL = 1;
delayNOP();
SCL = 0;
SDA = 1;
}
/**********************************************************

SDA SCL
**********************************************************/
void iic_noack()
{
SDA = 1;
SCL = 1;
delayNOP();
SCL = 0;
SDA = 0;
}

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 147 -

ME950

Mcu Development Kit User tutorial

/**********************************************************

**********************************************************/
/*
bit iic_testack()
{
bit ack_bit;
SDA = 1;
SCL = 1;
delayNOP();
ack_bit = SDA;
SCL = 0;
delayNOP();

// SDA

return ack_bit; // AT24C04


}
*/
/**********************************************************

AT24C04 MCU
**********************************************************/
/*
unsigned char readbyte()
{
unsigned char i,read_data;
for(i = 0; i < 8; i++)
{
read_data <<= 1;
if(iic_testack())
read_data++;
}
return(read_data);
}
*/
/**********************************************************

AT24C04 MCU
**********************************************************/
unsigned char readbyte()
{
unsigned char i, read_data;
SDA = 1; // SDA
for (i = 0; i < 8; i++)
{
SCL = 1; // SDA
read_data <<= 1; //
if (SDA)
// SDA
read_data++;
SCL = 0; //
}
return (read_data);
}
/**********************************************************

MCU AT24C04
**********************************************************/

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 148 -

ME950

Mcu Development Kit User tutorial

void writebyte(unsigned char write_data)


{
unsigned char i;
for (i = 0; i < 8; i++)
// 8
{
SDA = (bit)(write_data &0x80); // SDA
SCL = 1;
delayNOP();
SCL = 0; //SDA
write_data <<= 1; //
}
}
/**********************************************************
addr N
**********************************************************/
void write_nbyte(unsigned char addr, unsigned char n)
{
unsigned char x;
iic_start();
writebyte(OP_WRITE); // 0xa0
iic_ack();
writebyte(addr); //
iic_ack();
while (n--)
{
writebyte(sendbuf[x++]); //
iic_ack();
delayms(1);
}
iic_stop(); //
}
/**********************************************************
addr N
**********************************************************/
void read_nbyte(unsigned char addr, unsigned char n)
{
unsigned char x = 0;
iic_start();
writebyte(OP_WRITE); // 0xa0
iic_ack();
writebyte(addr); //
iic_ack();
iic_start();
writebyte(OP_READ); // 0xa1
iic_ack();
while (n--)
{
display[x++] = readbyte(); //
iic_ack(); //
delayms(1);
}
iic_noack(); //
iic_stop(); //
}
/**********************************************************

**********************************************************/
void main(void)
{
unsigned char k, shift;

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 149 -

ME950

Mcu Development Kit User tutorial

iic_init();
write_nbyte(0, 8); // AT24C04
delayms(100); // 100ms
read_nbyte(0, 8); // AT24C04
while (1)
{
shift = 0xfe; //
P2 = 0xff; //
for (k = 0; k < 8; k++)
{
P0 = display[k]; //
P2 = shift; //
shift = _crol_(shift, 1); //
delayms(1); // 1ms
}
}
}
/**********************************************************/

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 150 -

ME950

Mcu Development Kit User tutorial

PCF8591 A/D

PCF8591 I2C 8 A/D D/A 4 A/D 1 D/A


A/D D/A A/D
I2C Philips SDASCL
CPU I2C

A/D PCF8591 I2C A/D


CPU SCL SDA

1.
4 A/D IN0 VR1
IN1IN2 IN3 J13 <=5V
D/A IN0 A/D D/A DL10 D/A
LCD1602 A/D IN0 A/D D/A

2.

ME950
AD/DA Convert AD/DA
ME830/ME850

Convert

VCC

U12
VR1
10K

IN0
IN1
IN2
IN3

J13

AOUT

1
2
3
4
5
6
7
8

AIN0
AIN1
AIN2
AIN3
A0
A1
A2
VSS

VDD
AOUT
VREF
AGND
EXT
OSC
SCL
SDA

16
15
14
13
12
11
10
9

C33

0.1uF
R25

470
SCL
SDA

JP4

P10
P11

DL10

PCF8591T
JP5

5.53 ADC/DAC(PCF8591)

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 151 -

ME950

Mcu Development Kit User tutorial

3.
JP24 ON LCD1602
JP25 LCD1602
JP4 P1.0P1.1
JP5 DL10LED D/A
IN1IN2IN3 J13

4.

check_ACK

A/D

iic_start

SDA=1

SCL=1

0x90

slave_ACK

check_ACK

IN0
slave_ACK

F0=0
N

SDA=1?

0x04

IN1
slave_ACK

Y
F0=1

check_ACK

IN2
slave_ACK

SCL=0

iic_start

IN3
slave_NOACK

0x91

iic_stop

check_ACK

5.54 A/D

0755-84867757

5.55

www.sofi-tech.com

www.mcu01.com

- 152 -

ME950
D/A

check_ACK

iic_start

0x90

check_ACK

check_ACK

iic_stop

D/A
0x40

Mcu Development Kit User tutorial

5.56 D/A
IIC EX17_24C04

5.
Example_A51\EX19_ADC

6. C
Example_C51\EX19_ADC

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 153 -

ME950

Mcu Development Kit User tutorial

PCF8591 D/A

1.
D/A
K2 K3 K4
LCD1602
DL10LED JP5

2.
5.53
3.
JP24 P2.2-EN LCD1602
JP25 LCD1602
JP4 P1.0P1.1
JP5 DL10 D/A LED
JP5

4.
D/A

check_ACK

iic_start

0x90

check_ACK

check_ACK

iic_stop

D/A
0x40

5.57 D/A

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 154 -

ME950

Mcu Development Kit User tutorial

SIN

Square

Triangle

=0

D/A1

=0

-1

100ms

D/A

D/A

+1

=0

D/A

SIN
+1

D/A0
D/A
100ms
N

=256

=255

5.58

5.
Example_A51\EX20_DAC

6. C
Example_C51\EX20_DAC

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 155 -

ME950

Mcu Development Kit User tutorial

DS1302

DS1302 DALLAS RAM


2.5V5.5V CPU
RAM DS1302 318
RAM DS1302 /

1.
DS1302 /
LCD1602 DS1302
K1 K4 DS1302

2.
DS1302
colock
ME830/ME850
ME950
DS1302
Clock
C26
220uF/10V

VCC
C27

0.1uF
Y2
32678Hz

U14

1
2
3
4

VCC2 VCC1
X1
SCLK
X2
I/O
GND
RST

8
7
6
5

SCLK
I/O
RST

JP18

P10
P11
P12

DS1302

5.59 DS1302

3.
JP24 ON LCD1602
JP25 LCD1602
JP18 P1.0P1.2

4.

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 156 -

ME950

Mcu Development Kit User tutorial

Indata
=0

Outdata
=0

SCL=0

SCL=0

Indata
IO=CY

Outdata
IO=1
Outdata | 0x80

SCL=1
SCL=1
+1
+1

=8
Y

=8

5.60 1

RESET=0
SCL=0
RESET=1

RESET=0
SCL=0
RESET=1

addr

addr

indata

outdata

SCL=1
RESET=0

SCL=1
RESET=0

5.61 1

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 157 -

ME950

Mcu Development Kit User tutorial

DS1302
LCD1602

DS1302
/

K1K4

LCD1602

Y
/
DS1302

5.62

5.
Example_A51\EX21_DS1302

6. C
Example_C51\EX21_DS1302

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 158 -

ME950

Mcu Development Kit User tutorial

DS18B20

DS18B20Dallas(One-wire)

DS18B20
-55 125
9 12

9 0.5 12 0.0625
9 93.75 ms12 750ms


1.
DS18B20 6
DS18B20

2.
ME830/ME850
1-Wire Temperature
ME950
1-Wire Temperature
DALLAS

VCC

18B20

JP11

R21
10K

P33

1 2 3

J8

1. GND
2. DQ
3. VDD

3
2
1

CON3

1 2 3

TO-92

5.63 DS18B20

3.
JP21 8 DG0DG7 P2
JP22 9 ADP P0 VCC
JP11 DS18B20 P3.3
JP24 OFF LCD1602

4.

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 159 -

ME950

Mcu Development Kit User tutorial

18B20

18B20

ROM
(0xCC)

presence==0

ROM
(0xCC)
Y

(0x44)

(0xBE)

5.64

5.65

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 160 -

ME950

Mcu Development Kit User tutorial

Indata
=8

Outdata
=8

<15s

<15s

Indata>>1
CYDQ

Outdata>>1
DQ=1
Outdata | 0x80

>45s
>45s

>1s
N

-1=0 ?
Y

>1s
N

-1=0 ?
Y

5.66

5.
Example_A51\EX22_DS18B20
;*******************************************************************
;*
*
;* ME950 - DS18B20
*
;*
*
;* 6
*
;*
*
;* V1.0 (2011/08/24)
*
;* gguoqing (Email: gguoqing@willar.com)
*
;* www.sofi-tech.com() www.mcu01.com()*
;* willar@tom.com
*
;*
*
;*Copyright(C) All Rights Reserved
*
;*
*
;*
*
;*******************************************************************
TEMPL
TEMPH

EQU
EQU

30H
31H

LEDPLAY

EQU

40H

BEEP
DATA_LINE

BIT
BIT

P3.7
P3.3

PRESENCE
FLAG

BIT
BIT

20H.0
20H.1

;
;
;DS18B20 DQ
;DS18B20
;

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 161 -

ME950

Mcu Development Kit User tutorial

;**********************************************************
ORG 0000H
AJMP MAIN
ORG 0050H
;**********************************************************
MAIN:
MOV SP,#60H
;
MOV P0,#0FFH
MOV P2,#0FFH
SETB
SETB
SETB
MOV
MOV
MOV
MOV
MOV
MOV

PRESENCE
FLAG
BEEP
LEDPLAY,#0BH
LEDPLAY+1,#0CH
LEDPLAY+2,#0DH
LEDPLAY+3,#0DH
LEDPLAY+4,#0DH
LEDPLAY+5,#0DH

; C
;
; -

LOOP:
ACALL RESET
JNB PRESENCE,LOOP1
MOV P2,#0FFH
ACALL BEEP_BL
AJMP LOOP

; DS18B20

MOV A,#0CCH
ACALL WRITE
MOV A,#044H
ACALL WRITE

; ROM

MOV R4,#130

;
;DS18B20

LOOP1:
;

LOOP2:
ACALL TEMP_PLAER
DJNZ R4,LOOP2

;>750ms
;

ACALL RESET
JB PRESENCE,LOOP
MOV A,#0CCH
ACALL WRITE
MOV A,#0BEH
ACALL WRITE

; DS18B20
; ROM
;

ACALL READ_TEMP
ACALL CONVTEMP
MOV R4,#30

;
;

ACALL TEMP_PLAER
DJNZ R4,LOOP3

AJMP

; LOOP

LOOP3:

LOOP

;**********************************************************
;DS18B20
;PRESENCE=0 OK, PRESENCE=1 ERROR
;**********************************************************
RESET:
SETB DATA_LINE
;
NOP
NOP
CLR DATA_LINE
;
MOV B,#64H
MOV R1,#03H

; 600us

RESET1:
DJNZ B, RESET1
MOV B,#64H

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 162 -

ME950

Mcu Development Kit User tutorial

DJNZ R1,RESET1
SETB DATA_LINE
NOP
MOV B,#22H

DJNZ B,RESET2
JNB DATA_LINE,RESET3
AJMP RESET4

; 64us
; DS18B20

RESET2:

RESET3:
MOV B,#210
; 420us
DJNZ B,$
JNB DATA_LINE,RESET4 ; DS1820
CLR PRESENCE
;, DS1820
AJMP RESET5
RESET4:
SETB PRESENCE

;, DS1820

SETB DATA_LINE
RET

RESET5:

;**********************************************************
;
;**********************************************************
WRITE:
MOV R2,#8
; 8 bit
CLR C
WR1:
CLR DATA_LINE
;,
MOV B,#05
DJNZ B,$
; 10us
RRC A
; BIT C
MOV DATA_LINE,C
; BIT
MOV B,#23
DJNZ B,$
; 46us
SETB DATA_LINE
;,
DJNZ R2,WR1
; BIT
RET
;**********************************************************
;
;**********************************************************
READ:
MOV R2,#8
; 8 bit
SETB DATA_LINE
CLR C
RD1:
CLR DATA_LINE
;
NOP
;
NOP
SETB DATA_LINE
;
NOP
NOP
MOV C,DATA_LINE
; C
RRC A
; A
MOV B,#23
DJNZ B,$
; 46us
SETB DATA_LINE
;,
DJNZ R2,RD1
; BIT
RET
;**********************************************************
;
; DS18B20
; TEMPL 2
;**********************************************************
READ_TEMP:

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 163 -

ME950

Mcu Development Kit User tutorial

MOV R4,#2
MOV R1,#TEMPL
RE00:
ACALL READ
MOV @R1,A
INC R1
DJNZ R4,RE00
RET
;**********************************************************
;

;**********************************************************
CONVTEMP:
MOV A,TEMPH
;
ANL A,#80H
JZ TEMPC1
;
CLR C
MOV A,TEMPL
;
CPL A
;
ADD A,#01H
; 1
MOV TEMPL,A
MOV A,TEMPH
CPL A
ADDC A,#00H
MOV TEMPH,A
CLR FLAG
;,
SJMP TEMPC11
TEMPC1:
SETB FLAG
;,
TEMPC11:
MOV A,TEMPL
ANL A,#0FH
;
MOV DPTR,#TEMPDOTTAB
;
MOVC A,@A+DPTR
MOV LEDPLAY+2,A
;
MOV
ANL
SWAP
MOV
MOV
ANL
SWAP
ORL
LCALL

A,TEMPL
A,#0F0H
A
TEMPL,A
A,TEMPH
A,#0FH
A
A,TEMPL

MOV
ANL
MOV

;
; TEMPL
; TEMPH
; A

HEX2BCD1

; BCD

TEMPL,A
A,#0FH
LEDPLAY+3,A

MOV A,TEMPL
SWAP A
ANL A,#0FH
MOV LEDPLAY+4,A
MOV A,R7
JZ TEMPC12
ANL A,#0FH
MOV LEDPLAY+5,A
AJMP TEMPC15

;
;R7 -
;"0"
;

TEMPC12:
JNB
MOV
MOV
JNZ
MOV
AJMP

FLAG,TEMPC13
LEDPLAY+5,#0AH
A,LEDPLAY+4
TEMPC15
LEDPLAY+4,#0AH
TEMPC15

;"0"
;"0"

TEMPC13:
MOV A, LEDPLAY+4
JZ TEMPC14
MOV LEDPLAY+5,#0DH

;"0"
;"-"

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 164 -

ME950
AJMP

Mcu Development Kit User tutorial

TEMPC15

TEMPC14:
MOV LEDPLAY+5,#0AH
;
MOV LEDPLAY+4,#0DH
;"-"
TEMPC15:
RET
;**********************************************************
;

;**********************************************************
TEMPDOTTAB:
DB
00H,01H,01H,02H,03H,03H,04H,04H
DB
05H,06H,06H,07H,08H,08H,09H,09H
;**********************************************************
;
;**********************************************************
TEMP_PLAER:
MOV R0,#LEDPLAY
;
MOV R5,#0FEH
;
PLAY:
MOV A,@R0
; A
MOV DPTR,#TABLE
;
MOVC A,@A+DPTR
;
MOV P0,A
;
MOV A,R5
MOV P2,A
;
JB
ACC.3,LOOP5
;
CLR P0.7
LOOP5:
ACALL DL_MS
; 1ms
INC R0
;
MOV A,R5
JNB ACC.5,ENDOUT
;ACC.5=0 ,
RL A
;
MOV R5,A
; R5
AJMP PLAY
; PLAY
ENDOUT:
MOV P2,#0FFH
;
RET
;**********************************************************
;
;**********************************************************
TABLE:
DB 0C0H,0F9H,0A4H,0B0H,99H,92H,82H,0F8H
;
0" 1" 2" 3" 4"5"6"7"
DB 80H,90H,0FFH,0C6H,9CH,0BFH,0C7H,89H
;
8"9"""
C
"-"
"L" "H"
;**********************************************************
; 1MS
; LED
;**********************************************************
DL_MS:
MOV R6,#2
DL1:
MOV R7,#230
DL2:
DJNZ R7,DL2
DJNZ R6,DL1
RET
;**********************************************************

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 165 -

ME950

Mcu Development Kit User tutorial

; BCD
;(A)-
;:R7-,A-( BCD )
;**********************************************************
HEX2BCD1:
PUSH B
MOV B,#64H
; 100
DIV AB
MOV R7,A
; R7
MOV A,#0AH
; 10
XCH A,B
;A B
DIV AB
SWAP A
; 4
ORL A,B
; A
POP B
RET
;**********************************************************
;
;**********************************************************
BEEP_BL:
MOV R6,#180
BL1:
ACALL DEX1
CPL BEEP
; P3.7
DJNZ R6,BL1
MOV R5,#10
ACALL DELAY
RET
;**********************************************************
; 650us
;
;**********************************************************
DEX1:
MOV R7,#200
DEX2:
NOP
DJNZ R7,DEX2
RET
;**********************************************************
; (R5)*10MS

;**********************************************************
DELAY:
MOV R6,#10
DEL1:
MOV R7,#230
DEL2:
DJNZ R7,DEL2
DJNZ R6,DEL1
DJNZ R5,DELAY
RET
;**********************************************************
END

;**********************************************************

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 166 -

ME950

Mcu Development Kit User tutorial

6. C
Example_C51\EX22_DS18B20
/*******************************************************************
*
*
* ME950 - DS18B20
*
*
*
* 6
*
*
*
* V1.0 (2011/08/23)
*
* gguoqing (Email: gguoqing@willar.com)
*
* www.sofi-tech.com() www.mcu01.com() *
* willar@tom.com
*
*
*
*Copyright(C) www.willar.com All Rights Reserved *
*
*
*
*
*******************************************************************/
#include <reg52.h>
#include <intrins.h>
sbit DQ = P3 ^ 3; // DS18B20 DQ
sbit BEEP = P3 ^ 7; //
bit presence;
unsigned char code LEDData[] =
{
0xC0, 0xF9, 0xA4, 0xB0, 0x99, 0x92, 0x82,
0xF8, 0x80, 0x90, 0xff, 0xc6, 0x9c, 0xbf
};
unsigned char data temp_data[2];
unsigned char data display[7] =
{
0x0b, 0x0c, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d
};
char code reserve[3]_at_ 0x3b; // 0x3b 3
/**********************************************************
us

(8*1.085)*num

**********************************************************/
void Delay(unsigned int num) //
{
while (--num)
;
}
/**********************************************************

**********************************************************/
void delayms(unsigned int ms)
{
unsigned char k;
while (ms--)
{
for (k = 0; k < 114; k++)
;
}
}
/**********************************************************

**********************************************************/
void beep()

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 167 -

ME950

Mcu Development Kit User tutorial

{
unsigned char i;
for (i = 0; i < 180; i++)
{
Delay(80);
BEEP = !BEEP; //BEEP
}
BEEP = 1; //
delayms(100);
}
/**********************************************************
DS18B20
presence=0

OK

presence=1

ERROR

**********************************************************/
unsigned char Init_DS18B20(void)
{
DQ = 0; //
Delay(60); //>480us
DQ = 1; //
Delay(8); //>64us,
presence = DQ; //
Delay(50); //>400us,
DQ = 1; //
return (presence); // presence
}
/**********************************************************

**********************************************************/
unsigned char ReadOneChar(void)
{
unsigned char i = 0;
unsigned char dat = 0;
DQ = 1;
for (i = 0; i < 8; i++)
// 8 bit
{
DQ = 0; //
dat >>= 1;
DQ = 1; //
_nop_();
_nop_();
if (DQ)
//
dat |= 0x80;
// 1
Delay(6); //>45us
DQ = 1; //,
}
return (dat); //
}
/**********************************************************

**********************************************************/
void WriteOneChar(unsigned char dat)
{
unsigned char i = 0;
for (i = 0; i < 8; i++)
// 8 bit
{
DQ = 0; //

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 168 -

ME950

Mcu Development Kit User tutorial

Delay(1); //<15us
dat >>= 1; //, CY
DQ = CY; // 1bit
Delay(6); //>45us
DQ = 1; //,
}
}
/**********************************************************

**********************************************************/
void Temperature_conver()
{
unsigned char minus = 0;
//
//

display[0]=0x0b;
display[1]=0x0c;

// C
//

if (temp_data[1] > 127)


//
{
temp_data[0] = (~temp_data[0]) + 1; //
if ((~temp_data[0]) >= 0xff)
temp_data[1] = (~temp_data[1]) + 1;
else
temp_data[1] = ~temp_data[1];
minus = 1; //
}
display[6] = temp_data[0] &0x0f; //
display[2] = (display[6] *10) / 16; //
display[6]
//
display[5]
display[4]
display[3]

= ((temp_data[0] &0xf0) >> 4) | ((temp_data[1] &0x0f) << 4);


= display[6] / 100; //
= (display[6] % 100) / 10; //
= display[6] % 10; //

if (!display[5])
// 0,
{
display[5] = 0x0a;
if (!display[4])
// 0,
display[4] = 0x0a;
}
if (minus)
{
display[5] = 0x0d; //
}
}
/**********************************************************

**********************************************************/
void ledplay()
{
unsigned char n, shift;
shift = 0xfe; //
for (n = 0; n < 6; n++)
//6
{
if (n == 3)
P0 = (LEDData[display[n]]) &0x7f;
//
else
P0 = LEDData[display[n]];

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 169 -

ME950

Mcu Development Kit User tutorial

//
P2 = shift; //
shift = (shift << 1) | 0x01; //
delayms(1);
}
P2 = 0xff; //
delayms(1);
}
/**********************************************************

**********************************************************/
void main(void)
{
unsigned char m;
P0 = 0xff;
P2 = 0xff;
while (1)
{
Init_DS18B20();
if (presence == 0)
{
WriteOneChar(0xCC); // ROM
WriteOneChar(0x44); //
for (m = 0; m < 120; m++)
//
ledplay();
//
}
Init_DS18B20();
if (presence == 0)
{
WriteOneChar(0xCC); // ROM
WriteOneChar(0xBE); //
temp_data[0] = ReadOneChar(); // 8
temp_data[1] = ReadOneChar(); // 8
Temperature_conver(); //
for (m = 0; m < 120; m++)
ledplay();
//
}
else
{
beep(); //
P2 = 0xff; //
}
}
}
/*********************************************************/

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 170 -

ME950

Mcu Development Kit User tutorial

ME950

1.
P3.2

2.

ME830/ME850
IR
ME950
IR REMOTE

Remote

U16 1838

JP10

1
2
3

VCC

P32

R22
100

(#INT0)

5.67
ME950 T1838 T1838
T1838 38kHz
P3.2INT0

T1838 JP10 AT89S52 P3.2INT0


5.67

32
ME950 DT9122D HT6222SC6122
5.68

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 171 -

ME950

Mcu Development Kit User tutorial

5.68

3.
JP21 8 DG0DG7 P2
JP22 9 ADP P0 VCC
JP10 U16 P3.2
JP24 OFF LCD1602

4.

UP
0x1d

DOWN
0x12

DL11

DL11

INT0

5.69

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 172 -

ME950

IRCOM[ ]

INIR=0?
9ms

Mcu Development Kit User tutorial

INIR=1?
4.5ms

5.70

IRIN=0 ?

NUM=0

140us
IRIN=1 ?

NUM>8 ?

N
0

IRIN=1 ?

140us

Y
140us
NUM+1

5.71

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 173 -

ME950

Mcu Development Kit User tutorial

5.
Example_A51\EX23_IR
/;***************************************************************************
;* ME950 -
*
;*
*
;* 2
*
;*
*
;* : V1.0( 2008-08-20
)
*
;* : gguoqing
*
;* www.sofi-tech.com() www.mcu01.com()
*
;* willar@tom.com
*
;*
*
;*Copyright(C) All Rights Reserved
*
;*
*
;***************************************************************************
;*
*
;* :
*
;*
ME950
*
;*
, P0
*
;*
*
;*
UP DOWN
*
;*
*
;***************************************************************************
IRCOM

EQU

30H

IRIN
BEEP
RELAY

EQU
EQU
EQU

P3.2
P3.7
P3.6

;30H-33H IR

;**********************************************************
ORG 0000H
AJMP MAIN
ORG 0003H
AJMP IR_IN
ORG 0050H

; INT0

;**********************************************************
MAIN:
MOV
SP,#60H
MOV
A,#00H
MOV
R0,#IRCOM
LOOP0:
MOV
@R0,A
;30H-37H
INC
R0
CJNE R0,#IRCOM+8,LOOP0
MOV IE,#81H
MOV TCON,#01H
SETB IRIN
SETB BEEP
SETB RELAY
MOV IRCOM+5,#10H
MOV IRCOM+6,#10H
ACALL IR_SHOW

;, INT0
;

;"-"

LOOP1:
ACALL IR_SHOW
MOV A,IRCOM+2
CJNE A,#1DH,LOOP2
CLR
RELAY

;UP
;

CJNE
SETB

;DOWN
;

LOOP2:
A,#12H,LOOP3
RELAY

LOOP3:
AJMP

LOOP1

;**********************************************************
;

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 174 -

ME950

Mcu Development Kit User tutorial

;**********************************************************
IR_SHOW:
MOV
A,IRCOM+5
; A
MOV
DPTR,#TAB
;
MOVC A,@A+DPTR
;
MOV
P0,A
; P0
CLR
P2.0
SETB P2.1
ACALL DELAY1
MOV
A,IRCOM+6
; A
MOV
DPTR,#TAB
;
MOVC A,@A+DPTR
;
MOV
P0,A
; P0
CLR
P2.1
SETB P2.0
ACALL DELAY1
MOV P2,#0FFH
RET
;**********************************************************
TAB:
DB 0C0H,0F9H,0A4H,0B0H,99H,92H,82H,0F8H
DB 80H,90H,88h,83h,0c6h,0a1h,86h,8eh,0bfh ;0F,;**********************************************************
;
;
;
;

IR
R0--- IR
R2---
R3--- 8

;**********************************************************
IR_IN:
CLR EA
; CPU
PUSH ACC
PUSH PSW
SETB PSW.3
; 1
CLR
PSW.4
MOV R0,#IRCOM
MOV R4,#30
IR_IN1:
ACALL DELAY
; 4ms IR
DJNZ R4,IR_IN1
JB IRIN,IR_END
; IRIN1 IR
WAIT_H:
JB IRIN,WAIT_L
; IR 9ms
ACALL DELAY
AJMP
WAIT_H
WAIT_L:
JNB IRIN,WAIT_H1
; IR 4.5ms
ACALL DELAY
AJMP WAIT_L
WAIT_H1:
MOV R3,#0
;8 0
WAIT_L1:
JNB IRIN,WAIT_H2
; IR
ACALL DELAY
AJMP WAIT_L1
WAIT_H2:
JB IRIN,IR_COUN
; IR
ACALL DELAY
AJMP WAIT_H2
IR_COUN:
MOV R2,#0
; 0.14ms
IR_COUN1:
ACALL DELAY
JB IRIN, IR_COUN2
; IR
;IR=0 R2
MOV A,#8
CLR C
;
SUBB A,R2
;
; C=00"
; C=11"
MOV A,@R0
;

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 175 -

ME950
RRC
MOV
INC
CJNE
MOV
INC
CJNE
AJMP

A
@R0,A
R3
R3,#8,WAIT_L1
R3,#0
R0
R0,#IRCOM+4,WAIT_L1
IR_COMP

Mcu Development Kit User tutorial

; C A
;,
; 1
; 8
; IR 1
; 4

IR_COUN2:
INC R2
CJNE R2,#15,IR_COUN1

;0.14ms

IR_END:
POP PSW
POP ACC
SETB EA
RETI
IR_COMP:
MOV A,IRCOM+3
CPL A
CJNE A,IRCOM+2,COMP_END

;
;,

MOV A,IRCOM
JNZ COMP_END

; "00"

MOV A,IRCOM+2
ANL A,#0FH
MOV IRCOM+5,A
MOV A,IRCOM+2
ANL A,#0F0H
SWAP A
MOV IRCOM+6,A
ACALL IR_SHOW
ACALL BEEP_BL

;
;

;
;
;

COMP_END:
AJMP

IR_END

;**********************************************************
; 0.14MS
; IR
;**********************************************************
DELAY:
MOV R6,#2
DEL1:
MOV R7,#32
DEL2:
DJNZ R7,DEL2
DJNZ R6,DEL1
RET
;**********************************************************
;
;**********************************************************
BEEP_BL:
MOV R6,#100
BL1:
CALL DEX1
CPL BEEP
DJNZ R6,BL1
RET
DEX1:
MOV R7,#220
DEX2:
NOP
DJNZ R7,DEX2
RET
;**********************************************************
DELAY1:
; 4MS

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 176 -

ME950
MOV

Mcu Development Kit User tutorial

R6,#20

DL2:
MOV R7,#100
DJNZ R7,$
DJNZ R6,DL2
RET
;**********************************************************
END

;**********************************************************
;
;
;
;

IRCOM[0]
IRCOM[1]
IRCOM[2]
IRCOM[3]

---------

00H
FFH

;================================
;DT9122D
;******
;
;
;
;
;
;
;
;

10
09
19
17
40
02
0A
1C

03
1D
1B
12
48
05
1E
14

01
1F
11
16
04
54
0E
0F

******
06
0D
15
4C
00
4D
1A
0C

;================================

6. C
Example_C51\EX23_IR
/*******************************************************************
*
*
* ME950 -
*
*
*
* 2
*
*
*
* V1.0 (2011/08/20)
*
* gguoqing (Email: gguoqing@willar.com)
*
* www.sofi-tech.com() www.mcu01.com() *
* willar@tom.com
*
*
*
*Copyright(C) www.willar.com All Rights Reserved *
*
*
*
*
*******************************************************************/
#include <reg52.h>
#include <intrins.h>
sbit IRIN = P3 ^ 2; //
sbit BEEP = P3 ^ 7; //
sbit RELAY = P3 ^ 6; //
unsigned char IRCOM[] =
{
0x00, 0x00, 0x00, 0x00, 0x10, 0x10
};
unsigned char code table[] =
{
0xc0, 0xf9, 0xa4, 0xb0, 0x99, 0x92, 0x82, 0xf8, //0,1,2,3,4,5,6,7
0x80, 0x90, 0x88, 0x83, 0xc6, 0xa1, 0x86, 0x8e, 0xbf //8,9,A,B,C,D,E,F,};

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 177 -

ME950

Mcu Development Kit User tutorial

char code reserve[3]_at_ 0x3b; // 0x3b 3


/**********************************************************
ms
**********************************************************/
void delayms(unsigned int ms)
{
unsigned char k;
while (ms--)
{
for (k = 0; k < 114; k++)
;
}
}
/**********************************************************
us
**********************************************************/
void delay(unsigned char x) //x*0.14MS
{
unsigned char i;
while (x--)
{
for (i = 0; i < 14; i++)
;
}
}
/**********************************************************

**********************************************************/
void beep()
{
unsigned char i;
for (i = 0; i < 100; i++)
{
BEEP = !BEEP; //BEEP
delay(6);
}
BEEP = 1; //
}
/**********************************************************

**********************************************************/
void play()
{
P0 = (table[IRCOM[4]]); //
P2 = 0xfe;
delayms(1);
P0 = (table[IRCOM[5]]); //
P2 = 0xfd;
delayms(1);
P2 = 0xff; //
delayms(1);
}
/**********************************************************

**********************************************************/
void main(void)
{
P0 = 0xff; //I/O
P2 = 0xff;

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 178 -

ME950

Mcu Development Kit User tutorial

IRIN = 1;
BEEP = 1;
RELAY = 1;
IE = 0x81; //, INT0
TCON = 0x01; //
play();
while (1)
{
if (IRCOM[2] == 0x1d)
//UP
RELAY = 0;
//
if (IRCOM[2] == 0x12)
//DOWN
RELAY = 1;
//
play(); //
}
}
/**********************************************************
INT0
**********************************************************/
void IR_IN()interrupt 0
{
unsigned char j, k, Num = 0;
EX0 = 0; // INT0
delay(15); //
if (IRIN == 1)
// IR
{
EX0 = 1; // INT0
return ; //
}
while (!IRIN)
// IR 9ms
{
delay(1);
}
while (IRIN)
// IR 4.5ms
{
delay(1);
}
for (j = 0; j < 4; j++)
//
{
for (k = 0; k < 8; k++)
// 8
{
while (IRIN)
// IR
{
delay(1);
}
while (!IRIN)
// IR
{
delay(1);
}
while (IRIN)
// IR
{
delay(1);

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 179 -

ME950

Mcu Development Kit User tutorial

Num++;
if (Num >= 15)
{
EX0 = 1; //0.14ms
return ;
}
} //
IRCOM[j] = IRCOM[j] >> 1; //0
if (Num >= 8)
IRCOM[j] = IRCOM[j] | 0x80;
//1
Num = 0;
} //end for k
} //end for j
if (IRCOM[0] != 0x00)
//
{
EX0 = 1; // INT0
return ; //
}
if (IRCOM[2] != ~IRCOM[3])
//
{
EX0 = 1; // INT0
return ; //
}
IRCOM[4] = IRCOM[2] &0x0F; //
IRCOM[5] = IRCOM[2] >> 4; // 4
play(); //
beep(); //
EX0 = 1; // INT0
}
/**********************************************************
;================================
;DT9122D
;******
;
;
;
;
;
;
;
;

10
09
19
17
40
02
0A
1C

03
1D
1B
12
48
05
1E
14

01
1F
11
16
04
54
0E
0F

******
06
0D
15
4C
00
4D
1A
0C

;================================
IRCOM[0]
IRCOM[1]
IRCOM[2]
IRCOM[3]

---------

00H
ffH

*********************************************************/

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 180 -

ME950

Mcu Development Kit User tutorial

PS2

1.
PS2 PC PC PC
3 LED 1

PC 1-f EscNumLock 0-9


0-9 NumLock NumLock NumLock
0-9 NumLock NumLock 0-9 Esc
PC
PC 1
NumLock n
PC

2.

ME950
PS/2 Interface
ME830/ME850
PS/2 Interface
J10

6
4
2
1
3
5

CLK
DAT

JP12

11

Pin Name

15
14

6 5
4
3
21

VCC

12 21
23
22
16

20

PS2

P33
P34

Dir

Description

DATA

Key Data

24
225

N/C

Not connected

GND

GND

VCC

Power,+5V

CLK

Clock

N/C

Not connected
7

13

5.72 PS2

3.
JP21 8 DG0DG7 P2
JP22 9 ADP P0 VCC
JP12 PS/2 P3.3 P3.4
PC J10 PS/2
JP11 DS18B20
JP24 OFF LCD1602

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 181 -

ME950

Mcu Development Kit User tutorial

4.

INT0

BF=1 ?

Y
BF=0

0xFF

5.73

PS2 1 08 1 1 1

IntNum0 0

IntNum9
IntNum10 1
3

INT0

IntNum +1

INT0

KeyCode
= 0xf0

Y
Y

PS2_CLK=1 ?

N
N

PS2_CLK=0 ?

break_code=1
BF = 0

N
IntNum=11

0<IntNum<9

INT0

Y
KeyCode
PS2_DATA=1
KeyCode1

IntNum 0

BF = 1

5.74

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 182 -

ME950

Mcu Development Kit User tutorial

Indata | 0x01
1

PS2_CLK = 0
PS2_DATA = 0
>60us

PS2_DATA = 1
Check 1

N
PS2_DATA = 0

PS2_CLK = 1

Check
=0 ?

Indata

PS2_DATA = 0

PS2_DATA = 1

=8
N

1
0?

PS2_CLK

PS2_DATA = 1

PS2_CLK

PS2_CLK

PS2_CLK

PS2_CLK

PS2_CLK

PS2_DATA = 1
PS2_CLK = 1

PS2_CLK

PS2_DATA
PS2_CLK

5.75

5.
Example_A51\EX24_PS2
;*******************************************************************
;*
*
;* ME950 - PS2
*
;*
*
;* 1
*
;*
*
;* V1.0 (2011/09/23)
*
;* gguoqing (Email: gguoqing@willar.com)
*
;* www.sofi-tech.com() www.mcu01.com()*
;* willar@tom.com
*
;*
*
;*Copyright(C) All Rights Reserved
*
;*
*
;*
*
;*******************************************************************
PS2_CLK
PS2_DATA

EQU
EQU

P3.3
P3.4

KEY_DATA
ESC_DATA
NUM_DATA
S_DATA
TEMP

EQU
EQU
EQU
EQU
EQU

30H
31H
32H
33H
34H

FLAG
NumLock
SEND_OK
BREAK_C
BEEP

BIT
BIT
BIT
BIT
BIT

20H.0
20H.1
20H.2
20H.4
P3.7

;*********************************************************
ORG

0000H

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 183 -

ME950
JMP
ORG
JMP
ORG

Mcu Development Kit User tutorial

MAIN
0013H
EXT1
0050H

;*********************************************************
MAIN:
MOV SP,#60H
MOV P0,#0FFH
MOV P2,#0FEH
MOV P3,#0FFH
CLR IT1
SETB EA
SETB EX1
MOV
MOV
MOV
CLR
SETB
SETB

; 1
;
; 1

R0,#00H
R1,#00H
R3,#00H
NumLock
PS2_DATA
PS2_CLK

MOV S_DATA,#0FFH
ACALL SEND_DATA
ACALL DELAY
MOV ESC_DATA,#00H
MOV NUM_DATA,#00H
MOV P0,#0BFH

;PS2

;'-'

DISP:
MOV

P0,A

MOV
CJNE
MOV
CPL

R0,NUM_DATA
R0,#77H,NUM2
NUM_DATA,#00H
NumLock

MOV S_DATA,#0EDH
ACALL SEND_DATA
JNB NumLock,NUM1
MOV S_DATA,#02H
ACALL SEND_DATA
MOV P0,#0C8H
ACALL BEEP_BL
MOV A,#0C8H
AJMP DISP

;NUM

;PS2

; NumLock
;"n"
;"n"

NUM1:
MOV S_DATA,#00H
ACALL SEND_DATA
MOV P0,#0C8H
ACALL BEEP_BL
MOV A,#0C8H
AJMP DISP

; NumLock
;"n"
;"n"

NUM2:
MOV R0,ESC_DATA
CJNE R0,#76H,DISP_END
MOV ESC_DATA,#00H
MOV P0,#0BFH
MOV S_DATA,#0FFH
ACALL SEND_DATA
ACALL BEEP_BL
MOV A,#0BFH

;ESC
;'-'
;PS2
;'-'

DISP_END:
AJMP DISP
;---------------------------------------------------------; PS2
;
;---------------------------------------------------------PS2KEY_IN:
MOV B,A

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 184 -

ME950
MOV
MOV

Mcu Development Kit User tutorial

DPTR,#TABLE_D
R3,#0FFH

KEY_IN1:
INC R3
MOV A,R3
MOVC A,@A+DPTR
CJNE A,B,KEY_IN3
MOV A,R3
CLR C
SUBB A,#10H
JC KEY_IN2
JNB NumLock,KEY_END

;
;C=1

KEY_IN2:
MOV A,R3
MOV DPTR,#TAB_NU
MOVC A,@A+DPTR
MOV P0,A
ACALL BEEP_BL
RET

;
;
;

KEY_IN3:
CJNE

A,#0FFH,KEY_IN1

KEY_END:
CLR
MOV
RET

BREAK_C
A,#0BFH

;'-'

;**********************************************************
;

()

;**********************************************************
EXT1:
CLR EX1
CJNE R1,#00H,IN_LOOP
;
AJMP IN_LOOP3
IN_LOOP:
CJNE R1,#09H,IN_LOOP1
;2-9
IN_LOOP1:
JNC IN_LOOP3
; 9
RR A
;
JB PS2_DATA,IN_LOOP2
;10
ANL A,#7FH
AJMP IN_LOOP3
IN_LOOP2:
ORL A,#80H
IN_LOOP3:
INC R1
;
JNB PS2_CLK,$
; PS2_CLK
IN_LOOP4:
CJNE R1,#0BH,IN_LOOP5
;
IN_LOOP5:
JNC IN_LOOP6
; 11
AJMP EXT1_END
IN_LOOP6:
CJNE A,#0F0H,IN_LOOP7
;
SETB BREAK_C
;
MOV R1,#00H
;
JMP EXT1_END
IN_LOOP7:
CJNE A,#77H,IN_LOOP8
;NUMLOCK
JB BREAK_C,IN_LOOP7A
MOV NUM_DATA,A
IN_LOOP7A:
CLR BREAK_C
MOV R1,#00H
;
AJMP EXT1_END
IN_LOOP8:
CJNE A,#76H,IN_LOOP9
;ESC
JB BREAK_C,IN_LOOP8A
MOV ESC_DATA,A
IN_LOOP8A:
CLR BREAK_C
MOV R1,#00H
;
AJMP EXT1_END

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 185 -

ME950

Mcu Development Kit User tutorial

IN_LOOP9:
MOV R1,#00H
ACALL PS2KEY_IN

EXT1_END:
SETB
RETI

EX1

;**********************************************************
;
;**********************************************************
SEND_DATA:
CLR EA
MOV A,S_DATA
; A
JB PSW.0,SET1
SETB FLAG
;P=0 1,FLAG=1
AJMP
SEND_DATA0
SET1:
CLR FLAG
;P=1 1,FLAG=0
SEND_DATA0:
CLR PS2_CLK
;
SETB PS2_DATA
ACALL DELAY120US
; PS2_CLK 120us
CLR PS2_DATA
SETB PS2_CLK
MOV

;
;

R1,#08H

SEND_DATA1:
JB PS2_CLK,$
RRC A
MOV PS2_DATA,C
JNB PS2_CLK,$
DJNZ R1,SEND_DATA1
JB

PS2_CLK,$

JNB FLAG,SEND_DATA2
SETB PS2_DATA
AJMP SEND_DATA3

; PS2
; PS2
; 8 8 bit
; PS2
; 1

SEND_DATA2:
CLR

PS2_DATA

; 0

SEND_DATA3:
JNB PS2_CLK,$
JB PS2_CLK,$
SETB PS2_DATA
JNB PS2_CLK,$
SETB PS2_DATA
SETB PS2_CLK
JB PS2_CLK,$
MOV C,PS2_DATA
JNB PS2_CLK,$
JNB PS2_DATA,$
JC SEND_ERROR
SETB SEND_OK
AJMP SEND_DATA_END

; PS2
; PS2
;
; PS2

; PS2
; ACK ,
; PS2

SEND_ERROR:
CLR SEND_OK
SEND_DATA_END:
SETB EA
RET

;*********************************************************
;
;*********************************************************
DELAY120US:
MOV R7,#60
DJNZ R7,$
RET

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 186 -

ME950

Mcu Development Kit User tutorial

;**********************************************************
;
;**********************************************************
BEEP_BL:
MOV R6,#200
BL1:
ACALL DEX1
CPL BEEP
DJNZ R6,BL1
ACALL DELAY
RET
;**********************************************************
; 680US
;**********************************************************
DEX1:
MOV R7,#210
DEX2:
NOP
DJNZ R7,DEX2
RET
;**********************************************************
; 100ms
;**********************************************************
DELAY:
MOV R6,#200
DEL1:
MOV R7,#230
DJNZ R7,$
DJNZ R6,DEL1
RET
;**********************************************************
;
;**********************************************************
TABLE_D:
DB
DB
DB
DB

45H,16H,1EH,26H,25H,2EH,36H,3DH,3EH,46H
1CH,32H,21H,23H,24H,2BH
70H,69H,72H,7AH,6BH,73H,74H,6CH,75H,7DH
0FFH

;0-9
;a-f
; 0-9

;**********************************************************

;**********************************************************
TAB_NU:
DB 0C0H,0F9H,0A4H,0B0H,099H,092H,082H,0F8H
DB 080H,090H,088H,083H,0C6H,0A1H,086H,08EH
DB 0C0H,0F9H,0A4H,0B0H,099H,092H,082H,0F8H
DB 080H,090H,088H,083H,0C6H,0A1H,086H,08EH
DB

0FFH

;*********************************************************
END

;*********************************************************

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 187 -

ME950

Mcu Development Kit User tutorial

6. C
Example_C51\EX24_PS2
/*******************************************************************
*
*
* ME950 - PS2
*
*
*
* 1
*
*
*
* V1.0 (2011/09/15)
*
* gguoqing (Email: gguoqing@willar.com)
*
* www.sofi-tech.com() www.mcu01.com() *
* willar@tom.com
*
*
*
*Copyright(C) www.willar.com All Rights Reserved *
*
*
*
*
******************************************************************/
#include <reg52.h>
#include <intrins.h>
sbit PS2_DATA = P3 ^ 4; //PS2
sbit PS2_CLK = P3 ^ 3; //PS2
sbit BEEP = P3 ^ 7; //
bit numlock = 1; //NumLock
bit break_code = 1; //
bit BF = 0; //
#define NUMLOCK_CODE
#define ESC_CODE

0x77
0x76

//NumLock
//ESC

unsigned char TEMP, TEMP1, y;


unsigned char KeyCode; //
unsigned char code TABLE_D[] =
{
//
0x45, 0x16, 0x1e, 0x26, 0x25, 0x2e, 0x36, 0x3d, 0x3e, 0x46, //0-9
0x1c, 0x32, 0x21, 0x23, 0x24, 0x2b, //a-f
0x70, 0x69, 0x72, 0x7a, 0x6b, 0x73, 0x74, 0x6c, 0x75, 0x7d, 0xff
}; // 0-9
unsigned char code TABLE_NUM[] =
{
//
0xC0, 0xF9, 0xA4, 0xB0, 0x99, 0x92, 0x82, 0xF8, 0x80, 0x90, 0x88, 0x83, 0xC6,
0xA1, 0x86, 0x8E, 0xC0, 0xF9, 0xA4, 0xB0, 0x99, 0x92, 0x82, 0xF8, 0x80,
0x90, 0xff
};
unsigned char IntNum = 0; //
char code reserve[3]_at_ 0x3b; // 0x3b 3
/*********************************************************
x*0.14ms
*********************************************************/
void delay(unsigned int x)
{
unsigned char i;
while (x--)
{
for (i = 0; i < 14; i++)
;
}
}

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 188 -

ME950

Mcu Development Kit User tutorial

/**********************************************************

**********************************************************/
void delayms(unsigned int ms)
{
unsigned char k;
while (ms--)
{
for (k = 0; k < 114; k++)
;
}
}
/**********************************************************

**********************************************************/
void beep()
{
unsigned char i;
for (i = 0; i < 200; i++)
{
delay(6);
BEEP = !BEEP; //BEEP
}
BEEP = 1; //
delayms(100); // 100ms
}
/*********************************************************
:SEND_DATA()
:
:
*********************************************************/
void SEND_DATA(unsigned char orderByte)
{
unsigned char k;
unsigned char check = 0;
EA = 0; //,
PS2_CLK = 0; //
PS2_DATA = 0; //
for (k = 0xff; k != 0; k--)
;
//
PS2_DATA = 0; //
PS2_CLK = 1; //
for (k = 8; k != 0; k--)
//
{
while (PS2_CLK)
;
// PS2
if (orderByte &0x01)
{
PS2_DATA = 1; //
check++; // 1
}
else
PS2_DATA = 0;
orderByte >>= 1; //
while (!PS2_CLK)
;
//
}
while (PS2_CLK)

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 189 -

ME950

Mcu Development Kit User tutorial

;
// PS2
if (check % 2)
{
// 1
PS2_DATA = 0; // 0
}
else
{
PS2_DATA = 1; // 1
}
while (!PS2_CLK)
;
//
while (PS2_CLK)
;
PS2_DATA = 1;
while (!PS2_CLK)
;
//
PS2_DATA = 1;
PS2_CLK = 1;
while ((PS2_CLK) | (PS2_DATA))
;
// ACK
while (!PS2_CLK)
;
// scl
EA = 1; //
}
/*********************************************************

*********************************************************/
void PS2KEY_NUM()
{
if (break_code)
//
{
break_code = 0; //
return ; //
}
if (KeyCode == ESC_CODE)
//Esc
{
KeyCode = 0;
SEND_DATA(0xff); //
beep();
return ; //
}
if ((KeyCode == NUMLOCK_CODE) &numlock)
//NumLock
{
numlock = 0;
KeyCode = 0;
SEND_DATA(0xED); // NumLock
SEND_DATA(0x02);
TEMP1 = 0xc8; //'n'
P0 = TEMP1;
beep();
return ; //
}
else
{
if ((KeyCode == NUMLOCK_CODE) &(!numlock))
{
numlock = 1;
KeyCode = 0;

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 190 -

ME950

Mcu Development Kit User tutorial

SEND_DATA(0xED); // NumLock
SEND_DATA(0x00);
TEMP1 = 0xc8; //'n'
P0 = TEMP1;
beep();
return ;
}
}
for (y = 0; y < 27; y++)
//
{
if (KeyCode == TABLE_D[y])
//
{
if ((y > 15) &(numlock))
//NumLock
{
KeyCode = 0x00;
return ;
}
else
{
TEMP1 = TABLE_NUM[y]; //
P0 = TEMP1; //
beep(); //
KeyCode = 0x00;
return ;
}
}
else
//
{
TEMP1 = 0xbf; //'-'
P0 = TEMP1;
}
}
BF = 0;
}
/**********************************************************

**********************************************************/
void main(void)
{
TEMP1 = 0xbf; //'-'
P0 = TEMP1;
P2 = 0xfe;
IT1 = 0; // 1
EA = 1; //
EX1 = 1; // 1
SEND_DATA(0xff); //
while (1)
{
P0 = TEMP1; //
if (BF)
{
BF = 0;
PS2KEY_NUM();
}
}
}
/*********************************************************

*********************************************************/
void ReadPS2()interrupt 2

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 191 -

ME950

Mcu Development Kit User tutorial

{
EX1 = 0;
while (PS2_CLK)
;
if ((IntNum > 0) && (IntNum < 9))
//
{
KeyCode = KeyCode >> 1; //>>
if (PS2_DATA)
KeyCode = KeyCode | 0x80;
// 1 1
}
PS2_CLK = 1;
IntNum++;
while (!PS2_CLK)
;
// PS/2CLK
if (IntNum == 11)
// 11
{
IntNum = 0; //
BF = 1;
if (KeyCode == 0xf0)
// 0xF0
{
break_code = 1;
BF = 0; //
}
}
EX1 = 1; // 1
}
/*********************************************************/

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 192 -

ME950

Mcu Development Kit User tutorial

74HC573

1.
74HC573 0-9

2.

P17
P20
P21
P22
P23
P24
P25
P26
P27

JP13

1
11
2
3
4
5
6
7
8
9
10

U4
OE
LE
D1
D2
D3
D4
D5
D6
D7
D8
GND

74HC573
VCC
Q1
Q2
Q3
Q4
Q5
Q6
Q7
Q8

20
19
18
17
16
15
14
13
12

ME950 74HC573

VCC
RP31 470*4
U4_Q1
U4_Q2
U4_Q3
U4_Q4
U4_Q5
U4_Q6
U4_Q7
U4_Q8

10
9
8
5
4
2
3
7

DS7
a
b
c
d
e
f
g
DP

VCC

JP29
A
A

1
6

J16
U4_Q1
U4_Q2
U4_Q3
U4_Q4
U4_Q5
U4_Q6
U4_Q7
U4_Q8

1
2
3
4
5
6
7
8

RP32 470*4

5.76 74HC573
74HC573 8 D () LE OE
I/O
74HC573
/OE1 3
LE11
D1-D82-9
Q1-Q719-12 3

74HC573

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 193 -

ME950

Mcu Development Kit User tutorial

/OE 8
LE 8
LE = 0 P2 8 74HC573
LE = 1 P2 8 74HC573
74HC573
/OE = 0LE = 1
/OE = 0LE = 0
/OE = 1 D1-D8 LE
3.

JP13 74HC573
JP29 74HC573

JP13 74HC573
JP29 J16 Q0-Q7
4.

5.77

5.
Example_A51\ EX25_573\7SEG
/*******************************************************************
*
*
* ME950 74HC573
*
*
*
* V1.0 (2010/02/12)
*
* gguoqing
*
* www.sofi-tech.com ()
*
*
www.willar.com()
*
* sofitech@tom.com
*
*
*
*Copyright(C) All Rights Reserved
*
*
*
*
*
********************************************************************
*
*
* 74LS573 8 D
*
*
*
* 74LS573 1
*
*
*
;********************************************************************
ORG 0000H
AJMP MAIN
ORG 0050H
;**********************************************************
;

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 194 -

ME950

Mcu Development Kit User tutorial

;**********************************************************
MAIN:
MOV SP,#60H
MOV P0,#0FFH
MOV P2,#0FFH
MAIN1:
CLR A
; A
MOV DPTR,#TAB_NU
;
MOVC A,@A+DPTR
;,
MOV R1,#11
; 11
MAIN2:
MOV DATA_573,A
;
ACALL LATCH
ACALL DELAY
INC DPTR
;
CLR A
; A
MOVC A,@A+DPTR
;
DJNZ R1,MAIN2
AJMP MAIN1
;************************************************
;
;************************************************
LATCH:
NOP
; 0E
SETB LE_573
; LE
NOP
; D Q(Q=D)
CLR LE_573
;LE ,
NOP
;D Q
RET
;************************************************
;
; 500ms (11.0592MHz)
;************************************************
DELAY:
MOV R5,#5
DEL1:
MOV R6,#200
DEL2:
MOV R7,#230
DEL3:
DJNZ R7,DEL3
;
DJNZ R6,DEL2
;
DJNZ R5,DEL1
;
RET
;*********************************************************
;
;*********************************************************
TAB_NU:
DB 0C0H,0F9H,0A4H,0B0H,099H,092H,082H,0F8H,080H
DB 090H,0FFH
;**********************************************************
END
;**********************************************************

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 195 -

ME950

Mcu Development Kit User tutorial

6. C
Example_C51\EX25_573\7SEG
/*******************************************************************
* ME950 74HC573
*
*
*
* V1.0 (2010/02/12)
*
* gguoqing
*
* www.sofi-tech.com ()
www.willar.com() *
* sofitech@tom.com
*
*Copyright(C) All Rights Reserved
*
*
*
*
*
********************************************************************
* 74LS573 8 D
*
*
*
* 74LS573 1
*
*******************************************************************/
#include <reg52.h>
//51
#include <intrins.h>
// _nop_();
sbit LE_573 = P1^7;

//573

unsigned char code display[] =


{
0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90,0xff
};
/**********************************************************
t
11.0592MHz 1ms
**********************************************************/
void delayms(unsigned int t)
{
unsigned char k;
while(t--)
{
for(k=0; k<125; k++)
;
}
}
/**********************************************************

**********************************************************/
void latch()
{
LE_573=1;
///OE , LE
_nop_();
// D Q(Q=D)
_nop_();
LE_573=0;
//LE ,
}
/**********************************************************

**********************************************************/
void main()
{
unsigned char n;
P0=0xff;
P2=0xff;
while(1)
{
for(n=0;n<11;n++)
{
P2=display[n];
latch();
delayms(500);
}
}
}
/**********************************************************/

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 196 -

ME950

Mcu Development Kit User tutorial

MAX485

1.
TT K1
ME950 RS485
welcome to www.willar.com

OK

2.

SWDIP 8

ME950 MAX485
U19
P30
P31
P17

JP28

RO
DI
EN

VCC

MAX485
VCC

2
1

8
6

R35
20K

R
B

3
4

RL1
120

R36
20K

J15
A
B
GND

1
2
3

GND

5.78 74HC573
MAX485 Maxim RS485
RO1 DI4 RXD TXD

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 197 -

ME950

Mcu Development Kit User tutorial

/RE2 DE3 /RE 0 DE


1 MAX485

A6 B7 , A B
1 A B 0 A B 120

RS485 RS485 RS232-RS485

3.

JP13 74HC573
JP29 74HC573
RS232-RS485 232 485 ME950 J15 485+
J15 A
485-B

GNDGND

TT TOOL K1 TT

5.79 74HC573

4.

5.80

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 198 -

ME950

Mcu Development Kit User tutorial

5.
Example_A51\EX26_MAX485
;********************************************************************
;*
*
;* ME950 - MAX485
*
;*
*
;* V1.0 (2010/01/25)
*
;* gguoqing
*
;* www.sofi-tech.com ()
*
;*
www.willar.com()
*
;* sofitech@tom.com
*
;*
*
;*Copyright(C) All Rights Reserved
*
;*
*
;*
*
;********************************************************************
;*
*
;*
*
;*
*
;* 1 K1
*
;* 2
*
;* 3 32
*
;*
*
;*******************************************************************/
COUNT
DISBUF

EQU
EQU

RE_DE
K1
FLAG

BIT P1.7
BIT P1.4
BIT 20H.1

ORG
AJMP
ORG
LJMP
ORG

2FH
30H

;
;

0000H
MAIN
0023H
T_SERIL
0050H

;*********************************************************
;
;*********************************************************
MAIN:
MOV SP,#60H
MOV P0,#0FFH
MOV P1,#0FFH
MOV P2,#0FFH
MOV TMOD,#20H
MOV TH1,#0FDH
MOV TL1,#0FDH
MOV SCON,#50H
ANL PCON,#00H
SETB EA
SETB TR1
ACALL BUF_INIT
SETB ES

; 1 8 ,
; 9600
; 1,
;
;
; 1
;

MAIN1:
JB K1,MAIN2
MOV R5,#10
ACALL DELAY
JB K1,MAIN2
SETB

; 100MS

RE_DE

;RS485

MOV DPTR,#TAB_1
ACALL SEND_STRING
MOV DPTR,#TAB_2
ACALL SEND_STRING
MOV DPTR,#TAB_3
ACALL SEND_STRING

; 1
; 2
; 3

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 199 -

ME950
MOV A,#'O'
ACALL TXD_CHAR
MOV A,#'K'
ACALL TXD_CHAR
MOV A,#0AH
ACALL TXD_CHAR

;O

CLR RE_DE
JB FLAG,MAIN3
AJMP MAIN1

;RS485
;

MOV R5,#10
ACALL DELAY
SETB RE_DE

MOV R0,#DISBUF
MOV R2,#00H

Mcu Development Kit User tutorial

;K
;

MAIN2:

MAIN3:
;RS485

MAIN4:
MOV A,@R0
ACALL TXD_CHAR
INC R0
INC R2
MOV A,R2
CJNE A,COUNT,MAIN4
ACALL BUF_INIT
AJMP

MAIN1

;*********************************************************
;
;*********************************************************
BUF_INIT:
MOV R0,#DISBUF
;
MOV R2,#00H
MOV A,#20H
CLR_1:
MOV @R0,A
; 32
INC R0
INC R2
CJNE R2,#32,CLR_1
MOV
MOV
MOV
CLR
RET

R0,#DISBUF
R2,#00H
COUNT,#00H
FLAG

;
;

;*********************************************************
;
;*********************************************************
TXD_CHAR:
CLR TI
MOV SBUF,A
;
JNB TI,$
;
CLR TI
;
RET
;*********************************************************
;
;*********************************************************
RXD_CHAR:
JNB RI,$
;
MOV A,SBUF
;
CLR RI
;
RET
;**********************************************************
;
;**********************************************************
SEND_STRING:
CLR A
MOVC A,@A+DPTR
JZ S_END
; 00H ,

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 200 -

ME950
ACALL TXD_CHAR
INC DPTR
SJMP SEND_STRING

Mcu Development Kit User tutorial

S_END:
RET
;**********************************************************
;
;**********************************************************
T_SERIL:
PUSH ACC
JNB RI,T_END
MOV B,SBUF
;
CLR RI
;
SETB FLAG
;
MOV A,COUNT
CLR C
CJNE A,#32,T_S1

; 32

T_S1:
JC T_S2
AJMP T_END
T_S2:
MOV
INC
INC

@R0,B
R0
COUNT

;
;

T_END:
POP ACC
RETI
;*********************************************************
; (R5*10)MS
;*********************************************************
DELAY:
MOV R6,#50
DEL1:
MOV R7,#93
DEL2:
DJNZ R7,DEL2
DJNZ R6,DEL1
DJNZ R5,DELAY
RET
;**********************************************************
;
;**********************************************************
TAB_1:
DB "ME950 RS485 "
DB 0AH
;
DB 00H
;
TAB_2:
DB
DB
DB
TAB_3:
DB
DB
DB

"welcome to www.willar.com "


0AH
;
00H
;
" "
0AH
;
00H
;

;*********************************************************
END

;*********************************************************

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 201 -

ME950

Mcu Development Kit User tutorial

6. C
Example_C51\EX26_MAX485
/*******************************************************************
* ME950 74HC573
*
*
*
* V1.0 (2010/02/12)
*
* gguoqing
*
* www.sofi-tech.com ()
www.willar.com() *
* sofitech@tom.com
*
*Copyright(C) All Rights Reserved
*
*
*
*
*
********************************************************************
* 74LS573 8 D
*
*
*
* 74LS573 1
*
*******************************************************************/
#include <reg52.h>
//51
#include <intrins.h>
// _nop_();
sbit LE_573 = P1^7;

//573

unsigned char code display[] =


{
0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90,0xff
};
/**********************************************************
t
11.0592MHz 1ms
**********************************************************/
void delayms(unsigned int t)
{
unsigned char k;
while(t--)
{
for(k=0; k<125; k++)
;
}
}
/**********************************************************

**********************************************************/
void latch()
{
LE_573=1;
///OE , LE
_nop_();
// D Q(Q=D)
_nop_();
LE_573=0;
//LE ,
}
/**********************************************************

**********************************************************/
void main()
{
unsigned char n;
P0=0xff;
P2=0xff;
while(1)
{
for(n=0;n<11;n++)
{
P2=display[n];
latch();
delayms(500);
}
}
}
/**********************************************************/

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 202 -

ME950

Mcu Development Kit User tutorial

6.2

PWM LED

1.
PWM
K1PWM ,P0 8 LED
K2PWM ,P0 8 LED
PWM

2.
LED 5.2 5.14
5.7

3.
CPU I/O LED JP9
JP8 JP15

1602LCD JP24 OFF 1602LCD 1602LCD LED

4.

5.
Example_A51\ EX27_PWM CONTROL LED

6. C
Example_C51\ EX27_PWM CONTROL LED

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 203 -

ME950

Mcu Development Kit User tutorial

1.
8 1-8

1
2
3
4
5
6
7
8

1
2
3
4
5
6
7
8

1
2
3
4
5
6
7
8

1
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8

1
2
3
4
5
6
7
8

;
1 ;
2
3
4
5
6
7
8 ; 2s
;

1
2
3
4
5
6
7
8

2.
5.9

3.
JP21 8 P2
JP22 9
P0 VCC
JP24 OFF LCD1602

4.

5.
Example_A51\EX28_7SEG Move L

6. C
Example_C51\EX28_7SEG Move L

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 204 -

ME950

Mcu Development Kit User tutorial

1.
8 1-8
1
2
3
4
5
6
7
8

;
;
1
2
3
4
5
6
7
8

1
2
3
4
5
6
7
8

1
2 1
3 2 1
4 3 2 1
5 4 3 2 1
6 5 4 3 2
7 6 5 4 3
8 7 6 5 4
8 7 6 5
8 7 6
8 7
8

; 2s
;

2.
5.9

3.
JP21 8 P2
JP22 9
P0 VCC
JP24 OFF LCD1602

4.

5.
Example_A51\EX29_7SEG Move R

6. C
Example_C51\EX29_7SEG Move R

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 205 -

ME950

Mcu Development Kit User tutorial

1.
8 1-8

1
2
3
4
5
6
7
8
1
2
3
4
5
6
7
8

1
2
3
4
5
6
7
8

1
2
3
4
5
6
7
8

1
2
3
4
5
6
7
8

1
2
3
4
5
6
7
8

1
2
3
4
5
6
7
8

1
2
3
4
5
6
7
8

1
2
3
4
5
6
7
8

;: ()
;

; 2s
;

;
;: ()
;
1
2
3
4
5
6
7
8

1
2
3
4
5
6
7
8

1
2 1
3 2
4 3
5 4
6 5
7 6
8 7
8

1
2
3
4
5
6
7
8

1
2
3
4
5
6
7
8

1
2
3
4
5
6
7
8

; 2s
;

2.
5.9

3.
JP21 8 P2
JP22 9
P0 VCC
JP24 OFF LCD1602

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 206 -

ME950

Mcu Development Kit User tutorial

4.

5.
Example_A51\EX30_7SEG Move LR

6. C
Example_C51\EX30_7SEG Move LR

1.
--HELLO

2.
5.9

3.
JP21 8 P2
JP22 9
P0 VCC
JP24 OFF LCD1602

4.

5.
Example_A51\EX31_7SEG Caption

6. C
Example_C51\EX31_7SEG Caption

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 207 -

ME950

Mcu Development Kit User tutorial

LCD12864 4

1.
LCD12864 8 4 8 D0-D7
4 D4-D7 4
4 4 4

2.
5.25

3.
1602LCDLED P0 P2 12864LCD
12864LCD
JP24 OFF 1602LCD
JP22 Vcc
LED JP9 Vcc
12864LCD ME950 J6 LED

4.

5.
Example_A51\EX32_LCD12864 4BIT

6. C
Example_C51\EX32_LCD12864 4BIT

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 208 -

ME950

Mcu Development Kit User tutorial

LCD12864

1.
12864LCD

2.
5.25

3.
1602LCD
LED P0 P2
12864LCD 12864LCD

JP24 OFF 1602LCD


JP22 Vcc
LED JP9 Vcc
12864LCD ME950 J6 LED

4.

5.
Example_A51\EX33_LCD12864 Serial

6. C
Example_C51\EX33_LCD12864 Serial

1.
K1

2.
5.7 5.14

3.
JP15
JP8 8

4.

5.
Example_A51\EX34_Buzzer Gun Sound

6. C
Example_C51\EX34_Buzzer Gun Sound

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 209 -

ME950

Mcu Development Kit User tutorial

1.

1) 245us 2KHz
2) 325us 1.5KHz

1) P3.7 2KHz 1
2) P3.7 1.5KHz 1
,

2.
5.7

3.
JP15

4.

5.
Example_A51\EX35_Buzzer Ambulance

6. C
Example_C51\EX35_Buzzer Ambulance

1.
,,

2.
5.7

3.
JP15

4.

5.
Example_A51\EX36_Buzzer Fire Engine

6. C
Example_C51\EX36_Buzzer Fire Engine

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 210 -

ME950

Mcu Development Kit User tutorial

0-99

1.
0-99 2

2.
5.9

3.
JP21 8 P2
JP22 9
P0 VCC
1602LCD JP24 OFF 1602LCD

4.

5.
Example_A51\EX37_0-99 Count

6. C
Example_C51\EX37_0-99 Count

0-99

1.
0-99 4

L 0
;
H 99
;

K1 --- UP
K2 --- DOWN
K3 ---
K4 ---

L ---
H ---

K4
K3
0 K4
0
K1K2K4
K3

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 211 -

ME950

Mcu Development Kit User tutorial

(DL11 )
(DL11 )

2.
5.9 5.7 5.5 5.14

3.
I/O I/O
JP21
JP22 VCC
JP15
JP16
JP8
1602LCD JP24 OFF 1602LCD

4.

5.
Example_A51\EX38_ 0-99 Count Down

6. C
Example_C51\EX38_ 0-99 Count Down

1.
8
K1 /
K4
K4
10

2.
5.9 5.7 5.14

3.
I/O I/O
JP21
JP22 VCC
JP15
JP8
1602LCD JP24 OFF 1602LCD

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 212 -

ME950

Mcu Development Kit User tutorial

4.

5.
Example_A51\ EX39_STOPWATCH 7SEG

6. C
Example_C51\ EX39_STOPWATCH 7SEG

1602

1.
1602LCD
K1 /
K4
K4
LCD1602 10 K1

2.
5.7 5.14 5.20

3.
I/O I/O
JP241602LCD ON
JP251602LCD 1602LCD
JP15
JP8
JP22 Vcc 1602LCD

4.

5.
Example_A51\ EX40_STOPWATCH LCD1602

6. C
Example_C51\ EX40_STOPWATCH LCD1602

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 213 -

ME950

Mcu Development Kit User tutorial

1.
8

2.
5.9

3.
I/O I/O
JP21
JP22 VCC
1602LCD JP24 OFF 1602LCD

4.

5.
Example_A51\EX41_SIMPLE CLOCK 7SEG

6. C
Example_C51\ EX41_SIMPLE CLOCK 7SEG

1602

1.
1602

2.
5.20

3.
JP241602LCD ON
JP251602LCD 1602LCD
JP22 Vcc 1602LCD

4.

5.
Example_A51\EX42_SIMPLE CLOCK LCD1602

6. C
Example_C51\EX42_SIMPLE CLOCK LCD1602

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 214 -

ME950

Mcu Development Kit User tutorial

1.
8
K4
K1
K2

2.
5.7 5.9 5.14

3.
I/O I/O
JP21
JP22 VCC
JP15
JP8
1602LCD JP24 OFF 1602LCD

4.

5.
Example_A51\EX43_UNIVERSAL CLOCK 7SEG

6. C
Example_C51\EX43_UNIVERSAL CLOCK 7SEG

1602

1.
1602
K4
K1
K2

2.
5.7 5.14 5.20

3.
I/O I/O
JP241602LCD ON
JP251602LCD 1602LCD
JP15
JP8
JP22 Vcc 1602LCD

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 215 -

ME950

Mcu Development Kit User tutorial

4.

5.
Example_A51\ EX44_UNIVERSAL CLOCK LCD1602

6. C
Example_C51\ EX44_UNIVERSAL CLOCK LCD1602

1.
8
8
235950
10
000000 24 24
30
000030
000100

K1:
K2:
K3:
K4:
1)
K4:
K2:
K3:
K4
K4
2)
K2:
K2 000030
K2 ,
3)
K1:
K2:
K3:

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 216 -

ME950

Mcu Development Kit User tutorial

K1 K1
4
K3:

30
K3

2.
5.5 5.7 5.9 5.14

3.
I/O I/O
JP21
JP22 VCC
JP15
JP16
JP8
1602LCD JP24 OFF 1602LCD

4.

5.
Example_A51\EX45_ ALARM CLOCK 7SEG

6. C
Example_C51\EX45_ ALARM CLOCK 7SEG

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 217 -

ME950

Mcu Development Kit User tutorial

1602

1.
1602
LCD1602
ALARM CLOCK
TIME: 235950

10
LARM CLOCK
TIME: 00:00:00
30
ALARM CLOCK
TIME: 00:00:30
ALARM CLOCK
TIME: 00:01:00

24 24

K1:
K2:
K3:
K4:
1)
K4:
K2:
K3:
SET REAL_TIME
TIME: 23:59:50
K4
K4
2)
K2:
K2
LOOK ALARM_TIME
TIME: 000030
K2 ,
3)
K1:
K2:
K3:
SET ALARM_TIME
TIME: 00:00:30

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 218 -

ME950

Mcu Development Kit User tutorial

K1 K1
4
K3:
LCD1602 2 15

30
K3

2.
5.5 5.7 5.14 5.20

3.
I/O I/O
JP241602LCD ON
JP251602LCD 1602LCD
JP15
JP16
JP8
JP22 Vcc 1602LCD

4.

5.
Example_A51\ EX46_ALARM CLOCK LCD1602

6. C
Example_C51\ EX46_ALARM CLOCK LCD1602

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 219 -

ME950

Mcu Development Kit User tutorial

DS18B20 ()

1.
DS18B20 8

1 2
3 6
7 LH
DS18B20
DS18B20 18.8
DS18B20

1)
K1 TH :
H 28
TH: 28
K1 TL :
L 20
TL: 20

K1
2)
K3 TH :
H 28
K3 TL :
L 20
K3
K1 UP
K2 DOWN

DS18B20 EEROM DS18B20


EEROM

1) TH 7 H
2 TL 7 L
3 TH DL11 (LED)

2.
5.5 5.7 5.9 5.14 5.63

3.
I/O I/O

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 220 -

ME950

Mcu Development Kit User tutorial

JP21
JP22 VCC
JP15
JP16
JP8
1602LCD JP24 OFF 1602LCD

4.

5.
Example_A51\EX47_DS18B20 7SEG

6. C
Example_C51\EX47_DS18B20 7SEG

DS18B20 (1602 )

1.
DS18B20 1602
DS18B20
DS18B20 LCD

DS18B20 DS18B20 ROMCORD LCD

2 LCD1602

LCD1602

TEMP: 21.3

TH: 24 TL: 19

1) DS18B20 ROMCORD
K1 DS18B20 ROMCORD
K2

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 221 -

ME950

Mcu Development Kit User tutorial

2)
K3
TH
TL

K1 (UP)
K2 (DOWN)

K4
LCD1602 LCD1602

TH TH
TL TL

2.
5.5 5.7 5.14 5.20

3.
I/O I/O
JP241602LCD ON
JP251602LCD 1602LCD
JP15
JP16
JP8
JP22 Vcc 1602LCD

4.

5.
Example_A51\ EX48_DS18B20 LCD1602

6. C
Example_C51\ EX48_DS18B20 LCD1602

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 222 -

ME950

Mcu Development Kit User tutorial

1.

D00
D01
D02
K1

2.
5.2 5.14 5.38

3.
I/O I/O
JP9LED
JP8
1602LCD JP24 OFF 1602LCD P0 LED

4.

5.
Example_A51\EX49_STEP MOTOR Variable

6. C
Example_C51\EX49_STEP MOTOR Variable

1.

K1 D00
K2 D01

2.
5.2 5.14 5.38

3.
I/O I/O
JP9LED
JP8
1602LCD JP24 OFF 1602LCD P0 LED

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 223 -

ME950

Mcu Development Kit User tutorial

4.

5.
Example_A51\EX50_STEP MOTOR KEY

6. C
Example_C51\EX50_STEP MOTOR KEY

1.
1602
5
UP >>>>
DOWM <<<<
K1 STOP


K1

2.
5.7 5.20 5.66

3.
I/O I/O
JP241602LCD ON
JP251602LCD 1602LCD
JP15
JP10
JP22 Vcc 1602LCD

4.

5.
Example_A51\EX51_STEP MOTOR IR

6. C
Example_C51\EX51_STEP MOTOR IR

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 224 -

ME950

Mcu Development Kit User tutorial

1.
LCD1602

1F
F(3 )LCD1602

2
0-9
10
LCD1602

LCD1602

10
3

A LCD1602

B LCD1602

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 225 -

ME950

Mcu Development Kit User tutorial

C
E
D 10
987654

2.
5.5 5.7 5.18 5.20

3.
I/O I/O
JP241602LCD ON
JP251602LCD 1602LCD
JP15
JP16
JP7
JP22 Vcc 1602LCD

4.

5.
Example_A51\EX52_Electronic Code Lock

6. C
Example_C51\EX52_Electronic Code Lock

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 226 -

ME950

Mcu Development Kit User tutorial

5.3
TFT +SD () ME950
SD/MMC 1.8 TFT 3.3V 28Pin DIP ISP
ATmega88V AVR SD
TFT ME950
TFT ()TFT TFT
TTF 12864
Examples_TFT+SD
TFT +SD

TFT +SD

TFT +SD

SD/MMC
1.8 128x160
28Pin DIP ATmega88V AVR
ISP
40Pin ME950
SD AVR TFT TFT
TFT ......

1. 51
TFT+SD DIP28Pin U2 ATmega88V
51 TFT+SD J5
ME950 J4

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 227 -

ME950

Mcu Development Kit User tutorial

51 TFT

TFT

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 228 -

ME950

Mcu Development Kit User tutorial

2. AVR
U2 ATmega88V DIP40 ISP ME950 JP2
J4 ME950 J4 ME950
JP1 AVR

AVR
SFISP ATmega88V[ISP][ISP]ISP
"Clock source and start-up time"
RC Int. RC Osc. ...Reset disabled...
ISP
-------------------------------------------------------------------------------------------

ME950

ME950

ME950

Gguoqing
www.sofi-tech.com
www.mcu01..com
2012-03

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 229 -

ME950
1

Mcu Development Kit User tutorial

1.PWR?
ME950 CPU 500mA
PWR LED
USB

2.?

1)
2)

3)->->->

3.LED
1602LCD12864LCD16 LED P0 P2

1602LCD 12864LCD JP22 VCC


1602LCD 1602LCD
JP24 OFF 1602LCD ON
2

4.
ME950

1602LCD ME950 1602LCD JP24


OFF 1602LCD 1602LCD P0P2
JP22 VCC
16x16LED JP23 VCC
LED JP9 VCC

5. ID ?
ID

6. ?
( AVR )

1AVR AVR ME950


ISP

ISP
RESET IO

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 230 -

ME950

Mcu Development Kit User tutorial

, RC ,
.
2ISP . ISP , ISP .
3
4 ISP WINBOND/NXP
ISP
5 AT89S52 AT89S52[ZIF],
AT89S52[ISP],

7. ISP ?
ISP In System Programming
ISP ISP

ME950 ISP : ISP ,


[ISP]

8.ME950
ME950
I/O CPU I/O
PCB

ME300B
4066

CPU I/O

ME950
ME950

9. C ?
C

10.
4.3

SFISP
22uF
SFISP

11.
Keil C ( C )Keil
Keil
C

12.ME950 ICE52

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 231 -

ME950

Mcu Development Kit User tutorial

RAM

ME950 USB2.0 51 ICE52


8051/8052

51 SST
SST
keil T2 8

13.
www.mcu01.com www.willar.com

Email

ME950

0755-84867757

www.sofi-tech.com

www.mcu01.com

- 232 -