The first program, learning SCM together! (Lm3s811)

Source: Internet
Author: User

Reprinted please indicate the source: http://blog.csdn.net/icyfox_bupt

Documentation:Http://url.cn/30W8lo

Hello everyone, I am a fox. I learned SCM together in the school lab. Now I will share some of my learning experience with you. As I learn more, I will continue to improve. Hope myArticleIt will help you.

The lab usesCOrtex m3 lm3s811 model.


I wanted to upload the driver library, schematic diagram, and internal principles to Baidu Library. The result was not allowed to be uploaded in harmony. If you need a friend, leave a mailbox and I will package it for you. These documents are really useful. For function parameters, the internal connection structure is clearly described. It is really essential for programming!

 

Keil uvision4 software is used for reading and writing single-chip microcomputer. Download addresses and cracked versions are available on the Internet. After the download is complete, we recommend that you also put the driver library of lm3s811 in the strllarisware folder.

 

This section describes my current directory relationships. Under the. folder

../Lab (store mySource code)

../Keil (ProgramUse)

../Strllarisware (driver Library)

 

After preparing for the above, you need to program the project!

Open the Keil uvision4 software, and a project will be automatically opened, so we don't care about it and do our own program. Select project --> New uvision project... (if an error occurs, project --> close project ...).

Create a folder and create a project in it. The intermediate files and required files during project compilation will appear in this folder.


Select lm3s811 under luminary micro.


Select "yes" in the displayed selection box ".

Okay. now an empty project is ready!

click the" new "button in the upper left corner, and write some Code in it, as shown below:

# Include "INC/hw_types.h" <br/> # include "INC/hw_memmap.h" <br/> # include "driverlib/sysctl. H "<br/> # include" driverlib/gpio. H "<br/> int main () <br/> {<br/> sysctlclockset (sysctl_osc_main | sysctl_xtal_6mhz | sysctl_use_osc | sysctl_sysdiv_1 ); <br/> // configure the system clock (using the primary oscillator | 6 MHz external crystal oscillator | not applicable to PLL | System Frequency Division 1) <br/> sysctlperipheralenable (sysctl_periph_gpioc ); <br/> // enable the gpioc module. This module is one of the modules used by the Board for input and output. <br/> gpiodirmodeset (gpio_portc_bas E, gpio_pin_5, gpio_dir_mode_out); <br/> // set the pin5 of gpioc to the out mode, that is, the Pc5 (a small light) on the board is converted to the output. <Br/> gpiopadconfigset (gpio_portc_base, gpio_pin_5, gpio_strength_2ma, gpio_pin_type_std); <br/> // set some details <br/> while (1) {// keep the program running in an endless loop <br/> gpiopinwrite (gpio_portc_base, gpio_pin_5, 0xff); // assign Pc5 to 1 <br/> sysctldelay (sysctlclockget () /6); // 1 s latency <br/> gpiopinwrite (gpio_portc_base, gpio_pin_5, 0x00); // assign Pc5 to 0 <br/> sysctldelay (sysctlclockget () /6); // 1 s latency <br/>}< br/>}

 

Save the file as a. c file in the same directory of the project.

In this case, the project cannot be run. We need to add files to the project and configure the environment.

In the left column, right-click "Source group 1" and choose "add files to group" Source group 1 "" to add the source code file we just wrote. Go to "../strllarisware/driverlib/rvmdk/driverlib. lib" and add the file. This is the driver library used for driver writing.

Right-click "target1" on the left and select "Options for target1 ..".

You can change the CPU in the device, and change the "xtal MHz" on the left to 6.0 in the target, in C/C ++, change the "include path" in the last three rows to the strllarisware folder (for example, "E:/study/strllarisware "), make the following changes in utilities:

Choose J-LINK or U-LINK or something else to watch our device, open settings, click "add", add ls3mxxx 64kb flash

 

In this way, we can compile and run it!

The program will flash the Pc5 light once every second. The principle will be continued tomorrow!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.