Welcome to www.agpgames.com ---- HANGZHOU KinCony ELECTRONICS CO.,LTD.
About Us Contact Us          Our Patents Our Articles        Forum      SiteMap    Chinese Version

Chapter 1. Overview Chapter 2. Emulation Guide Chapter 3. Build Your First Project Chapter 4. In System Programming
Chapter 5. USB Interface Installation Chapter 6. LED Display Application Chapter 9. FAQ Chapter 10. System Configuration and Service
 
Chapter 7. Basic Experiments
7.1. Experiment with LED 7.2. Experiment with Flowing LEDs 7.3. Experiment with Keys 7.4. Experiment with Beeper
7.5. Experiment with Relay 7.6. Experiment with LED Display 7.7. Experiment with Serial Port  
 
8.1. Experiment with Matrix Key 8.2. Experiment with Stepping Motor 8.3. Experiment with 1-Wire Digital Thermometer DS18B20
8.4. Experiment with 24C01 EEPROM 8.5. Experiment with 93C46 Serial EEPROM 8.6. Experiment with DS1302 Real-time Clock
8.7. Experiment with 8-bit Serial AD Converter ADC0832 8.8. Experiment with 1602 Character LCD Module 8.9. Experiment with 12864 Graphic LCD
8.10. Experiment with Infra-red Remote Controller 8.11. Experiment with Wireless Encoding Module Chapter 11. User Feedback

Chapter 3. Build Your First Project

Build Your First Project

To start a new project, we should first create a project.

Click ‘Project’ – ‘New uVision Project...’.

 

Name the project file to ‘my.uv2’.

Now, choose the device we need to experiment with. Here, we select Atmel AT89S51, a very popular MCU.

After the MCU is chosen, Keil will ask to add startup code to the project. We click no.

Till now, our project is created.

We can write source code in the Keil uVision IDE. Our example codes are the minimum codes needed to light up a LED.

Click ‘File’ – ‘New...’

Type below codes in the popped text editor.

loop:

CLR P1.0

Ajmp loop

END

Only 4 statements are used in this example.

CLR P1.0 will set the MCU P1.0 to low level. From the schematic, we know that to light the LED up, we need to set P1.0 to low.

The first line ‘loop’ is a label. ‘Ajmp loop’ force the program to jump to the position where label loop locates.

END is the ending of the program.

A simple program is finished. Now click ‘File’ – ‘Save As...’ to save the file, and name it to ‘led.asm’. Notice that ‘.asm’ is its file extension, because codes are in assemble language. If C language is used, we should name the file with ‘.c’.

With the project ‘my’ we created, and source code file ‘led’ we wrote, now we should add the source code file into the project. Click the left ‘plus’ and right click ‘Source Group’, then click ‘Add files to Group ‘Source Group 1’. Select ‘led.asm’ and click ok to add it into our project.

Now it’s time to compile all the source files, and generate target file that will be programmed into AT89C51 later on.

To generate hex file for programming, some settings are needed before compiling. Right click ‘Target 1’ and select ‘Options for Target ‘Target 1’.

Activate the ‘Output’ sheet in ‘Options for Target ‘Target 1’, and enable ‘Create HEX file’ option. Then click OK to confirm the setting.

Now, press shortcut F7 to start compiling. ‘my.hex’ file will be generated in the directory where ‘led.asm’ is located. It’s a hexadecimal file that can be used to program a MCU.

To see if the generated hex file is what we need the MCU to do, we can emulate it in our KinCony 8051 MCU Development Platform.

Repeat the before-mentioned process, activate the ‘Target’ sheet and set ‘Xtal (MHz)’ to 11.0592 which is the emulation frequency.

Select ‘Debug’ sheet, and choose ‘Use: Keil Montor-51 Driver’.

Then click ‘Settings’ to set proper COM port number and Baudrate in the popped dialog. In this example, we use COM1 and 38400bps.

Till now, all settings for emulation have been done. Let’s click ‘Debug’ – ‘Start/Stop Debug Session’, or press the shortcut to run the debug.

Click ‘Debug’ – ‘Run’ or press the shortcut to run the program. You will see the first LED p1.0 lighted up as we hope so.

To end the emulation, press the reset key in the board, and then click ‘Debug’ – ‘Start/Stop Debug Session’ again to exit the emulation.



COPYRIGHT2003--2008 HANGZHOU KinCony ELECTRONICS CO.,LTD. All Rights Reserved

Add:Rm 11-3-702, Pujing Jiayuan, Gongshu District, Hangzhou, Zhejiang, China.
Tel:+86-0571-87615070,Fax:+86-0571-87615070 E-mail: hificat@163.com  ICQ:164806453  Webmaster:Hificat