Home
OSs-Micrium-Learning Centre-Application Notes
Contents
1. pu C OS II documentation O Source Target uC Probe yC OS II processor Communication Ei Target CS ei source E C3 Communication RS 232 E 3 Generic Communication E os e ucos E O Rs 232 uC Probe a Qos LPC24xx RS 232 O ucos I Port E Ports El C3 NxP C3 LPC24xx Ce Source O Source El C3 Plugins O cos Figure 2 1 Directory Structure 10 Micripm uC OS Il and pC Probe for the NXP LPC2478 CPU 2 03 Using the IAR Project An IAR project file named LPC2478 EA OS Probe v5 2 eww is located in the directory marked IAR Example Project in Figure 2 2 Micrium Software EvalBoards NXP LPC2478 EA IA R OS Probe To view this example project start an instance of IAR EWARM and open the workspace file LPC2478 EA OS Probe V5 2 eww To do this select the Open menu command under the File menu select the Workspace submenu command and select the workspace file after navigating to the project directory The project tree shown in Figure 2 3 should appear In addition the workspace should be openable by double clicking on the file itself in a Windows Explorer window The example project LPC2478 EA OS Probe v5 2 eww is intended for EWARM v5 2x 2 03 01 pu C OS II Kernel Awareness When running the IAR C Spy debugger the uC OS II Kernel Awareness Plug In can be used to provide useful information about the status of uC OS II objects and
2. delayO0 BSP ADC GetStatus BSP ADC POT 32 OSTimeDlyHMSM 0 0 delayO 1000 BSP LED Off 0 delayO 1000 delayO0 BSP ADC GetStatus BSP ADC POT OSTimeDlyHMSM 0 0 delayO 1000 delayO 1000 leds 0 1 while it msg OSQAccept AppKbdQ amp err X leri OS Q meus meg break ted PU_INT32U imsg aise led sy di break leds 1 lt lt led if leds 0 continue woe 5 Oe 3 2027 wx 4 figa al dip al lt dip stp 4 if leds amp 1 lt lt i T BSP LED Toggle i Note 7 votel 9 i Note 8 il lt lt lt a d delayl BSP ADC GetStatus BSP ADC POT gt gt 2 32 OSTimeDlyHMSM 0 0 delayl 1000 delayl 1000 Listing 4 2 App TaskStart 20 Micripm uC OS Il and pC Probe for the NXP LPC2478 CPU Listing 4 2 Note 1 BSP Init initializes the Board Support Package the I Os tick interrupt etc See Section 5 for details Listing 4 2 Note 2 OSStatInit initializes uC OS Il s statistic task This only occurs if you enable the statistic task by setting OS TASK STAT ENto 1 inos cfg h The statistic task measures overall CPU usage expressed as a percentage and performs stack checking for all the tasks that have been created with OSTaskCreateExt with the stack checking option set Listing 4 2 Note 3 If uC OS Probe is enabled then the module s initializ
3. OS Events OS Timers OS Configuration General OS Configuration Everks Timers Application Start Button This workspace is an example pC Probe workspace for g ETET the EA LPC2478 evaluation board which employs the 85232 Serial Output This button ox dioe NXP LPC2478 processor Accompanying this 3 OSDataSize workspace is the source code for this example mL pr pre ee ficere between Design lorica and Run Time OSEvenEn Epo s ia DSEvertMax SEventNameSize Views During OSE vet BSie H H FlagEn Run Time View E 2 when data is collected this will appear as a stop button a blue square Download the code onto the target start execution on the target and then press the Start button on the Home tab in this program The components to the right labels LEDs gauges and spreadsheets will begin to update with values from the target uC Probe can download data from the EA LPC2468 through RS 232 at 115200 baud or through a J Link OSFlagMax OSFlagNameSize OSFlagNodeSize OSFlagwidih OSLowestPrio OSMboxE nv OSMemEn OSMemMax OSMemNameSize OSMemSize OSMemTbiSize For more information about this workspace or about pC Probe refer to the pC Probe user manual or visil www micrium com OSMutexEn SPtSize OSQEn Ha pE aE i Data Screen Os0See OOOO Em Components are placed ossenen onto the data screen and assigned symbols duri
4. ThreadX pC 05 l Code Coverage ORTI RTOS LMI FTDI Macraigor RDI Third Party Driver Description RTOS awareness for CMX C Program FilesNA amp R Systems E mbedded Workbench 5 2 IAR Systems 5 20 0 50993 Location Originator Version Figure 2 2 Enabling the u C OS II Kernel Awareness Plug In 4 Name Start Task 3 1 Dly 784 25 400032B0 48 34 248 176 512 40003360 40003160 Keyboard 6 2 Dly 33 409 400034E0 45 25 232 128 512 40003560 40003360 Probe Str g 3 Dly 534 5 40003AD0 37 28 192 144 512 40003B60 40003960 Joystick 8 4 Dly 34 90 400036D0 37 28 192 144 512 40003760 40003560 Serial RS232 7 5 Dly 1 1192 400038D8 40 26 208 136 512 40003960 40003760 Probe 0S PlugIn 4 6 Dly 8 806 400044C8 48 29 248 152 512 40004560 40004360 Probe RS 232 5 11 Sem 0 Probe RS 232 1 40002DA0 17 12 176 128 1024 40002E20 40002420 uC OS II Tmr 2 29 Sen 0 OS TmrSig 46 400040E0 34 25 176 128 512 40004160 40003F60 uC OS II Stat 1 30 Dly 30 50 40003CF8 29 20 152 104 512 40003D60 40003B60 gt uC OS II Idle 0 31 Ready 0 2340 40003F08 20 17 104 88 512 40003F60 40003D60 Task List Semaphore List x Figure 2 3 p C OS II Task List for LPC2478 EA OS Probe V5 2 ewp 2 05 Example Application Once the program is loaded onto the target the LEDs will begin turning on one by one The LEDs will then be all turned off If any of the push buttons have been pressed since this last occurred then the correspondi
5. This directory contains Jib def h which provides defines for useful constants like DEF TRUE and DEF DISABLED and macros Micripm uC OS Il and pC Probe for the NXP LPC2478 CPU Micrium Software uC LIB Doc This directory contains the documentation for pC LIB Application Code Micrium Software EvalBoards NXP LPC2478 EA IAR OS Probe This directory contains the source code the example application app c contains the test code for the example application including calls to the functions that start multitasking within pC OS II register tasks with the kernel and update the user interface the LEDs and the push buttons app cfg h is a configuration file specifying stack sizes and priorities for all user tasks and defines for important global application constants includes h is the master include file used by the application os cfg h is the nC OS II configuration file LPC2478 EA OS Probe v5 2 are the IAR Embedded Workbench project files LPC2478 EA OS Probe Workspace wsp is an example uC Probe workspace Micrium Software EvalBoards NXP LPC2478 EA IAR BSP This directory contains the Board Support Package for the Embedded Artists LPC2478 OEM evaluation board bsp c contains the board support package functions which initialize critical processor functions e g the PLL and provide support for peripherals such as the push button and potentiometer bsp h contains prototypes for functions that may be called by t
6. ANSIW iis2008 N 1 SCROLL caes Num Capture Print echo Figure 2 3 Example Application serial output The RS 232 port labeled as UART 2 is used for pC Probe at 115200 baud which allows you to view in real time the value of static global variables in the target system 2 05 0 Additional Information Including the uC OS IM system tasks the example application includes ten tasks as listed in Table 2 1 The board hardware used in the application is diagrammed in Figure 2 4 Micripm uC OS Il and pC Probe for the NXP LPC2478 CPU TaskName Promy Function SSCS App T Start vim Tan re Starts pC OS Probe reads ADCs blinks LEDs App TaskKbd 2 Reads status of push buttons passes IDs of pressed Keyboard buttons to App TaskStart in a queue App T ProbeSt PEE an Outputs strings to the Windows pC Probe program App TaskJoy Increment decrement the state of the system screens Joystick base on the joystick status C M Outputs information through the RS 232 port Probe OS Plugin 6 UbdaesCPUusageioruCiProe Table 2 1 Example Application Tasks The project is configured so that code is loaded into Flash and the stacks and data are loaded into RAM as shown in Table 2 2 Memory Range Sie Segment s 512 KB Code in Fash KG Stacks and data n RAND Table 2 2 Example Application Tasks UART2 u C OS Probe LI PCA9532 ame B4 LED4 Acceler
7. a different directory The following files are in this directory os_cpu h OS_cpu_d asm OS cpu c c Os dcc c os dbg c With this port uC OS II can be used in either ARM or Thumb mode Thumb mode which drastically reduces the size of the code was used in this example but compiler settings may be switched as discussed in Section 2 30 to generate ARM mode code without needing to change either the port or the application code The ARM Thumb port is described in application note AN 1014 which is available from the Micrium web site Micrium Software uCOS I Source This directory contains the processor independent source code for u C OS II Micripm uC OS Il and pC Probe for the NXP LPC2478 CPU yu C Probe Files Micrium Software uC Probe Communication Generic This directory contains the pu C Probe generic communication module the target side code responsible for responding to requests from the pu C Probe Windows application including requests over RS 232 Micrium Software uC Probe Communication Generic Source This directory contains probe com c and probe com h the source code for the generic communication module Micrium Software uC Probe Communication Generic OS uCOS II This directory contains probe_com_os c which is the un C OS II port for the n C Probe generic communication module Micrium Software uC Probe Communication Generic Source RS 232 This directory contains the RS 232 specific code for uC Probe generic comm
8. queue update period 10 iv sec C Calculate communication timeout automatically Wait Time 10 me Figure 6 2 uC Probe Options 4 Micrium pC Probe LPC2478 EA OS Probe Workspace wsp OS About OS General Info OS Task CPU Usage OS Task Stack Usage OS Task Into OS Everts 05 Timers OS Configuration General OS Configuration Events Timers Application App EALPC2478 OSEvertNameSize OSEvertSize OSEvertTbiSize OSTCBPiioTbMax TM platy OS I OSTatkCreateEn The Roal Time Kernel OSTaskCreateEnEn OSTaskDelEn ACT sebl ac Cine oO oO Oo oO Oo Oo m u Oo oO m Oo u oO Oo n m n oO o 0 Oo O oO 0 u Oo u m Oo Oo oO jm n n Figure 6 3 uC Probe Run Time C OS II Task Information 30 Licensing pu C OS II is provided in source form for FREE evaluation for educational use or for peaceful research If you plan on using pC OS II in a commercial product you need to contact Micrium to properly license its use in your product We provide ALL the source code with this application note for your convenience and to help you experience uC OS II The fact that the source is provided does NOT mean that you can use it without paying a licensing fee Please help us continue to provide the Embedded community with the finest software available Your honesty is greatly appreciated References LH C OS II The Real Time Kernel 2nd Edition Jea
9. serve as examples for initializing an interrupt and servicing that interrupt static void BSP_Tmr TickInit void CPU JDNHPSIZI jerellhs SS CPU INT32U rid cents VICIntSelect amp 1 lt lt VIC TIMERO Note 1 VICVectAddr4 CPU INT32U BSP Tmr TickISR Handler VICIntEnable ui lt lt WANG nne 9 pclk freq BSP CPU PclkFreq BSP PCLK TIMERO Note 2 zid Ents poro r OSIECK ERE TOTCR i lt lt 1 MOTER 0 ORC OF TOMRO rld_cnts Note 3 TOMCR Sm TOCCR 0 TOEMR OF TOTCR 1 Note 4 Listing 5 2 Tmr_TickInit Listing 5 2 Note 1 The timer interrupt vector is set and the interrupt is enabled Listing 5 2 Note 2 The peripheral clock frequency is calculated and this clock frequency and desired tick rate OS TICKS PER _SEC are used to determine the number of clocks between interrupts Listing 5 2 Note 3 The timer is setup to generate a periodic interrupt and then reset to zero Listing 5 2 Note 4 The timer is started 26 Micripm uC OS Il and pC Probe for the NXP LPC2478 CPU void BSP Tmr TickISR Handler void TOIR 0er Note 1 OSTimeTick Note 2 Listing 5 3 BSP Tnr TickISR Handler Listing 5 3 Note 1 The interrupt is cleared Listing 5 3 Note 2 oSTimeTick informs pC OS II of the tick interrupt 27 Micrium Uu C OS IIl and pC Probe for the NXP LPC2478 CPU 6 y
10. tasks If the n C OS II Kernel Awareness Plug In is currently enabled then a uC OS II menu should be displayed while debugging Otherwise the plug in can be enabled Stop the debugger if it is currently active and select the Options menu item from the Project menu Select the Debugger entry in the list box and then select the Plugins tab pane Find the pC OS II entry in the list and select the check box beside the entry as shown in Figure 2 2 When the code is reloaded onto the evaluation board the uC OS Il menu should appear Options are included to display lists of kernel objects such as semaphores queues and mailboxes including for each entry the state of the object Additionally a list of the current tasks may be displayed including for each task pertinent information such as used stack space task status and task priority in addition to showing the actively executing task An example task list for this project is shown in Figure 2 7 Options for node LPC2478 EA O0S Probe v5 2 x Category General Options C C Compiler Assembler Output Converter Custom Build Build Actions Linker Simulator Angel GDB Server IAR ROM monitor J Link J Trace Micripm Uu C OS IIl and uC Probe for the NXP LPC2478 CPU Factory Settings Setup Download Extra Options Plugins Select plugins to load SEGGER embOS JOSE Epsilon Power Pac RTOS
11. AR Project 11 2 03 01 u C OS II Kernel Awareness 11 2 05 Example Application 12 2 05 0 Additional Information 13 3 Directories and Files 15 4 Application Code 18 4 01 app c 18 4 02 os cfg h 21 5 Board Support Package BSP 23 5 01 IAR Specific BSP Files 23 5 03 BSP bsp c and bsp h 24 5 04 BSP bsp_i2c c 25 5 05 Processor Initialization Function 25 6 uC Probe 28 Licensing 31 References 31 Contacts 31 Micrium Uu C OS IIl and pC Probe for the NXP LPC2478 CPU 1 Introduction This document AN 1478 explains example code for using pu C OS II and p C OS Probe with the Embedded Artists LPC2478 OEM Evaluation Board as shown in Figure 1 1 which employs NXP s ARM7TDMI based LPC2478 microcontroller The processor includes 512 kB on chip flash memory and 64 kB SRAM in addition to dedicated SRAM for the EMAC and DMA peripherals The chip includes serial interfaces such as an internal 10 100 EMAC USB device and host with support for an external OTG transceiver two CAN channels a SPI controller two SSP controllers four UARTs and several I C and S interfaces Additionally the chip has a SD MMC card interface many general purpose I O pins and a 10 bit A D converter The LPC2478 OEM daughterboard includes the processor a National DP83848 PHY and external memories The baseboard on which this is situated provides the user peripherals including five user push buttons one of which is attached to an interrupt line one potentiometer
12. Hz The higher the tick rate the more overhead pu C OS II will impose on the application However you will have better tick granularity with a higher tick rate 22 Micripm uC OS Il and pC Probe for the NXP LPC2478 CPU 5 Board Support Package BSP The Board Support Package BSP provides functions to encapsulate common I O access functions and make porting your application code easier Essentially these files are the interface between the application and the Embedded Artists LPC2478 OEM board Though one file bsp c contains some functions which are intended to be called directly by the user all of which are prototyped in bsp h the other files serve the compiler as with cstartup s79 5 01 IAR Specific BSP Files The BSP includes three files intended specifically for use with IAR tools LPC2478 Flash icf LPC268 Flash mac cstartup s These serve to define the memory map and initialize the processor prior to loading or executing code If the example application is to be used with other toolchains the services provided by these files must be replicated as appropriate Before the processor memories can be programmed the compiler must know where code and data should be placed IAR requires a linker command file such as LPC2478 Flash icf that provides directives to accomplish this The C Spy macro files LPC2478 Flash mac declares routines which will be executed prior to loading code on the processor and after a processor reset Each
13. Micrium Empowering Embedded Systems uC OS II uC Probe and the NXP LPC2478 Processor Using the Embedded Artists LPC2478 OEM Evaluation Board Application Note AN 1478 www Micrium com Micripm uC OS Il and pC Probe for the NXP LPC2478 CPU About Micrium Micrium provides high quality embedded software components in the industry by way of engineer friendly source code unsurpassed documentation and customer support The company s world renowned real time operating system the Micrium wC OS II features the highest quality source code available for today s embedded market Micrium delivers to the embedded marketplace a full portfolio of embedded software components that complement ui C OS II A TCP IP stack USB stack CAN stack File System FS Graphical User Interface GUI as well as many other high quality embedded components Micrium s products consistently shorten time to market throughout all product development cycles For additional information on Micrium please visit www micrium com About u C OS II Thank you for your interest in n C OS Il wC OS II is a preemptive real time multitasking kernel pu C OS I has been ported to over 45 different CPU architectures and now has been ported to the Embedded Artists LPC2478 OEM evaluation board which includes the ARM based NXP LPC2478 processor uC OS II is small yet provides all the services you would expect from an RTOS task management time and timer managem
14. PIP 13 13 Ready String Tx 00065 PHY Status String Tx veiba String Tx 00067 Probe st String Tx 00068 String Tx 00069 String Tx 00070 String Tx 00071 String Tx 00072 String Tx 00073 String Tx 00074 String Tx 00075 String Tx 00076 String Tx 00077 uC OS I p For more informat Scenes The Real Time Kernel www micrium q5 ring Tx 00079 String Tx 00080 String Tx 00081 Running TCPAP 10 10 1 149 9930 65735 symbols sec sap Figure 1 2 uC Probe with Target Output Window Micripm uC OS Il and pC Probe for the NXP LPC2478 CPU 2 Getting Started The following sections step through the prerequisites for using the demonstration application described in this document AN 1478 First the setup of the hardware will be outlined Second the use and setup of the IAR Embedded Workbench project Thirdly the steps to build the projects and load the application onto the board through the JTAG will be described Lastly instructions will be provided for using the example application 2 01 Setting up the Hardware If uC OS Probe is being used then connect the RS 232 cable to the port labeled UART 2 for uC OS Probe in Figure 1 1 The project can also be configured to use UARTO which uses a USB port via a USB to serial bridge described below See Section 2 05 for details The board can be powered either by an external DC adapter or through the USB port used for the USB to se
15. ation procedure App ProbeInit is called App ProbeInit calls OSProbe Init which initializes the uC Probe plug in for uyC OS II which maintains CPU usage statistics for each task ProbeCom Init that initializes the yC Probe generic communication module and ProbeRS232 Init that initializes the RS 232 communication module After these have been initialized the uC Probe Windows program will be able to download data from the processor For more information see Section 6 Listing 4 2 Note 4 App EventCreate Creates all the application uC OS ll events and App TaskCreate creates all the application tasks Listing 4 2 Note 5 Any task managed by pC OS II must either enter an infinite loop waiting for some event to occur or terminate itself This task enters an infinite loop in which it toggles the LEDs at rates determined by the potentiometer settings Listing 4 2 Note 6 The four LEDs are turned on one by one and then all of the LEDs are turned off Listing 4 2 Note 7 The task checks the queue AppKbao to see if any messages have been posted Listing 4 2 Note 8 If messages were posted indicating that push buttons were pressed then the LEDs corresponding to the pressed push buttons will be blinked 20 times If no messages were posted then the task will have continued at the beginning of the loop 4 02 os cfg h The file os cfg h is used to configure un C OS II and defines the maximum number of tasks that your applicati
16. e program please refer to Section 6 a TCPIP fox Pai Home Numeric Meters Graphs Sliders Tanks Miscellaneous Switches Leds Dials Levels 9 e amp a a T Pu 3 Alignment Wp vents OS Configuration Events Timers DS Task Info OS Task CPU Usage 0S Timers OS About OS Task Stack Usage Net X g Task Stack Information E i C pes 5 Pointer Maximum Current Starts Ends 8 uC OS II Idle 0x0020A654 88 512 88 512 O0x0020A6AC 0x0020A4AC uC OS II Stat 0x0020A454 112 512 88 512 0x0020A4AC 0x0020A2AC Start Task 0x0020655C 208 2048 112 2048 0x002065CC 0x00205DCC Probe OS PlugIn 0x00207D54 128 2048 120 2048 0x00207DCC 0x002075CC Net Timer Task 0x00207574 144 2048 88 2048 0x002075CC 0x00206DCC Net IF Rx Task 0x00202B64 544 4096 128 4096 0x00202BE4 0x00201BE4 Probe RS 232 0x0020AA34 128 512 120 512 1asmosg joquits Probe TCPIP Ox00209BFC 720 1024 360 1024 0x00209D64 0x00209964 PHY Status 0x0020A244 112 512 104 512 0x0020A2AC 0x0020A0AC Probe Str 0x00206D64 144 2048 104 2048 0x00206DCC 0x002065CC General Task Information me rm ty wat State Del Waiting On ssage Switches CPU Usage uC OS II Idle 65535 31 Ready 158744 uC OS II Stat 30 Start Task 4 Probe OS PlugIn Net Timer Task Net IF Rx Task 9 9 Semaphore vss ae Jb om Sees ZEE j El Target Output DER Probe TE
17. ect Directory gt is the directory in which the IAR EWARM project is located extension ewp and Configuration Name is the name of the configuration in that project which was built to generate the ELF file and which will be loaded onto the target The ELF file will be named Project Name gt elf in EWARM v4 4x and Project Name gt out in EWARM v5 xx unless you specify otherwise To load this ELF file right click on the symbol browser and choose Add Symbols Configure the RS 232 Options In pC Probe choose the Options menu item on the Tools menu A dialog box as shown in Figure 6 2 left should appear Choose the RS 232 radio button Next select the RS 232 item in the options tree and choose the appropriate COM port and baud rate The baud rate for the projects accompanying this appnote is 115200 Start Running You should now be ready to run uC Probe Just press the run button to see the variables in the open data screens update Figure 6 3 displays the uC OS II workspace which displays detailed information about each task s state 29 Micrium Uu C OS IIl and pC Probe for the NXP LPC2478 CPU Options Options oe Settings E Communication Settings Lik RS 232 USB Link TCPAP Q JeLink Hew Target Server TCP IP USB USB Baud Rate amp Environment O TCPAP UDP Environment General General Screen Screen Target H Target COM Port 9 symbols sec O bytes sec Slow
18. ent semaphore and mutex message mailboxes and queues event flags an much more You will find that yC OS II delivers on all your expectations and you will be pleased by its ease of use Licensing pu C OS II is provided in source form for FREE evaluation for educational use or for peaceful research If you plan on using u C OS II in a commercial product you need to contact Micrium to properly license its use in your product We provide ALL the source code with this application note for your convenience and to help you experience uC OS II The fact that the source is provided DOES NOT mean that you can use it without paying a licensing fee Please help us continue to provide the Embedded community with the finest software available Your honesty is greatly appreciated Micripm uC OS Il and pC Probe for the NXP LPC2478 CPU About u C Probe uC Probe is a Windows application that allows a user to display and change the value at run time of virtually any variable or memory location on a connected embedded target The user simply populates uC Probe s graphical environment with gauges tables graphs and other components and associates each of these with a variable or memory location Once the application is loaded onto the target the user can begin uC Probe s data collection which will update the screen with variable values fetched from the target uC Probe retrieves the values of global variables from a connected embedded target and disp
19. er e BSP Joy GetPos return the position of the Joystick There are 6 different values that this function can return BSP JOY NONE Ifthe Joystick is not being pressed BSP JOY UP If the Joystick is toggled up BSP JOY DOWN If the Joystick is toggled down BSP JOY RIGHT Ifthe Joystick is toggled right BSP JOY LEFT Ifthe Joystick is toggled left BSP JOY PUSH lf the Joystick is being pressed 24 Micripm uC OS Il and pC Probe for the NXP LPC2478 CPU e BSP_JOY_GetStatus return DEF TRUE if the Joystick is being pressed at a given position The joy pos argument can take 6 different values BSP JOY NONE Ifthe Joystick is not being pressed BSP JOY UP If the Joystick is toggled up BSP JOY DOWN lfthe Joystick is toggled down BSP JOY RIGHT Ifthe Joystick is toggled right BSP JOY LEFT lf the Joystick is toggled left BSP JOY PUSH lf the Joystick is being pressed Six function provide access to serial port e BSP Ser Init initializes either UARTO UART1 or UART2 for serial communication e BSP Ser WrByte and BSP Ser WrStr write a byte such as a character or string to either UARTO UART1 or UART2 e BSP Ser RdByte and BSP Ser RdStr read a byte such as a character or string from either UARTO UART1 or UART2 e BSP Ser Printf can be called like printf to provide formatted output on either UARTO UART1 or UART2 5 04 BSP bsp i2c c This file includes a port for the NXP LPC2478 I2C interface
20. he user bsp i2c c contains a port for the NXP LPC2478 l C interface aimed specifically at supporting the PCA9532 LED dimmer which controls the LEDs and push buttons on the board cstartup s performs critical processor initialization such as the initialization of task stacks readying the platform to enter main LPC2478 Flash icf is the IAR linker files which contain information about the placement of data and code segments in the processors memory map LPC2478 Flash mac contains instructions that are executed prior to loading code onto the processor Micripm uC OS Il and pC Probe for the NXP LPC2478 CPU 4 Application Code The example application described in this appnote AN 478 is a simple demonstration of uC OS II and uC OS Probe for the NXP LPC2478 processor on the Embedded Artists LPC2478 OEM evaluation board 4 01 app c Five functions of interest are located in app c 1 main is the entry point for the application as it is with most C programs This function initializes the operating system creates the primary application task App TaskStart begins multitasking and exits App TaskStart after creating the user interface tasks enters an infinite loop in which it blinks the LEDs at rates determined by the potentiometers and checks a queue to see if push buttons have been pressed see Figure 2 14 App TaskKbd polls the user inputs the push buttons and if new input is detected places a me
21. lays the values in an engineer friendly format The supported data types are booleans integers floats and ASCII strings uC Probe can have any number of data screens where these variables are displayed This allows to logically grouping different views into a product Currently there are two different trial version of uC Probe e The Full Featured Trial Package 30 Day Evaluation Period e Untimed Trial Package 15 Symbol Maximum Both versions can be downloaded on the Micrium website http www micrium com products probe trialprobe html Micripm uC OS Il and pC Probe for the NXP LPC2478 CPU Manual Versions If you find any errors in this document please inform us and we will make the appropriate corrections for future releases Version Date By Description Software Versions This document may or may not have been downloaded as part of an executable file Micrium NXP uCOS II LPC2476 EA exe containing the code and projects described here If so then the versions of the Micrium software modules in the table below would be included In either case the software port described in this document uses the module versions in the table below modue version Comment uC OS II V2 86 ARM Port V1 84 scosPrhe vem In addition to the nu C OS II project accompanying this application note a pre compiled pu C OS II and pu C GUI example ca
22. n J Labrosse R amp D Technical Books 2002 ISBN 1 57820 103 9 Embedded Systems Building Blocks Jean J Labrosse R amp D Technical Books 2000 ISBN 0 87930 604 1 Contacts IAR Systems CMP Books Inc Century Plaza 1601 W 23rd St Suite 200 1065 E Hillsdale Blvd Lawrence KS 66046 9950 Foster City CA 94404 USA USA 1 785 841 1631 1 650 287 4250 1 785 841 2624 FAX 1 650 287 4253 FAX e mail rushorders cmpbooks com e mail Info lIAR com WEB http www cmpbooks com WEB www IAR com Micrium NXP 949 Crestview Circle 1110 Ringwood Court Weston FL 33327 USA 1 954 217 2036 1 954 217 2037 FAX e mail Jean Labrosse Micrium com WEB www Micrium com San Jose CA 95131 USA 1 408 474 8142 WEB www nxp com
23. n be found on the NXP LPC24xx page on the Micrium website Micripm uC OS Il and pC Probe for the NXP LPC2478 CPU Document Conventions Numbers and Number Bases Hexadecimal numbers are preceded by the Ox prefix and displayed in a monospaced font Example 0xFF886633 Binary numbers are followed by the suffix b for longer numbers groups of four digits are separated with a space These are also displayed in a monospaced font Example 0101 1010 0011 1100b Other numbers in the document are decimal These are displayed in the proportional font prevailing where the number is used Typographical Conventions Hexadecimal and binary numbers are displayed in a monospaced font Code excerpts variable names and function names are displayed in a monospaced font Functions names are always followed by empty parentheses e g OS Start Array names are always followed by empty square brackets e g BSP Vector Array File and directory names are always displayed in an italicized serif font Example Micrium Sofware uCOS II Source A bold style may be layered on any of the preceding conventions or in ordinary text to more strongly emphasize a particular detail Any other text is displayed in a sans serif font Micrium uC OS II and uC Probe for the NXP LPC2478 CPU Table of Contents 1 Introduction 7 2 Getting Started 9 2 01 Setting up the Hardware 9 2 02 Opening and Viewing the Project 9 2 03 Using the I
24. ng Symbol Browser Design View During Run Contains all symbols from the Time View these ELF files added to the components are updated workspace with values of those symbols from the target MOOOOOOOOOoOOoOoooOoOoOooooooooxoL P00 COM Disconnected x Figure 6 1 C Probe Windows Program 28 Micripm uC OS Il and pC Probe for the NXP LPC2478 CPU To use pC Probe with the example project or your application do the following 1 1 Download and Install uy C Probe A trial version of uC Probe can be downloaded from the Micrium website at http www micrium com products probe probe html Open uC Probe After downloading and installing this program open the example uC Probe workspace for uC OS Il named OS Probe Workspace wsp which should be located in your installation directory at Program Files Micrium uC Probe Target Plugins uCOS II Workspace Connect Target to PC Currently uC Probe can use RS 232 to retrieve information from the target You should connect a RS 232 cable between your target and computer Load Your ELF File The example projects included with this application note are already configured to output an ELF file If you are using your own project please refer to Appendix A of the pC Probe user manual for directions for generating an ELF file with your compiler This file should be in Project Directory gt lt Configuration Name gt exe where Proj
25. ng LEDs the LEDs directly above those push buttons will blink rapidly 20 times The potentiometer controls the delay between the lighting of the LEDs in the initial phase turning the potentiometer counter clockwise will decrease the delay Similarly the left hand potentiometer controls the rate at which the LEDs blink which correspond to the pressed push buttons turning the potentiometer counter clockwise will decrease the delay Also Text will be output to the RS 232 port labeled as UART 0 over USB to Serial Bridge at 115200 baud giving the state of the system as shown in Figure 2 3 The joystick pressing to the left or to the right can be used to change the output to a new item 12 Micripm uC OS Il and pC Probe for the NXP LPC2478 CPU To communicate with the board through RS 232 connect a serial cable between the evaluation board serial port and your PC and open a HyperTerminal or any Terminal program window Configure the RS 232 interface with the following settings e Bits per Second 115200 e Data bits 8 e Parity None e Stops bits 1 e Flow Control None EA LPC2478 HyperTerminal 15 xl File Edit Yiew Call Transfer Help Ols 8 cle Micrium uC O0S II on the Embedded Artist LPC2478 uC 0S II V2 86 running at 1000 ticks sec CPU Usage 04 at CPU Speed 048 MHz Ticks 00020284 tCtxSw 00024488 ACCx 0467 RCCy 04993 RCCz Pot 0725 mi oft Connected 0 00 30
26. of these sets the MEMMAP register as is appropriate for the location of the exception vectors In cstartup s is code which will be executed prior to calling main One important inclusion is the specification of the exception vector table as required for ARM cores and the setup of various exception stacks After executing this function branches to the IAR specific main function in which the processor is further readied for entering application code Micripm uC OS Il and pC Probe for the NXP LPC2478 CPU 5 03 BSP bsp c and bsp h The file bsp c implements several global functions each providing some important service be that the initialization of processor functions for uC OS II to operate or the toggling of an LED Several local functions are defined as well to perform some atomic duty initializing the I O for the LED or initialize the uC OS II tick timer The discussion of the BSP will be limited to the discussion of the global functions that might be called from user code and may be called from the example application The global functions defined in bsp c and prototyped in bsp h may be roughly divided into two categories critical processor initialization and user interface services Four functions constitute the former e BSP_Init is called by the application code to initialize critical processor features particularly the u C OS II tick interrupt after multitasking has started i e OS Start has been called This functi
27. ometer X a Accelerometer Y Accelerometer Z Potentiometer FC0 0 27 P0 28 Serial Output HyperTerminal Joystick LED1 LED2 LED3 Figure 2 4 Example Application Hardware Use 14 Micripm uC OS Il and pC Probe for the NXP LPC2478 CPU 3 Directories and Files Application Notes Micrium AppNotes ANI1xxx RTOS AN1014 uCOS II ARM This directory contains AN 1014 pdf the application note describing the ARM port for u C OS 1I and AN 1014 PPT pdf a supplement to AN 014 pdf Micrium AppNotes A N1xxx RTOS AN1478 uCOS H NXP LPC2478 This directory contains this application note AN 1478 pdf Licensing Information Micrium Licensing Licensing agreements are located in this directory Any source code accompanying this appnote is provided for evaluation purposes only If you choose to use u C OS II in a commercial product you must contact Micrium regarding the necessary licensing pu C OS II Files Micrium Software uCOS II Doc This directory contains documentation for uC OS I Micrium Software uCOS II Ports ARM Generic AR This directory contains the standard processor specific files for the generic uyC OS II ARM port assuming the IAR toolchain and the ARM Keil RealView Microprocessor Development Kit toolchain These files could easily be modified to work with other toolchains i e compiler assembler linker locator debugger however the modified files should be placed into
28. on 3 axis accelerometer a 5 key joystick and four LEDs One RS 232 port for the processors UART2 a USB port used for a serial bridge for UARTO one CAN port one USB device port one USB host port a SD MMC card holder and an Ethernet port provide for external communication The board includes a standard 20 pin JTAG connector for debugging and programming UART 0 over USB to Serial Bridge JTAG connector 3 Axis Accelerometer Potentiometers SER1EERI OTG Device QVGA TFT color LCD with touch screen UART 1 UART 2 Select UART 2 for uC OS Probe wes PDEMONELEUEEE Figure 1 1 Embedded Artists LPC2478 OEM Evaluation Board Micrium Uu C OS IIl and pC Probe for the NXP LPC2478 CPU If this appnote was downloaded in a packaged executable zip file then it should have been found in the directory Micrium Appnotes AN Ixxx RTOS AN1478 uCOS II NXP LPC2478 and the code files referred to herein are located in the directory structure displayed in Section 2 02 these files are described in Section 3 The executable zip also includes example workspaces for uC Probe uC Probe is a Windows program which retrieves the value of variables form a connected embedded target and displays the values in an engineer friendly format It interfaces with the NXP LPC2378 via RS 232C For more information including instructions for downloading a trial and the demo version of th
29. on can have which services will be enabled semaphores mailboxes queues etc the size of the idle and statistic task and more In all there are about 60 or so define that you can set in this file Each entry is commented and additional information about the purpose of each define can be found in Jean Labrosse s book uC OS II The Real Time Kernel 2nd Edition os_cfg h assumes you have uC OS II V2 83 or higher but also works with previous versions of uC OS II e Task sizes for the Idle oS TASK IDLE STK SIZE statistics OS TASK STAT STK SIZE and timer O5 TASK TMR STK SIZE task are set to 128 OS STK elements each is 4 bytes and thus each task stack is 512 bytes If you add code to the examples make sure you account for additional stack usage e OS DEBUG EN is set to 1 to provide valuable information about pC OS II objects to IAR s C Spy through the Kernel Awareness plug in Setting oS DEBUG EN to 0 should some code space though it will not save much e OS LOWEST PRIOiS set to 31 allowing up to 32 total tasks 21 Micripm uC OS Il and pC Probe for the NXP LPC2478 CPU OS MAX TASKS determines the number of application tasks and is currently set to 10 allowing 9 more tasks to be added to the example code OS TICKS PER SEC is set to 1000 Hz This value can be changed as needed and the proper tick rate will be adjusted in bsp c if you change this value You would typically set the tick rate between 10 and 1000
30. on should be called before any other BSP functions are used See Listing 5 1 for more details e BSP IntDisAl1 is called to disable all interrupts thereby preventing any interrupts until the processor is ready to handle them e BSP CPU ClkFreq returns the clock frequency in Hz e BSP CPU PclkFreq returns the clock frequency in Hz or a peripheral clock an ID for the peripheral clock as defined in bsp h is accepted as the argument Five function provide access to user interface components e BSP LED Toggle BSP LED On and BSP LED Off will toggle turn on and turn off respectively the LED corresponding to the ID passed as the argument If an argument of 0 is provided the appropriate action will be performed on all LEDs Valid IDs are 1 2 3 and 4 e BSP PB GetStatus takes as its argument the ID of a push button and returns DEF TRUE if the push button is being pressed and DEF FALSE if the push button is not being pressed Valid IDs are 1 2 3 and 4 e BSP ADC GetStatus takes as its argument the ID of a ADC and returns the 10 bit number that when divided by 0x3FF is equal to the ratio of the input voltage divided by the reference voltage The ID parameter can take the following values BSP ADC ACC Xthe ADO 0 channel Accelerometer x axis BSP ADC ACC Y the ADO 1 channel Accelerometer y axis BSP ADC ACC Zthe ADO 2 channel Accelerometer z axis BSP ADC POT the ADO 2 channel Potentiomet
31. rial bridge labeled UARTO over USB to Serial Bridge in Figure 1 1 When first connecting the USB cable between the evaluation board and your computer you will be prompted to install the FTDI driver see the board manual for details Once you have this driver installed your computer can use this particular USB port on the board port as if it were a COM port Included in this is the ability to program the LPC2478 through the UARTO ISP If you want to use UARTO or use power from this USB port but do not want to use ISP you will need to open the jumpers RST and P2 10 2 02 Opening and Viewing the Project If this file were downloaded as part of an executable zip file which should have been named Micrium NXP uCOS II LPC2476 EA exe then the code files referred to herein are located in the directory structure shown in Figure 2 1 Micrium Uu C OS IIl and uC Probe for the NXP LPC2478 CPU E C3 Micrium pu S A Icensing agreements B e ANLxxx RTOS sa ie og AN1014 uCOS II ARM commercially O AN1478 uCOS II NXP LPC2478 Contact wd www Micrium com Licensing forpricing O Software E EvalBoards Ei C3 NxP E LPC2478 EA E rar 53 BsP 53 05 Probe El uc cPu ycios ll ARM The Real Time IAR pechos uc LrB Run Time Libraries ucos r co Doc E 3 Ports py C Probe El G ARM ARM Real Time Monitor El C3 Generic uC OS II port D IAR IAR Example Project
32. sk In addition C OS II creates either one or two internal tasks in OSInit pu C OS II always creates an idle task OS _TaskIdle and will create a statistic task OS_TaskStat if you set OS TASK STAT EN to 1 in os cfg h Listing 4 1 Note 5 As of V2 6x you can now name u C OS II tasks and other kernel objects and display task names at run time or with a debugger In this case the App TaskStart is given the name Start Task Because C Spy can work with the Kernel Awareness Plug In available from Micrium task names can be displayed during debugging Listing 4 1 Note 6 Finally multitasking under uC OS II is started by calling oSSTart nC OS M will then begin executing App TaskStart since that is the highest priority task created both OS TaskStat andOS TaskIdle having lower priorities Micripm uC OS Il and pC Probe for the NXP LPC2478 CPU static void App TaskStart void p arg CPU_INTO8U i CPU INTO8U Je void msg CPU_INTO8U erip CPU INTO8U led CPU INT32U leds CPU INT32U delay0 CPU_INT32U delayl void p arg BSP Init if OS TASK STAT EN gt 0 OS Sissi NET endif if APP CFG PROBE COM EN DEF ENABLED App ProbeInit endif App EventCreate App TaskCreate BSP Ser Init 115200 BSP LED Off 0 while DEF TRUE tou a dp a e sp 4 BSP LED On i Note 1 Note 2 Note 3 Note 4 Note 5 Note 6
33. ssage in a queue for App TaskStart App TaskJoy monitors the state of the joystick and passes messages to App TaskSer 5 App TaskSer Outputs the state of the system based on the display state passed to it by App TaskJoy int main void Note 1 CPU INTOSU err BSP IntDisAll Note 2 Qisubsute p Note 3 OSTaskCreateExt void void App TaskStart Note 4 void 5 i OS STK amp ApplaskStartStk APP CrG TASK START STK SIZE 1 INT8U APP CFG TASK STARI FRIO INT16U APP CFG TASK START PRIO OS STK amp AppTaskStartStk 0 INT32U APP CEG TASK START SIK SIZE void Qe INT8U OS TASK OPT STK CHK OS TASK OPT STK CLR if OS TASK NAME SIZE gt 13 Note 5 OSTaskNameSet APP CFG TASK START PRIO CPU INTO08U Start Task amp err fendif OSStart Note 6 Listing 4 1 main 18 Micripm uC OS Il and pC Probe for the NXP LPC2478 CPU Listing 4 1 Note 1 As with most C applications the code starts in main Listing 4 1 Note 2 All interrupts are disabled to make sure the application does not get interrupted until it is fully initialized Listing 4 1 Note 3 OSInit must be called before creating a task or any other kernel object as must be done with all wC OS II applications Listing 4 1 Note 4 At least one task must be created in this case using OSTaskCreateExt to obtain additional information about the ta
34. targeted at supporting the PCA9532 5 05 Processor Initialization Function void BSP Init void a5 Wink diede P Note 1 SSP iuc one P Note 2 BSP MAM Init Note 3 BSPEGETONITISIE Note 4 BORE JOVE OO Note 5 BOPEADCE TONAO Note 6 BSP VIC Imich Note 7 BSP 120 Imie Note 8 SSP mye mieki p Note 9 Listing 5 1 BSP_Init Listing 5 1 Note 1 The PLL is setup to generate a 72 MHz CPU clock All peripheral clocks are set to half the CPU clock Micripm uC OS II and pC Probe for the NXP LPC2478 CPU Listing 5 1 Note 2 The Real Time clock RTC is setup Listing 5 1 Note 3 The Memory Acceleration Module MAM is setup Listing 5 1 Note 4 The general purpose I O ports are setup Listing 5 1 Note 5 The Joystick I O is initialized Listing 5 1 Note 6 The ADC used for the Accelerometer potentiometer is initialized Listing 5 1 Note 7 The interrupt controller is initialized including the disabling of all interrupts and the assignment of a dummy ISR handler to each interrupt vector to catch spurious interrupts Listing 5 1 Note 8 The lC interface used for the PCA9532 which controls the LEDs and push buttons is initialized Listing 5 1 Note 9 The pC OS II tick interrupt source is initialized Listings 5 2 and 5 3 give the ui C OS II timer tick initialization function BSP Tmr TickInit the tick ISR handler BSP_Tmr TickISR Handler These may
35. u C Probe uC Probe is a Windows program which retrieves the values of global variables from a connected embedded target and displays the values in a engineer friendly format To accomplish this an ELF file created by the user s compiler and containing the names and addresses of all the global symbols on the target is monitored by uC Probe The user places components such as gauges labels and charts into a Data Screen in a uC Probe workspace and assigns each one of these a variable from the Symbol Browser which lists all symbols from the ELF file The symbols associated with components placed on an open Data Screen will be updated after the user presses the start button assuming the user s PC is connected to the target A small section of code resident on the target receives commands from the Windows application and responds to those commands The commands ask for a certain number of bytes located at a certain address for example Send 16 bytes beginning at 0x0040102C The Windows application upon receiving the response updates the appropriate component s on the screens with the new values Fi Micrium wC Probe LPC2478 EA 05 Probe Workspace wsp Home Er ena SS Coc PS eee e Stack Usage OS Abo en PU RO9B ey bre MV ANON jc SEENON Min e A counter is kept in the uC Probe OS plug in callback which is displayed with this gauge OS General Iro OS Task CPU Usage OS Task Stack Usage OS Task Info
36. unication module the target side code responsible for responding to requests from the wC Probe Windows application over RS 232 Micrium Software uC Probe Communication Generic Source RS 232 Source This directory contains probe_rs232 c and probe_rs232 h the source code for the generic communication module RS 232 code Micrium Software uC Probe Communication Generic Source RS 232 Ports NXP LPC24xx This directory contains probe_rs232c c and probe_rs232c h the NXP LPC24xx port for the RS 232 communications Micrium Software uC Probe Communication Generic Source RS 232 O0S uCOS I1 This directory contains probe rs232 os c which is the ui C OS II port for the pC Probe RS 232 communication module u C CPU Files Micrium Software uC CPU This directory contains cpu_def h which declares define constants for CPU alignment endianness and other generic CPU properties Micrium Software uC CPU ARM VIAR This directory contains cpu h and cpu_a s cpu h defines the Micrium portable data types for 8 16 and 32 bit signed and unsigned integers such as CPU_INT16U a 16 bit unsigned integer These allow code to be independent of processor and compiler word size definitions cpu_a s contains generic assembly code for ARM7 and ARMO processors which is used to enable and disable interrupts within the operating system This code is called from C with OS ENTER CRITICAL andOS EXIT CRITICAL pu C LIB Files Micrium Software uC LIB
Download Pdf Manuals
Related Search
Related Contents
Manual de usuário - multiport.com.br 9x7 QuasarBlaze MOEN 5965SRS Installation Guide DENVER MT-783 - MANUAL Portuguese Operating Instructions TrapPro User Manual 6 Slot Service Manual Copyright © All rights reserved.
Failed to retrieve file