|
|||||||||||
Technical Support On-Line Manuals µVision3 User's Guide µVision3 Overview User Interface Creating Applications Utilities Debugging Debug Commands Debug Functions Creating Functions Invoking Functions Predefined Functions __acos __asin __atan __cos __exp __log __log10 __sin __sqrt __tan _RBYTE _RDOUBLE _RDWORD _RFLOAT _RWORD _sleep_ _TaskRunning_ _WBYTE _WDOUBLE _WDWORD _WFLOAT _WWORD exec execf (Cortex-M) F32ToRawF16 F32ToRawF32 F64ToRawF64 getdbl getint getlong memset printf rand RawF16ToF32 RawF32ToF32 RawF64ToF64 rwatch swatch twatch wwatch User Functions Signal Functions Differences Between µVision3 and C Differences Between µVision3 and dScope Simulation Flash Programming Dialogs Example Programs Command Line Appendix |
Signal FunctionsA Signal function let you repeat operations, like signal inputs and pulses, in the background while µVision3 executes your target program. Signal functions help you simulate and test serial I/O, analog I/O, port communications, and other repetitive external events. Signal functions execute in the background while µVision3 simulates your target program. Therefore, a signal function must call the twatch function at some point to delay and let µVision3 run your target program. µVision3 reports an error for signal functions that never call twatch. Note
Signal functions begin with the SIGNAL keyword and are defined as follows: SIGNAL void fname (parameter_list) { statements }
ExampleThe following example shows a signal function that puts the character 'A' into the serial input buffer once every 1,000,000 CPU states. For more information refer to Creating Functions. SIGNAL void StuffS0in (void) { while (1) { S0IN = 'A'; twatch (1000000); } } To invoke this function, type the following in the command window. StuffS0in() When invoked, the StuffS0in signal function puts and ASCII character 'A' in the serial input buffer, delays for 1,000,000 CPU states, and repeats. RestrictionsThe following restrictions apply to signal functions:
Managing Signal FunctionsµVision3 maintains a queue for active signal functions. A signal function may either be either idle or running. A signal function that is idle is delayed while it waits for the number of CPU states specified in a call to twatch to expire. A signal function that is running is executing statements inside the function. When you invoke a signal function, µVision3 adds that function to the queue and marks it as running. Signal functions may only be activated once, if the function is already in the queue, a warning is displayed. View the state of active signal functions with the command SIGNAL STATE. Remove active signal functions form the queue with the command SIGNAL KILL. When a signal function invokes the twatch function, it goes in the idle state for the number of CPU states passed to twatch. After the user program has executed the specified number of CPU states, the signal function becomes running. Execution continues at the statement after twatch. If a signal function exits, because of a return statement, it is automatically removed from the queue of active signal functions. Analog ExampleThe following example shows a signal function that varies the input to analog input 0 on a C167. The function increases and decreases the input voltage by 0.5 volts from 0V and an upper limit that is specified as the signal function's only argument. This signal function repeats indefinitely, delaying 200,000 states for each voltage step. signal void analog0 (float limit) { float volts; printf ("Analog0 (%f) entered.\n", limit); while (1) { /* forever */ volts = 0; while (volts <= limit) { ain0 = volts; /* analog input-0 */ twatch (200000); /* 200000 states Time-Break */ volts += 0.1; /* increase voltage */ } volts = limit; while (volts >= 0.0) { ain0 = volts; twatch (200000); /* 200000 states Time-Break */ volts -= 0.1; /* decrease voltage */ } } } The signal function analog0 can then be invoked as follows: >ANALOG0 (5.0) /* Start of 'ANALOG()' */ ANALOG0 (5.000000) ENTERED The SIGNAL STATE command to displays the current state of the analog0: >SIGNAL STATE 1 idle Signal = ANALOG0 (line 8) µVision3 lists the internal function number, the status of the signal function: idle or running, the function name and the line number that is executing. Since the status of the signal function is idle, you can infer that analog0 executed the twatch function (on line 8 of analog0) and is waiting for the specified number of CPU states to elapse. When 200,000 states pass, analog0 continues execution until the next call to twatch in line 8 or line 14. The following command removes the analog0 signal function from the queue of active signal functions. >SIGNAL KILL ANALOG0 | ||||||||||
|
Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.