Home

Copyright 1995, Jean J. Labrosse, Plantation, FL

image

Contents

1. represents the address of the data to write 46 C OS View References C OS II The Real Time Kernel 2 Edition Jean J Labrosse R amp D Technical Books 2002 ISBN 1 5782 0103 9 Contacts Micri m Inc 949 Crestview Circle Weston FL 33327 USA 1 954 217 2036 1 954 217 2037 FAX e mail WEB Www Micrium com CMP Books Inc 1601 W 23rd St Suite 200 Lawrence KS 66046 9950 USA 1 785 841 1631 1 785 841 2624 FAX WEB _hhttp www rdbooks com e mail rdorders rdbooks com JK Microsystems Inc 1403 Fifth Street Suite D Davis CA 95616 USA 1 530 297 6073 47 48 C OS View
2. OSView RxIntDis is not currently called by the processor independent code but could be in a future release However it can be used by the target specific code to disable interrupts from the UART Universal Asynchronous Receiver Transmitter receiver This function must ONLY disable receiver interrupts Arguments None Returned Value None Notes Warnings This function should only disable interrupts from the receiver and not affect other interrupt sources For this you may need to read the current interrupt disable mask register alter the bit s needed to disable the receiver interrupt and write the new value to the interrupt mask register Example 80x86 port using COM1 on a PC void OSView_RxIntDis void if OS CRITICAL METHOD OS CPU SR cpu sr tendif INT8U stat INT8U mask OS ENTER CRITICAL stat inp OS VIEW 8250 BASE F OS_VIEW_8250_IER amp BITO outp OS VIEW 8250 BASE OS VIEW 8250 IER stat if stat 0x00 mask inp OS VIEW 8259 MASK REG mask OS VIEW 8259 COMM INT EN outp OS VIEW 8259 MASK REG mask OS EXIT CRITICAL 23 C OS View OSView_RxIntEn void OSView_RxIntEn void File Called from OS _VIEWc C The processor specific code OSView_RxIntEn is not currently called by the processor independent code but could be in a future release However it can be used by
3. OSView CyclesCtr INT32U OSView TimeGetCycles void pdata INT32U cycles INTI6U cnts16 INT16U delta OS ENTER CRITICAL cnts16 Read counts from timer chip delta OSView TmrCntsPrev cnts1l6 OSView TmrCntsPrev cnts16 OSView CyclesCtr delta cycles OSView CyclesCtr OS EXIT CRITICAL return cycles 33 C OS View void OSView_TickHook void INT16U cntsl6 INT16U delta OS ENTER CRITICAL cnts16 Read counts from timer chip delta OSView TmrCntsPrev cnts16 OSView CyclesCtr delta OSView TmrCntsPrev cnts16 OS EXIT CRITICAL 34 C OS View OSView Tx1 void OSView_Tx1 INT8U data File Called from OS_VIEWc C Processor independent code in OS_VIEW C OSView_Tx1 is called by the processor independent code to send a single byte to the serial port Arguments data is the single character to send to the serial port Returned Value None Notes Warnings You should not be calling this function from your application because it is called by the processor independent code Example void OSView _Txl INT8U data Write data to UART Tx register 35 C OS View OSView TxIntDis void OSView_TxIntDis void File Called from OS_VIEWc C The processor specific and independent code OS VIEW C and OS VIEWc C OSView_TxIntDis is called by the processor specific and independent co
4. Returned Value None Notes Warnings You should not be calling this function from your application because it is called by the processor independent code Example void OSView_GetCPUName char s strcpy s M16C 19 C OS View OSView GetIntStkBase INT32U OSView GetIntStkBase void File Called from OS VIEWc C OSView CmdGetSysInfo OS VIEW C OSView GetIntStkBase is called by the processor independent code to obtain the base address of the interrupt stack if a separate interrupt stack is used If the processor you are using doesn t have an interrupt stack or you have not implemented that feature in software then this function should return 0 Arguments None Returned Value None Notes Warnings You should not be calling this function from your application because it is called by the processor independent code Example INT32U OSView_GetIntStkBase void return INT32U amp OSIntStkBase OR INT32U OSView_GetIntStkBase void return INT32U 0 If there is no interrupt stack 20 C OS View OSView GetIntStkSize INT32U OSView GetIntStkSize void File Called from OS VIEWc C OSView CmdGetSysInfo OS VIEW C OSView_GetIntStkSize is called by the processor independent code to obtain the size in number of bytes of the interrupt stack if a separate interrupt stack is used If the processor you are usin
5. 32 bit 0x00 cmd 0x00 0x00 4 0x00 0x00 1 values from the target Addr 1 32 bit Value Addr 0 4 N 1 32 bit Value Addr 4 32 bit Value Addr 8 Addr in the command SUM SUM 32 bit Value Addr C represents the start 0x8D ED i address of the data to read 32 bit Value Addr N 4 4 p and N the desired number au aay of 32 bit values Write one OxED SDO 1 0x8C SD0 This command allows the bytes 0x8C SD1 1 OxED SD1 Windows application to 1 cmd 0x06 LEN 1 0x01 LEN write a single 8 bit value to 0x31 1 1 0x31 1 the target system at a Age pee SUM specific memory location Value x8D ED SUM SUM i Addr in the command 0x8D ED represents the address of the data to write Write one OxED SD0 1 0x8C SDO 1 This command allows the 16 bit value 0x8C SD1 1 OxED SD1 1 Windows application to 2 cmd 0x06 LEN 1 0x01 LEN 1 write a single 16 bit value 0x32 2 1 0x32 2 1 to the target system at a Aad i pe SUM i specific memory location Value x8D ED SUM SUM i Addr in the command 0x8D ED represents the address of the data to write Write one OxED SD0 1 0x8C SD0 1 This command allows the 32 bit value 0x8C SD1 1 OxED SD1 1 Windows application to 4 cmd 0x06 LEN 1 0x01 LEN 1 write a single 32 bit value 0x34 4 1 0x34 4 1 to the target system at a zadr Mee SUM specific memory location alue x8D ED re ey Addr in the command x
6. ANDUAWNHOS Tasks Help This menu Mite ri tin CPU load ys time Bytes 4542468 26442541 Packets 349338 38400 baud on CON 7 Figure 2 4 Profile of the four tasks selected 2 05 Step Mode C OS View now support the stepping feature of the viewer Pressing the F7 key on the viewer pauses the C OS II ticker Pressing the F8 key allows one tick to be executed Pressing the F6 key resumes normal operation of the ticker Note that OSTimeTickHook is still called at the tick rate in case your application has time critical needs 11 C OS View 3 00 C OS II Target Resident Software Torun C OS II your target system needs to have an RS 232C port and include target resident software that communicates with the Windows application The target resident software is found in five files that starts with the prefix OS_ VIEW File name Description OS_VIEW C Target independent code OS_VIEW H Target independent header file OS_VIEWc C Target specific C source file i e port which changes based on the target CPU used OS_VIEWc H Target specific C header file OS_VIEWa ASM Target specific assembly language file Table 3 1 C OS View source files You should not have to change the target independent code i e OS VIEW C and OS VIEW H 3 01 Restrictions and Configuration When you compile the target resident code with your C OS II application you need to abide by the following restr
7. Also YOUR callback function needs to be declared as shown above You can create your own commands for your target system Specifically you could have code that initiates special tests on your hardware in response to certain keystrokes you could create commands that changes the operating mode of your target you could create commands that displays the contents of variables and memory locations and more 15 C OS View static void TestTerminalTask void pdata if OS CRITICAL METHOD OS CPU SR cpu sr endif char s 100 char key INT8U err pdata pdata while TRUE key char OSMboxPend TestTerminalMbox 0 amp err TestTerminalMsgCtr sprintf s S05u TestTerminalMsgCtr PC DispStr 60 22 S DISP FGND YELLOW DISP BGND BLUE switch key case l sprintf s nCPU Usage OSView_TxStr s 1 break ole 3u n OSCPUUSage case 2 sprintf s n Tasks OSView_TxStr s 1 S3u n OSTaskCtr break default OSView_TxStr n nMicrium Inc 1 OSView_TxStr nl CPU Usage 1 OSView_TxStr n2 Tasks 1 OSView_TxStr n Help This menu n 1 break 3 05 OSView_TxStr You might have noticed from the code in the previous section that the function OSView TxStr is being called to send ASCII strings to the Windows application These strings are actually sent to the terminal window see section 3 04 Terminal Window Your application can
8. IntStack Indicates the base address of the interrupt stack if a separate stack area is reserved for interrupts 2 03 Terminal Window The Terminal Window area allows the Windows application i e the Viewer to communicate you re your target Specifically the Terminal Window allows you to send keystrokes that you type from on the Windows PC to your target system Your target system can then process these keystrokes and responds back with ASCII strings that are displayed on the Terminal Window Your application actually determines what to do with the keystrokes The terminal window is described later 2 04 CPU load vs time This area allows you to see the execution profile of your tasks the percentage CPU usage of tasks as a function of time This area is interesting since it gives you an idea about where your CPU is spending it s time C OS View You can setup C OS View to display either all your tasks at the same time or select to display up to 5 tasks on the graph To change this option simply click on the Setup menu item and then click on the CPU View tab as shown in Figure 2 2 Communication General CPU View Log Show Total for alltasks J Ignore CPU load of lowest priority task Task selection Use Filter Cancel Figure 2 2 CPU View Options As shown in Figure 2 3 if you click on the Task Selection s Use Filter check box you can actually specify which of up to 5 tasks you can show on the g
9. OS ENTER CRITICAL cnts16 Read counts from timer chip delta cnts16 OSView_TmrCntsPrev OSView_TmrCntsPrev cnts16 OSView CyclesCtr delta cycles OS EXIT CRITICAL return cycles OSView CyclesCtr 31 C OS View void OSView_TickHook void INT16U cntsl6 INT16U delta OS ENTER CRITICAL cnts16 Read counts from timer chip delta cntsl6 OSView_TmrCntsPrev OSView CyclesCtr delta OSView TmrCntsPrev cnts16 OS EXIT CRITICAL 32 The drawi C OS View Example assuming a 16 bit down counter ng below shows a free running timer that counts down from 65535 to 0 and rolls over to 65535 If C OS I s tick rate is faster than the rollover rate then you could sample this free running timer by hooking into C OS Il s tick ISR as shown in the code below OSView CyclesCtr simply needs to contain the sum of the Deltas Because we use unsigned arithmetic a small Prev value minus a large New value results in the proper delta OSView CyclesCtr is actually updated in both OSView_TickHook and OSView_TimeGetCycles You should note that OSView TimeGetCycles can actually be called at just about any time and thus also needs to update OS View CyclesCtr before it returns the current value OSView TimeGetCycles needs to return the current value of OSView CyclesCtr 65339 OSView TickHook 0 Delta Prev New Delta Prev New a a Time
10. Rx and Tx characters However you MUST declare the function but leave the contents empty Example void OSView_RxISRHandler void INT8U c c Read character from UART OSView RxHandler c Pass to processor independent code Clear interrupt 26 C OS View OSView_RxTxISR void OSView_RxTxISR void File Called from OS _VIEWa ASM The UART Rx interrupt OSView RxTxISR is the interrupt service routine ISR that is invoked by the processor hardware when either a character is received or transmitted by the UART Universal Asynchronous Receiver Transmitter If the UART issues a separate interrupt for a received character and another one for a transmitted character then you should instead use OSView RxISR and OSViewTxISR respectively OSView RxTxISR should call OSView RxTxISRHandler to process the interrupt from C instead of assembly language Arguments None Returned Value None Notes Warnings You don t need to write the contents of this function if your UART issues a separate ISR for for Rx and Tx characters However you MUST declare the function but leave the contents empty Example Pseudo code OSView_RxTxISR Save ALL CPU registers OSIntNesting Notify uC OS II of ISR entry if OSIntNesting 1 Save SP in TCB if first nested ISR OSTCBCur gt OSTCBStkPtr SP OSView_RxTxISRHandler Call the C handler in OS VIEWe C OSIntExit
11. for the user to press the F8 key on the Windows terminal 0x02 means step and is issued in response to the user pressing the F8 key Trace OxED SD0 1 Command T cmd 0x8C SD1 1 not 0x01 LEN 1 implemented 0x54 AT 1 OxAB SUM 1 0x8D ED 1 45 C OS View Read N OxED SDO 1 0x8C SDO 1 This command allows the bytes Ox8C SD1 1 OxED SD1 1 Windows application to b cmd 0x06 LEN i N LEN F read N consecutive bytes 0x62 b x62 b Addr cee 4 mee oon Meer 1 Tom the target N 1 8 bit Value Addr 1 i i 8 bit Value Addr 2 Addr in the command SUM SUM i 8 bit Value Addr 3 z represents the start 0x8D ED j address of the data to read pe CR and N the desired number ne 1 of bytes Read N OxED SDO 1 0x8C SD0 1 This command allows the 16 bit Ox8C SD1 1 OxED SD1 1 Windows application to values 0x06 LEN 1 N 2 LEN 1 read N consecutive 16 bit w cmd 0x77 W 1 0x77 w 1 values from the target Addr 4 16 bit Value Addr 0 2 N 1 16 bit Value Addr 2 2 16 bit Value Addr 4 Addr in the command SUM SUM i 16 bit Value Addr 8 represents the start 0x8D ED 5 address of the data to read 16 bit Value Addr N 2 2 a and N the desired number ie aoe i of 16 bit values x Read N OxED SDO 1 0x8C SDO il This command allows the 32 bit Ox8C SD1 1 OxED SD1 1 Windows application to values 0x06 LEN 1 N 4 LEN 1 read N consecutive
12. send ASCII strings to the terminal window at any time However you would typically send such strings in response to keystrokes that you would receive from the terminal window The prototype for this function is void OSView TxStr char s INT16U dly where s is a pointer to the string to send dly allows the calling task to delay itself for dly ticks until the current string is sent If dly is set to 0 then the string will not be sent if a string is currently in the process of being sent In other words if there a string currently being sent and you set aly to 0 OSView_TxStr will return to the caller and the string will not be sent 16 3 06 Porting C OS View should involve changing or creating only three files OS VT and OS VI You can download C OS View ports from the Micri m web site at www Micrium com Porting C OS View are found next to C OS II ports C OS View _VIEWc C OS VIEWc H EWa ASM The assembly language file generally contains ISRs which with C OS II should be written in assembly language as described in the C OS II book C OS View ports As a minimum a port should define the code for 18 functions as listed below Most of these functions are expected by OS VI OSView Exit OSView GetCPUName OSView GetIntStkBase OSView GetIntStkSize OSView InitTarget OSView RxIn OSView RxIn OSView RxIS OSView RxIS tDis tEn R RHandler OSVi
13. 34325 uC OS I Stat DELAY 178 234 1024 20B3419A 0 00 8775 20B342BE uC OS I Idle Ready 172 1024 20B345AE 18 75 99974 Micium Inc 1 CPU Usage 2 Tasks Help This menu er Terminal Window See section 2 03 CPU Load vs Time Display Area See section 2 04 Bytes 3801692 22129591 Packets 292350 38400 baud on CON Figure 2 1 Windows application view C OS View 2 01 Task List The task list shows all the tasks in your application and displays information about those tasks Specifically Prio Indicates the task priority of each task Note that entries in the task list are always sorted by task priority Id Is a unique ID for each task In fact this field contains the address of the OS_TCB of the task Name Is the name of the task Assigning a name to a task is a new feature that was added to C OS II V2 6x The name is actually stored in the target system and sent to the Windows application along with the other information about your tasks see section 3 03 for details on how to set the task names The number of characters you can use for a task name depends on the C OS II configuration constant OS TASK NAME SIZE found in OS CFG H Status This field indicates the status of each task A task can have the following statuses Ready The task is ready to run DELAY A task is waiting for time to expire The Timeout described later field indicates how many ticks remains before the t
14. ASK STK SIZE 1 your task prilo your task prio amp YourTaskStk 0 YOUR TASK STK SIZE or I0r 2 OS TASK OPW SUK CEIK OS TASK OPT SUK CR 3 OSTaskNameSet prio Your Task Name amp err 4 Listing 3 1 Creating a task when using C OS View 13 3 04 C OS View Terminal Window Support for a Terminal Window has been added in V1 10 The terminal window basically allows you to send characters i e keystrokes that you type on the Windows application s keyboard to your target Your target can then interpret these characters and perform actions that you determine for your target You target can also send ASCII strings back to the terminal window to provide you with feedback Figure 3 1 shows what happens when you select the Terminal Window and type at the keyboard Terminal 2 Display Help This menu 6 Display 5 i F3 1 1 F3 1 2 F3 1 3 F3 1 4 F3 1 5 F3 1 6 3 1 Keyboard Figure 3 1 Using the Terminal Window You press the character 1 at the keyboard C OS View displays the character typed on the terminal window C OS View sends the character typed to your target Your target gets a notification that a character has arrived from C OS View and performs some action that YOU determine In this case decided that receiving a 1 meant that you wanted to know what the current CPU usage is The target
15. Micri m Inc Copyright 2002 2003 Micri m Inc All Rights reserved C OS View V1 10 User s Manual Rev C ww Micrium com C OS View Table of Contents 08 C OS View C OS View 1 00 Introduction C OS View is a combination of a Microsoft Windows application program and code that resides in your target system i e your product The Windows application connects with your system via an RS 232C serial port as shown in Figure 1 1 The Windows application allows you to View the status of your tasks which are managed by C OS II pC OS View Target pC OS View Windows Application Your Product als w or LAN uC OS I pC OS View Processor Independent pC OS View Processor Specific RS 232C Communication L Figure 1 1 PC to target system via an RS 232C serial port C OS View C OS View allows you to view the following information from a C OS II based product The address of the TCB of each task The name of each task The status Ready delayed waiting on event of each task The number of ticks remaining for a timeout or if a task is delayed The amount of stack space used and left for each task The percentage of CPU time each task relative to all the tasks The number of times each task has been switched in The execution profile of each task More C OS View V1 10 also allows you to e Suspend the tick interrupt from de
16. Notify uC OS II of ISR completion Restore all the CPU registers Return from Interrupt 27 C OS View OSView RxTxISRHandler void OSView_RxTxISRHandler void File Called from OS VIEWc C OSView RXTXISR OS VIEWa ASM OSView RxTxISRHandler is called by the UART Universal Asynchronous Receiver Transmitter ISR Interrupt Service Routine that is generated when either a character is received or a character has been transmitted The Rx Tx ISR should be called OSView RxTxISR in OS VIEWa ASM If the UART issues a combined interrupt for a received and transmitted character then the ISR should call OSView RxTxISRHandler Arguments None Returned Value None Notes Warnings You don t need to write the contents of this function if your UART issues a combined ISR for both Rx and Tx characters However you MUST declare the function but leave the contents empty Example void OSView_RxTxISRHandler void INT8U c if Rx interrupt c Read character from UART OSView RxHandler c Pass to processor independent code Clear Rx interrupt if Tx interrupt OSView TxHandler Call processor independent code Clear Tx interrupt 28 C OS View OSView TickHook void OSView_TickHook void File Called from OS _VIEWc C OSTimeTickHook OS CPU C C OSView_TickHook MUST be called from the C OS II function OST
17. ask is ready to run MBOX The task is waiting on a message mailbox The Data field shows the address in Hexadecimal of the Event Control Block associated with the mailbox The Timeout field indicates the amount of time in ticks that the task is willing to wait for the mailbox to be posted An empty timeout indicates that the task will wait forever for the mailbox to be posted Q The task is waiting on a message queue The Data field shows the address in Hexadecimal of the Event Control Block associated with the queue The Timeout field indicates the amount of time in ticks that the task is willing to wait for the queue to be posted An empty timeout indicates that the task will wait forever for the queue to be posted MUTEX The task is waiting on a mutex The Data field shows the address in Hexadecimal of the Event Control Block associated with the mutex The Timeout field indicates the amount of time in ticks that the task is willing to wait for the mutex to be signaled i e released An empty timeout indicates that the task will wait forever for the mutex FLAG The task is waiting on an event flag group The Data field shows the address in Hexadecimal of the event flag group The Timeout field indicates the amount of time in ticks that the task is willing to wait for the desired flags to be set or cleared An empty timeout indicates that the task will wait forever for the desired flag s Data See Status Timeout See Statu
18. crementing delays and timeouts of tasks However you can step on tick at a time by pressing the F8 key from the Windows application The F6 key cancels this mode the F7 key enables this mode and the F8 key enables one tick to be processed e Pass keystrokes to you application from the Terminal window In other words you can now send commands to your product from the Windows application You determine the command structure e Output ASCII strings from the target to the Terminal window These ASCII strings are target specific and thus you can define those specific to your product 1 01 1 01 01 C OS View Revision History C OS View V1 10 C OS View V1 00 has been revised to support new features introduced in C OS IIl V2 62 and higher Specifically C OS View now support the stepping feature of the viewer In other words pressing the F7 key on the viewer pauses the C OS II ticker Pressing the F8 key allows one tick to be executed and pressing the F6 key resumes normal operation of the ticker Note that OSTimeTickHook is still called at the tick rate in case your application has time critical needs C OS View no longer needs to use OSTCBExtPtr C OS Il s OS TCB extension pointer This allows you to extend an OS TCB for your own use C OS II V2 61 now allows you to assign a name to a task and thus this feature is no longer part of C OS View There is no need for a C OS View task anymore since stack usage stat
19. de to disable interrupts from the UART Universal Asynchronous Receiver Transmitter transmitter Arguments None Returned Value None Notes Warnings This function should only disable interrupts from the transmitter and not affect other interrupt sources For this you may need to read the current interrupt disable mask register alter the bit s needed to disable the transmitter interrupt and write the new value to the interrupt mask register Example void OSView_TxIntDis void Disable Tx interrupts coming from the UART 36 C OS View OSView_TxIntEn void OSView_TxIntEn void File Called from OS_VIEWc C The processor specific and independent code OS VIEW C and OS VIEWc C OSView_TxIntEn is called by the processor independent code to enable interrupts from the UART Universal Asynchronous Receiver Transmitter receiver Arguments None Returned Value None Notes Warnings This function should only enable interrupts from the transmitter and not affect other interrupt sources For this you may need to read the current interrupt disable mask register alter the bit s needed to enable the transmitter interrupt and write the new value to the interrupt mask register Example void OSView_TxIntDis void Enable Tx interrupts coming from the UART 37 C OS View OSView TxISR void OSView_TxISR void File Called from OS _VIEWa ASM The UART Tx
20. ed If the UART issues a combined interrupt for a received and transmitted character then the ISR should call OSView_RxTxISRHandler OSView_TxISRHandler needs to call OSView_TxHandler to have this processor independent function determine whether there is another character to send and send the character if there is Arguments None Returned Value None Notes Warnings None Example void OSView_TxISRHandler void OSView_TxHandler Call the processor independent handler Clear the Tx interrupt 39 C OS View 3 07 C OS View Target Configuration C OS View requires that you set some configuration constants which are generally placed in OS _VIEWc H OS_VIEW_BAUDRATE OS_VIEW_RX_BUF_SIZE OS_VIEW_TX_BUF_SIZE OS_VIEW_TX_STR_SIZE This constant defines the RS 232C communications baud rate between the Windows application and your target system The default baud rate is 38400 and you should not change it unless your processor and serial port is unable to support this speed The serial port is configured for 8 bits no parity and 1 stop bit This define determines the size of the buffer used to receive packets from the Windows application You should not have to change the default value of 20 This define determines the size of the buffer used to hold reply packets going back to the Windows application The size you need depends on the number of tasks in your application Each task requires 4 bytes However
21. elimiter This is a single byte and is always the value 0x8D 43 4 01 to the request C OS View Packet Commands This section describes the data communication protocol between the Windows based application and your target Normally the Windows application requests information from the target and the target replies section 3 04 Terminal Window without being asked C OS View However the target is able to send an ASCII string to the Windows application see When the Windows application is started it sends the s command see below continuously unless it receives a valid response applition until the target system responds correctly to the s command In other words none of the other commands will be sent by the Windows Command Windows gt Target Bytes Target gt Windows Bytes Description Name Hex Packet Hex Packet Send byte OxED SD0 1 No reply 0 Send a single byte from the to target Ox8C SD1 1 Terminal Window to the C cmd 0x02 LEN 1 target 0x43 C 1 0xBB SUM n Note that you can call Ox8D ED i OSView_TxStr to send strings back to the terminal window based on characters you receive from the terminal window System OxED SD0 1 Ox8C SD0 Get general information Information 0x8C SD1 1 OxED SD1 about the target s cmd 0x01 LEN 1 0x33 LEN 0x73 s 1 Os Csr CPU Name is an ASCII Ox8C SUM l OSTime 4 string that is NOT NUL 0x8D ED 1 OSTCBCur 2 termina
22. escribed later SUM Is the two s complement of the unsigned 8 bit sum of the LEN and Command Data bytes In other words SUM INT8U LEN Command Data amp OxFF When the target receives the packet from the Windows application it adds in the received sum from the Windows application and the result should be 0x00 ED End delimiter This is a single byte and is always the value 0x8D When the target replies to a request from the Windows application it uses a similar structure but the start delimiters are slightly different as shown in figure 4 2 C OS View 1 1 1 Bytes N 1 1 OR Figure 4 2 Target gt Windows application packet structure SDO Start Delimiter 0 This is a single byte and is always the value 0x8c Note that it s different from the packet sent by the Windows application SD1 Start Delimiter 1 This is a single byte and is always the value 0xED Note that it s different from the packet sent by the Windows application LEN This is a single byte and contains the length of the Command Data portion of the packet in bytes Data Is the data sent back to the Windows application based on the command received The number of bytes sent back depends on the command to execute The commands are described in section 4 01 C OS View Packet Commands SUM Is the unsigned 8 bit sum of the LEN and Data bytes In other words SUM INT8U LEN Data amp OxFF ED End d
23. ew RxTxISR OSView RxTxISRHandler OSView Tick Hook OSView TimeGetCycles OSView Tx1 OSView TxInt OSView TxIn OSView TXIS OSView TxIS Dis En R RHandler EW C i e the target independent code 17 OSView Exit void OSView_Exit void File Called from OS_VIEWc C Your Application C OS View OSView Exit is called by your application when you want to stop running C OS View This function is meant to perform some cleanup operations such as disabling Rx or Tx interrupts releasing interrupt vectors and so on Arguments None Returned Value None Notes Warnings None Example void Task void pdata pdata pdata while 1 if Done using uC OS View OSView_Exit void OSView_Exit void Disable Tx and Rx interrupts Release interrupt vectors 18 C OS View OSView GetCPUName void OSView GetCPUName char s File Called from OS VIEWc C OSView CmdGetSysInfo OS VIEW C OSView GetCPUName is called by the processor independent code to obtain the name of the CPU that the viewer is connected to This function is trivial to write since it only involves copying the name of the processor into a string Arguments s is a pointer to the name of the CPU The name of the CPU should NOT exceed 29 characters 30 if you include the NUL character
24. g doesn t have an interrupt stack or you have not implemented that feature in software then this function should return 0 Arguments None Returned Value None Notes Warnings You should not be calling this function from your application because it is called by the processor independent code Example INT32U OSView_GetIntStkSize void return INT32U amp OSIntStkSize OR INT32U OSView_GetIntStkSize void return INT32U 0 If there is no interrupt stack 21 C OS View OSView InitTarget void OSView_InitTarget void File Called from OS _VIEWc C OSView Init OS VIEW C OSView_InitTarget is called by the processor independent code OSView_ Init to initialize the timer interrupt vectors and the RS 232C serial port used to interface with the Windows application portion of C OS View Arguments None Returned Value None Notes Warnings You should not be calling this function from your application because it is called by the processor independent code Example void OSView_InitTarget void Initialize the 16 or 32 bit timer used to measure execution time Initialize the RS 232C port to the desired baud rate 2y Setup interrupt vectors Enable timer and UART interrupts x 22 C OS View OSView RxIntDis void OSView_RxIntDis void File Called from OS _VIEWc C The processor specific code
25. ictions 1 You MUST use C OS II V2 62 or higher 2 You need to change the port files see OS_CPU_C C such that e OSTaskCreateHook CALLS OSView TaskCreateHook and passes it ptcb e OSTaskSwHook CALLS OSView_TaskSwHook e OSTimeTickHook CALLS OSView TickHook 3 Your OS _CFG H MUST set the following constants as follows e OS TASK CREATE EXT ENtol Enable OSTaskCreateExt e OS TASK STAT ENtol Enable the statistic task e OS TASK STAT STK CHK ENtol Enable stack checking by the statistic task e OS TASK NAME SIZE to 16 or higher Enable task names e OS TASK PROFILE EN tol Enable the profiling variables in OS TCB 4 You MUST create ALL your tasks using OSTaskCreateExt instead of OSTaskCreate 5 You MUST call OSTaskNameSet AFTER you call OSTaskCreateExt see below if you want to see the task names appear in the Windows application If you don t assign names to your tasks they will be displayed as 6 You need to dedicate an asynchronous serial port also known as a UART to C OS View 7 You cannot have more than 63 total tasks including the idle task In other words C OS View doesn t currently allow you to monitor an application that has the C OS II maximum number of task i e 64 tasks The highest number for OS_MAX_TASKS is given below fOS TASK ses 1 0S MAX TASKS cannot be higher than 61 fOS TASK STAT EN 0 0S MAX TASKS cann
26. imeTickHook Hopefully you would have access to the C OS II port files and thus you should simply add the call to this function there Arguments None Returned Value None Notes Warnings None Example See OSView TimeCyclesGet next function for a description of the code presented in this example Also the example assumes that a 16 bit up timer is used counts from 0x0000 to OxFFFF and rolls over to 0x0000 void OSTimeTickHook void uC OS II function in OS CPU C C OSView_TickHook void OSView_TickHook void Function defined in OS VIEWC C INT16U cnts16 INT16U delta cnts16 Read counts from timer chip delta cnts16 OSView TmrCntsPrev OSView CyclesCtr delta OSView TmrCntsPrev cntsl6 29 OSView TimeGetCycles INT32U OSView_TimeGetCycles void File Called from OS_VIEWc C Processor independent code OS VIEW C C OS View OSView TimeGetCycles is called by the processor independent code to read the current absolute time which is generally provided by a real time clock or a timer Preferably this clock would have a resolution in the microsecond range or better A 32 bit counter is preferable However if you can t get this from your hardware you can obtain sufficient resolution from a 16 bit counter as long as you can keep track of overflows or sample the timer faster than its overflow rate OSView_TimeGetC
27. interrupt OSView_TxISR is the interrupt service routine ISR that is invoked by the processor hardware when a character has been transmitted by the UART Universal Asynchronous Receiver Transmitter If the UART issues a combined interrupt for a received and transmitted character then your interrupt should vector to OSView_RxTxISR instead OSView TxISR should call OSView _TxISRHandler to process the interrupt from C instead of assembly language Arguments None Returned Value None Notes Warnings You don t need to write the contents of this function if your UART issues a combined ISR for both Rx and Tx characters However you MUST declare the function but leave the contents empty Example Pseudo code OSView_TxISR Save ALL CPU registers OSIntNesting Notify uC OS II of ISR entry if OSIntNesting 1 Save SP in TCB if first nested ISR OSTCBCur gt OSTCBStkPtr SP OSView_TxISRHandler Call the C Handler in OS_VIEWc C OSIntExit Notify uC OS II of ISR completion Restore all the CPU registers Return from Interrupt 38 C OS View OSView TxISRHandler void OSView TxISRHandler void File Called from OS VIEWC C OSView TxISR OS VIEWa ASM OSView TxISRHandler is called by the UART Universal Asynchronous Receiver Transmitter ISR Interrupt Service Routine that is generated when a character has been transmitt
28. istics are now determined by C OS Il s statistic task This means that C OS View doesn t eat up a task and stack space Also statistics variables allocated by C OS View are no longer needed since those have been placed in C OS II s OS TCB C OS View 2 00 C OS View Windows Application Figure 2 1 shows C OS View s four main display areas which are described next Task List System Variables Terminal Window CPU load vs Time Systems Variables Display Area See section 2 02 PON gt Task List Display Area ci See section 2 01 a ee Systen variables OK Name Status Stack CPULoad ContextSwitches Name Value 20B3438C Start Task DELAY 612 800 20B31520 0 00 88110 OS VERSION 2 62 20B343F3 uC OS View Terminal MBox p 380 800 20B33794 0 00 157 CPU 80x86 Large 20B3445A Task 1 Ready 188 800 20831840 68 75 29363 Ticks 1762358 20B344C1 Task 2 DELAY 188 800 20B31B60 0 00 18237 Tasks 14 20B34528 Task 3 Ready 194 800 20B31E80 0 00 18097 Current OS_TCB 20B342BE 20B3458F Task 4 Ready 182 800 20B321A0 0 00 18089 Int Stack n a 20B345F6 Task 5 DELAY 188 800 20B324C0 3 12 18069 20B3465D Task 6 Ready 188 800 20B327E0 3 12 18828 20B346C4 Task 7 Ready 182 800 20B32B00 0 00 18082 20B3472B Task 8 Ready 188 800 20B32E20 0 00 18104 20B34792 Task 9 Ready 188 800 20833140 0 00 18064 20B347F9 Task 10 DELAY 5 186 800 20833460 6 25 18918 208
29. ot be higher than 62 8 If you want to use the Terminal Window feature you need to declare a Callback function that will handle characters sent from the Windows application See section 3 04 9 You MUST call OSView Init AFTER calling oSStatInit 10 You MUST set OS TASK NAME SIZE see OS_CFG H greater than 16 12 C OS View 3 02 Initializing C OS View In order to use C OS View you need to initialize the target resident software The function OSView_Init is provided to initialize C OS View and should be called AFTER you called OSStatInit which you must do 3 03 Creating tasks All your C OS II tasks need to be created with OSTaskCreateExt because the target resident software makes use of additional variables only available with OSTaskCreateExt L3 1 1 Make sure you use OSTaskCreateExt L3 1 2 You should pass a NULL pointer as the pext argument if you are not using the TCB extension L3 1 3 You must also specify that you want to enable stack checking for the task as well as clear the stack upon task creation L3 1 4 You must call OSTaskNameSet and pass this function the task priority as well as a name you would like to give to the task The name can contain spaces and some punctuation marks The size number of characters of the name MUST be less than OS TASK NAME SIZE 1 INNS ETE OSTaskCreateExt YourTask 1 void 0 amp YourTaskStk YOUR_T
30. piler data space is shown in the table below Data Type Quantity required As Configured Bytes INT8U Tt Lo of 539 OS VIEW RX BUF SIZE 20 OS VIEW TX BUF SIZE 255 4 OS VIEW TX STR SIZE 255 INT16U 9 9 18 void 2 2 8 Total 565 Table 3 3 C OS View data storage on an 80x86 Large Model 41 C OS View 4 00 C OS View Communication Protocol This section describes the data communication protocol between the Windows based application and your target Normally the Windows application requests information from the target and the target replies to the request However the target is able to send an ASCII string to the Windows application see section 3 04 Terminal Window without being asked Data is sent between the Windows application and the target in Packets The Windows applications send data to the target using the packet structure shown in Figure 4 1 1 N Bytes 1 1 i 1 OR Figure 4 1 Windows application gt target packet structure SDO Start Delimiter 0 This is a single byte and is always the value 0xED SD1 Start Delimiter 1 This is a single byte and is always the value 0x8C LEN This is a single byte and contains the length of the Command Data portion of the packet in bytes Command Data Is the command sent to the target The command can be accompanied by a number of bytes which are specific to the command d
31. raph You simply select the tasks that you want to view by name Communication General CPU View Log Show Totalforalltasks J Ignore CPU load of lowest priority task Task selection lv Use Filter stetTask Task 1 None cance al Figure 2 3 Selecting to graph only four tasks Figure 2 4 shows the profile of the four tasks selected 10 C OS View pC OS View V3 10g TOX Task list H Ox System variables E OX Id Name Status Stack CPULoad ContextSwitches Name Value 20B3438C Start Task DELAY 612 800 20B31520 0 00 104965 OS VERSION 2 62 20B343F3 uC OS View Terminal MBox 20B336E6 380 800 20B33794 0 00 157 CPU 80x86 Large 20B3445A Task 1 Ready 188 800 20B31840 64 21 61263 Ticks 2099460 20B344C1 Task 2 DELAY 188 800 20B31B60 0 00 39624 Tasks 14 20834528 Task 3 Ready 194 800 20B31E80 0 00 39450 Current OS_TCB 20B3445A 20B3458F Task 4 Ready 188 800 20B321A0 0 00 39436 Int Stack n a 20B345F6 Task 5 DELAY 188 800 20B324C0 2 10 39419 20B3465D Task 6 Ready 188 800 20B327E0 4 21 40947 20B346C4 Task 7 Ready 188 800 20B32B00 0 00 39430 20B3472B Task 8 DELAY 182 800 20B32E20 0 00 39479 20B34792 Task 9 Ready 186 800 20B33140 0 00 39408 20B347F9 Task 10 Ready 188 800 20833460 5 26 41215 20B34325 uC OS II Stat DELAY 198 234 1024 20B3419A 0 00 10420 20B342BE uC OS I Idle Ready 172 1024 20B345AE 25 00 125645 y 3 Terminal
32. rguments None Returned Value None Notes Warnings You don t need to write the contents of this function if your UART issues a combined ISR for both Rx and Tx characters However you MUST declare the function but leave the contents empty Example Pseudo code OSView_RxISR Save ALL CPU registers OSIntNesting Notify uC OS II of ISR entry if OSIntNesting 1 Save SP in TCB if first nested ISR OSTCBCur gt OSTCBStkPtr SP OSView_RxISRHandler Call the C handler in OS VIEWc C OSIntExit Notify uC OS II of ISR completion Restore all the CPU registers Return from Interrupt 25 C OS View OSView RxISRHandler void OSView_RxISRHandler void File Called from OS VIEWc C OSView RxISR OS VIEWa ASM OSView RxISRHandler is called by the UART Universal Asynchronous Receiver Transmitter ISR Interrupt Service Routine that is generated when a character is received The Rx ISR should be called OSView_RxISR see previous page in OS VIEWa ASM If the UART issues a combined interrupt for a received and transmitted character then the ISR should call OSView RxTxISRHandler OSView RxISR should call OSView RxISRHandler to process the interrupt from C instead of assembly language Arguments None Returned Value None Notes Warnings You don t need to write the contents of this function if your UART issues a combined ISR for both
33. s C OS View Stack This field contains three pieces of information the amount of stack space used in bytes the total stack space available to the task in bytes and the base address of the task s stack If the stack grows downwards from high to low memory then this field contains the highest memory location of your stack If the stack grows upwards from low to high memory then this field contains the lowest memory location of your stack This field is useful to see just how much stack space is left for each task CPULoad This field indicates the amount of CPU time consumed by each task expressed as a percentage Of course a higher number indicates that your task consumes a high amount of the CPU s time ContextSwitches Contains the total number of context switches to the task since your application started 2 02 System Variables The Systems Variables area contains general information about your target Specifically OS_VERSION This field indicates the version of C OS II running in your target system This field will not change at run time CPU Indicates the type of CPU in your target system This field will not change at run time Ticks Contains the value of C OS lII s global variable OSTime which indicates the number of ticks since power up or since you last called OSTimeSet Tasks Contains the total number of tasks in your target application Current OS_TCB Contains the address of the current task s OS TCB
34. ted OS_VERSION 2 alt CPU Name 30 IntStkBase 4 IntStkSize 4 SUM SUM Ox8D ED Task OxED SDO 1 0x8C SDO Get information about a Information Ox8C SD1 1 OxED SD1 specific task t cmd 0x05 LEN 1 LEN LEN 0x74 Et i Ox TAE OSTCBTaskName is an Task ID OSViewCyclesCtr j SUM SUM 1 OSTCBTaskName PESO Say orate es ree Ox8D ED 1 OSTCBTaskPrio OSTCBStat F OSTCBEVentPtr i OSTCBDly F OSTCBCyclesTot OSTCBCtxSwCtr OSTCBStkBase 6 TOS TOBSEKS TZET sizeof OS STK SUM SUM 0x8D ED 44 C OS View Task List OxED SD0 1 Ox8C SD0 Get a list of Task IDs from TP cmd Ox8C SD1 1 OxED SD1 the target Task IDs are 0x01 LEN LEN LEN simply the addres of the Ox6C 1 Oe SL TCB of each task 0x93 SUM 1 Oxia Ver 0x8D ED 1 E de 7 Note that N in the reply PLO OSTCBPrioTbl 2 4 correspondsto lt SCR P ciel 3 4 OS_LOWEST_PRIO in OSTCBPrioTbl 4 4 C OS II However OSTCBPrioTbl 5 4 OS_LOWEST_PRIO must be less than or equal to 62 OSTCB PrioTbl N 4 SUM SUM Ox8D ED Step OxED SDO 1 0x8C SDO This commands allows the S cmd Ox8C SD1 1 OxED SD1 target system to receive 0x02 LEN 1 0x01 LEN step mode commands 0x53 S x 0 55 CS see section 2 05 Step Data 0x54 SUM Mode SUM SUM 1 0x8D ED 0x8D ED E Data in the command is as follows 0x00 means disable step 0x01 means wait for a step i e
35. the target specific code to enable interrupts from the UART Universal Asynchronous Receiver Transmitter receiver This function must ONLY enable receiver interrupts Arguments None Returned Value None Notes Warnings This function should only enable interrupts from the receiver and not affect other interrupt sources For this you may need to read the current interrupt disable mask register alter the bit s needed to enable the receiver interrupt and write the new value to the interrupt mask register Example 80x86 port using COM1 on a PC void OSView_RxIntEn void if OS CRITICAL METHOD OS CPU SR cpu sr tendif INT8U stat INT8U cmd OS ENTER CRITICAL stat inp OS VIEW 8250 BASE OS VIEW 8250 IER BITO outp OS VIEW 8250 BASE OS VIEW 8250 IER stat cmd inp OS VIEW 8259 MASK REG amp OS VIEW 8259 COMM INT EN outp OS VIEW 8259 MASK REG cmd OS _ EXIT CRITICAL 24 C OS View OSView RxISR void OSView_RxISR void File Called from OS _VIEWa ASM The UART Rx interrupt OSView_RxISR is the interrupt service routine ISR that is invoked by the processor hardware when a character is received by the UART Universal Asynchronous Receiver Transmitter If the UART issues a combined interrupt for a received and transmitted character then your interrupt should vector to OSView_RxTxISR instead A
36. then formats a reply string and send it to the terminal window C OS View sees that an ASCII string is received from the target and displays it on the terminal window 14 C OS View Figure 3 1 shows that typed other characters Specifically typing a 2 results in the target replying back with the number of tasks created Typing a 3 resulted in displaying this simple menu In fact the code have only recognizes either a 1 ora 2 and any other key displays the menu In order for the target to recognize the keys being sent from the terminal window you need to install a callback function by calling OSView_TerminalRxSetCallback In other words when a character is received the C OS View s target resident code calls the function that you install The code below shows how that s done OSView_TerminalRxSetCallback TestTerminalCallback and the code for the callback looks as follows void TestTerminalCallback INT8U data OSMboxPost TestTerminalMbox char data C OS View will call your function and pass it the character received from the terminal window You need to know that the callback Test TerminalCallback in the case above is called by an ISR and thus you should post the character received to a task as shown above and let the task process the received character as shown in the code below Of course the mailbox needs to be created before it s actually used by the callback
37. ycles is called whenever a context switch occurs to record when a task completes and when the new task starts executing Arguments None Returned Value A 32 bit value representing absolute time Notes Warnings You should not be calling this function from your application because it is called by the processor independent code 30 C OS View Example assuming a 16 bit up counter The drawing below shows a free running timer that counts up from 0 to 65535 and rolls over to 0 If C OS II s tick rate is faster than the rollover rate then you could sample this free running timer by hooking into C OS II s tick ISR as shown in the code below OSView CyclesCtr simply needs to contain the sum of the Deltas Because we use unsigned arithmetic a small New value minus a large Prev value results in the proper delta OSView CyclesCtr is actually updated in both OSView_TickHook and OSView_TimeGetCycles You should note that OSView TimeGetCycles can actually be called at just about any time and thus also needs to update OSView CyclesCtr before it returns the current value OSView TimeGetCycles needs to return the current value of OSView CyclesCtr Prev 6595359 New L OSView TimeGetCycles OSView TickHook 0 Prev Delta New Prev Delta New Prev p Time OSView CyclesCtr INT32U OSView TimeGetCycles void pdata INT32U cycles INT16U cntsl6 INT16U delta
38. you should not set this define to a value less than 64 The maximum is 255 which allows you to display the status of up to 63 tasks This define determines the size of the buffer used to hold reply packets going back to the Terminal Window The size you need depends on the maximum number of characters you will send to the terminal window using OSView TxStr You should not set this define to a value less than 64 The maximum is 255 40 3 08 ROM and RAM usage C OS View C OS View consumes both code space i e ROM and data space i e RAM Code Space Data Space It s difficult to determine the exact amount of code space needed because this is compiler dependent On an Intel 80x86 Large Model compiled using the Borland C C V4 52 compiler code space is about 4 5 Kbytes Data space usage is determined by the following equation 7 sizeof INT8U OS VIEW_RX BUF SIZE OS VIEW TX BUF SIZE OS VIEW TX STR_SIZI 9 e sizeof IN sizeof IN sizeof IN ERA sizeof INT16U 2 sizeof void T8U T8U T8U A different way of computing this information is shown in table 3 2 Data Type Quantity required INT8U 7 OS VIEW RX BUF SIZE 4 OS VIEW TX BUF SIZE 4 OS VIEW TX STR SIZE INT16U 9 void 2 Table 3 2 C OS View data storage requirements On an Intel 80x86 Large Model compiled using the Borland C C V4 52 com

Download Pdf Manuals

image

Related Search

Related Contents

マルチラベルプレートカウンターARVO X5 利用法(簡略版) 1. 起動 2. 測定  MANUAL DE USUARIO  Pyle Car Speakers User Manual  FUEL PRO® 482 - DAVCO Technology  高性能エア供給装置 ASCシリーズ  Lochinvar ARM3072PAB User's Manual  Samsung BQ2D7G144, Piekarnik elektryczny    Compact Hydraulic Steering  

Copyright © All rights reserved.
Failed to retrieve file