|
|||||||||||
Technical Support On-Line Manuals µVision User's Guide About µVision 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 µVision and C Simulation Flash Programming Dialogs Example Programs Command Line Appendix |
Signal FunctionsSignal Functions repeat operations in the background while µVision runs the target program. They help simulating and testing serial and analog I/Os, port communications, and other repetitive external events, like signal inputs and pulses. Signal functions are created by the developer directly in the Command window or using the function editor. Refer to Creating Functions for details. It is mandatory to call the built-in function twatch at least once to delay execution and let µVision run the target program. An error is triggered for signal functions that never call twatch. System Variables can be used in signal functions. Signal functions begin with the keyword SIGNAL and are defined as follows: SIGNAL void fname (parameter_list) { statements } Where
ExampleThe following signal function puts the character 'A' into the serial input buffer, delays for 1,000,000 CPU states, and repeats. SIGNAL void StuffS0in (void) { while (1) { S0IN = 'A'; twatch (1000000); } } Invoke the function by typing the function name into the Command window. StuffS0in() Restrictions
Managing Signal FunctionsµVision maintains a queue for all active signal functions. A signal function can have the state idle or running. When a signal function invokes the twatch function, it goes into 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. When invoked, the signal function is added to the queue and gets marked as running. Signal functions can be invoked only once. If the function is invoked twice, then a warning is displayed. If a signal function exits because of a return statement, then it is removed automatically from the queue of active signal functions.
The command SIGNAL STATE shows the
state of all active signal functions. Analog ExampleThe following example shows a signal function that varies the analog input ain0 on a C167. The function increases and decreases the input voltage by 0.5 volts between 0V and an upper limit specified in the function argument. This signal function repeats indefinitely, delaying 200,000 CPU 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.5; /* increase voltage */ } volts = limit; while (volts >= 0.0) { ain0 = volts; twatch (200000); /* 200000 states Time-Break */ volts -= 0.5; /* decrease voltage */ } } } Invoke the function: >ANALOG0 (5.0) /* Start of 'ANALOG()' */ View the state of the function: >SIGNAL STATE 1 idle Signal = ANALOG0 (line 8) The Command window lists the internal function number, the status of the signal function, the function name and the line number that is executing. Remove the 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.