The LabVIEW Embedded Module for ADI Blackfin Processors allows you to program the Analog Devices Blackfin Processor using LabVIEW. In many designs, the processor must monitor an external device for a signal, such as a push button press, and when that signal is received, some reaction is needed. In this document, we will discuss the two primary ways -- polling and callbacks -- you can use to respond to external signals in an embedded application.
Polling and callbacks are the two primary ways a processor responds to an external signal. With polling, the processor constantly monitors the signal and waits for a change. When a change is detected, the processor continues its execution and handles the change accordingly. The major benefit of using polling is that the application has the fastest possible response to the signal. However, polling requires that some of the processor's computation time be dedicated to the polling operation. Therefore, any additional operations that occur in parallel to the polling does not have full use of the processor.
With callbacks, also known as interrupts, the processor does not need to explicitly monitor the signal in the application. Instead, the application registers the signal with the embedded operating system, which for the Blackfin processor is the Visual DSP++ Kernel (VDK). When the OS detects the signal, the OS temporary halts the embedded application and executes an interrupt service routine (ISR). Once the ISR completes, the execution returns to the embedded application. The main benefit of using callbacks is that the main embedded application does not have to spend processor resources on monitoring a signal. Therefore, parallel applications are more efficient. However, callbacks do introduce a delay, or latency, between when the signal is detected and the corresponding reaction.In general, if the application is performing a single task, or if minimizing latency is critical, polling is probably the most appropriate. If the application has many parallel operations or if latency is tolerable, callbacks are most suitable.
You can use a Case structure, the BF Is Button Pushed VI, and a While Loop to poll a push button. No additional configuration is needed.
Creating a callback-based application requires a bit more configuration than polling. You must associate the callback VI with a push button. Complete the following steps to associate a callback VI with a push button.
Firing a Timed Loop from a Callback VIWhen using callbacks, or interrupts, you need to create a separate thread to free up processor resources. Use a Timed Loop to create a separate thread that sleeps until the OS detects the interrupt. In the Embedded Module for Blackfin Processors, each Timed Loop executes in its own OS thread. You can independently set the priority of each Timed Loop as well as select the timing source.Before you can fire a Timed Loop from an ISR VI, you must create an external timing source. Use the Create External Timing Source VI to create the external timing source. Use the Fire External Timing Source VI to fire a Timed Loop from and ISR VI.As a general rule, you want to spend as little time as possible in the interrupt. ISR VIs have limited capabilities. One of the limitations is that no memory allocation is allowed. Because placing a string constant on the block diagram of the ISR VI allocates memory, use a global variable to get the name of the external timing source.
To configure a Timed Loop to fire from an external timing source, you must configure the Timed Loop options so the external timing source appears as an input of the Timed Loop. Complete the following steps to configure the Timed Loop so the external timing source appears as an input.
Right-click the Input Node of the Timed Loop and select Configure Timed Loop from the shortcut menu to open the Loop Configuration dialog box.
Under Timing source, place a checkmark in the Use terminal checkbox.
Click the OK button.
You can now wire a string to the Input Node of the Timed Loop.
Collaborate with other users in our discussion forums
A valid service agreement may be required, and support options vary by country.