Application Programming Practice of VxWorks for lpc2210 ZZ

Source: Internet
Author: User

Sender: gdtyy (gdtyy), email area: embedded
Title: VxWorks for lpc2210 Application Programming Practice
Mailing station: shuimu community (Mon Jun 25 23:25:15 2007), within the station

***********************************
* VxWorks for lpc2210 application programming practices *
***********************************
------ Choose "ECOs value-added package" and choose VxWorks application programming practices
Asdjf@163.com www.armecos.com

Vxworks_romresident.bin trial download 483 K

For the ECOS value-added package, you can select VxWorks for lpc2210 so that
Develop the VxWorks application on smartarm2200. This option is not sold separately and does not contain BSP source code. You need to purchase it separately.
Development environment. If you have met these requirements, I hope the following articles will help you develop the VxWorks application.
Help.

Like ECOs, VxWorks is a multi-task operating system developed using the GNU tool chain, but the API function name is slightly
Therefore, we use the two demo programs introduced in ECOs to explain the development of VxWorks application programming.
Method.

Similar to ucos51 and ECOs, when using the operating system for the first time, you can run multiple tasks first. demo1 demonstrates multiple tasks.
Concurrent Operation (Note: This site also sells the ucos51 software package, 51 engineers can also run the OS ). Three thread tasks print information at the same time
Thread a prints data once per second, thread B prints data once every 3 seconds, and thread C prints data once every 6 seconds. Comparing these programs, in fact
That is, the API function name is different, and the idea is the same. This means that the OS abstracts the hardware and time stream, so that we are closer
The essence of application. The following is the demo1 source code:

# Define stack_size 2000

Void TASKA (INT Arg );
Void taskb (INT Arg );
Void taskc (INT Arg );

Void demo1 (void)
{
Printf ("demo1 start.../N ");

Taskspawn ("TASKA", 90, 0, stack_size, TASKA, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 );

Taskspawn ("taskb", 90, 0, stack_size, taskb, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0 );

Taskspawn ("taskc", 90, 0, stack_size, taskc, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0 );
}

Void TASKA (INT Arg)
{
For (;;)
{
Printf ("/taaaaaa111111 is active. Thread data is % d./N", ARG );
Taskdelay (100 );
}
}

Void taskb (INT Arg)
{
For (;;)
{
Printf ("/tbbbbbbbb333333 is active. Thread data is % d./N", ARG );
Taskdelay (300 );
}
}

Void taskc (INT Arg)
{
For (;;)
{
Printf ("/tcccccc666666 is active. Thread data is % d./N", ARG );
Taskdelay (600 );
}
}

As shown in the preceding figure, taskspawn is used for tasks created in VxWorks, and taskdelay is used for delay. The following table compares
The names of tasks and task latencies in ucos51, ECOs, and VxWorks.
------------------------------------------------------
| Create a task | task latency |
------------------------------------------------------
| Ucos51 | ostaskcreate | ostimedly |
------------------------------------------------------
| ECOs | cyg_thread_create | cyg_thread_delay |
------------------------------------------------------
| VxWorks | taskspawn | taskdelay |
------------------------------------------------------

VxWorks function Syntax:

Task No. = taskspawn (name, priority, option, stack size, task function name, parameter 1,... Parameter
10 );
Taskdelay (number of tick delays );

Test the program running result. The demo1 program creates three tasks A, B, and C with a priority of 10 and A is displayed once per second.
, B is displayed every 3 seconds, and C is displayed every 6 seconds. From the display results, after 3 A is displayed, 1 B is displayed, and 6 A and 2 are displayed.
After B, 1 C is displayed, and the result is correct.

(Demo1 run)

The following demo2 example is an application that controls gpio to make the buzzer sound. It stops for 1 second and starts again and again.

# Define hal_write_uint32 (_ register _, _ value _)/
(* (Volatile unsigned int *) (_ register _) = (_ value _))

# Define lpc2xxx_gpio_io0set 0xe0028004
# Define lpc2xxx_gpio_io0dir 0xe0028008
# Define lpc2xxx_gpio_io0clr 0xe002800c

# Define stack_size 2000
# Define beepcon 0x0000080

Void task (void );

Void demo2 (void)
{
Printf ("demo2 start.../N ");

Taskspawn ("task", 90, 0, stack_size, task, 0, 0, 0, 0, 0, 0 );
}

Void task (void)
{
Hal_write_uint32 (lpc2xxx_gpio_io0dir, beepcon );

For (;;)
{
Hal_write_uint32 (lpc2xxx_gpio_io0set, beepcon );
Taskdelay (100 );
Hal_write_uint32 (lpc2xxx_gpio_io0clr, beepcon );
Taskdelay (100 );
}
}

As can be seen from the above, VxWorks supports direct register operations, using flat memory mode, and ECOs to operate hardware I/O
Same method.

Note: The application uses/**/for comments. If you use "//" for comments, you need to remove the-ANSI compilation option.

The following figure shows how to use it:

First, write the vxworks_romresident.bin file in the flash of the board and set the jumper. After power-on, you will see
Go to the console shell interface,

Open tornado and create a downloadable project,

(New project diagram) 1, 2, 3
[Img] http://bbs.21ic.com/upfiles/img/20074/2007423101550549.jpg#/img]
[Img] http://bbs.21ic.com/upfiles/img/20074/2007423101617722.jpg#/img]
[Img] http://bbs.21ic.com/upfiles/img/20074/2007423101639274.jpg#/img]

Add the demo file and compile it. A message is displayed, indicating that the dependent file is generated. Select OK.

4, 5
[Img] http://bbs.21ic.com/upfiles/img/20074/2007423101659764.jpg#/img]
[Img] http://bbs.21ic.com/upfiles/img/20074/2007423101716328.jpg#/img]

Set the target server (Configuration File Settings) and use serial communication. The 9600 baud rate, as if the maximum speed is
38400. If it is too high, it is not easy to connect successfully. If you use the network, it will be faster. Note: In core file and symbols
The file must be consistent with the VxWorks file written in flash, that is, the ELF File With debugging information. The connection is displayed
A target icon appears in the tray.

6, 7, 8, 9
[Img] http://bbs.21ic.com/upfiles/img/20074/2007423101736432.jpg#/img]
[Img] http://bbs.21ic.com/upfiles/img/20074/2007423101751982.jpg#/img]
[Img] http://bbs.21ic.com/upfiles/img/20074/200742310187477.jpg#/img]
[Img] http://bbs.21ic.com/upfiles/img/20074/2007423101821792.jpg#/img]

Download the. Out File

10
[Img] http://bbs.21ic.com/upfiles/img/20074/2007423101848188.jpg#/img]

Start the target debugger and click the ant icon. Open the source file, set the breakpoint, and click
Run the villain icon to debug it. It supports various debugging methods such as single step and full speed. The task running letter will be asked at the beginning.
Number name and parameter. Set it.

13, 14, 11
[Img] http://bbs.21ic.com/upfiles/img/20074/200742310197112.jpg#/img]
[Img] http://bbs.21ic.com/upfiles/img/20074/2007423101921536.jpg#/img]
[Img] http://bbs.21ic.com/upfiles/img/20074/2007423101937197.jpg#/img]
Serial Port 0 console running effect

12
[Img] http://bbs.21ic.com/upfiles/img/20074/2007423101956852.jpg#/img]

Click the-> I icon to start the host shell. Enter I to view the running status of the task. There are four tasks at the beginning
Line task, log task, shell terminal, wdb debug resident task. Enter I for query after running demo1.
Three more tasks are created: TASKA, taskb, and taskc, which are exactly the three tasks we created in demo1. You can see clearly
Task priority, remaining Delay Time, status, and other information.

15, 16
[Img] http://bbs.21ic.com/upfiles/img/20074/2007423102015154.jpg#/img]
[Img] http://bbs.21ic.com/upfiles/img/20074/2007423102030305.jpg#/img]
--

※Source: · Shui Mu community http://newsmth.net · [from: 61.149.56. *]
 

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.