...
This application note contains instructions for using the IAR embedded workbench for Arm to compile the single core BSP for the Cortex M7 running on the STM32H747 Discovery board (EVK), generating .awb, .h and .c files from a design, and using the control interface API to enable hardware control of the embedded design. This guide assumes the user has some experience with Audio Weaver. While integration code is hardware specific, the general process of debugging and using the control interface is applicable to all bare metal targets.
Building and flashing a BSP with IAR Embedded workbench for Arm
...
In main.c define RUN_STANDALONE (line 17) and include “HW_Button_Mute_InitAWB.h” (line 21). This will instruct the board to load a design on startup in standalone mode. When compiled, the code will call awe_loadAWBfromArray() which references the “Core0_InitCommands” array generated previously from Designer.
...
After loading the AWB array, AWEIdleLoop() is called. In the idle loop context, non-real-time tasks are processed as a low priority background task. This includes the processing of tuning commands, deferred processing, and any Control command processing, as opposed to audio processing which should be set as the highest priority.
...
A dynamic view of the execution and pre-emption of these tasks is shown below. The lightly shaded areas mean that the task has been triggered but is not currently executing because it has been pre-empted by another, higher priority task. Note that priority order is configured by the app/BSP writer.
Include “HW_Button_Mute_ControlInterface.h” in AWEPlatform.c. For this example we’ll also declare some variables for the control interface steps.
Code Block |
---|
//Add these 5 lines for Application Note Example
#include "HW_Button_Mute_ControlInterface.h"
UINT32 buttonState;
UINT32 lastButtonState;
UINT32 runTime;
UINT32 classID;
UINT32 muteStatus; |
Using the Control Interface with the STM32H747
...
https://w.dspconcepts.com/hubfs/Docs-AWECore/AWECore_API_Doc/index.html#ctrl-interface-overview
https://w.dspconcepts.com/hubfs/Docs-AWECore/AWECore_API_Doc/a00082.html
The below code was added to AWEIdleLoop() in AWEPlatform.c
...
Code Block | ||
---|---|---|
| ||
//Control I/O //If the Mute module is found... if (awe_ctrlGetModuleClass(&g_AWEInstance, AWE_Mute1_isMuted_HANDLE, &classID) == AWE_OBJECT_FOUND) { //...check that the module assigned this classID is of module class Mute if (classID == AWE_Mute1_classID) { //If the blue button on the board is pushed, mute the output in the design and turn on the Blue LED awe_pltGPIOGetPin(1, (UINT32 *)&buttonState); if (buttonState != lastButtonState) { awe_ctrlSetValue(&g_AWEInstance, AWE_Mute1_isMuted_HANDLE, (void *)&buttonState, 0, 1); BSP_LED_Toggle(LED_BLUE); lastButtonState = buttonState; } } } if (awe_ctrlGetModuleClass(&g_AWEInstance, AWE_SinkInt1_value_HANDLE, &classID) == AWE_OBJECT_FOUND) { if (classID == AWE_SinkInt1_classID) { //Read the "SinkInt" value from the design for total runTime(48bs) and toggle every 500 blocks awe_ctrlGetValue(&g_AWEInstance, AWE_SinkInt1_value_HANDLE, (void *)&runTime, 0, 1); if (runTime % 1000 > 500) { BSP_LED_On(LED_ORANGE); } else { BSP_LED_Off(LED_ORANGE); } } } |
We can add a line of code to “get” or “set” the status of a module and store it into a variable with the following:
Code Block |
---|
awe_ctrlGetStatus(&g_AWEInstance, AWE_Mute1_isMuted_HANDLE, (void *)&muteStatus); |
A helpful option while debugging is to “watch” variables. While running the code, highlight and right click any of the variables to “add to watch” to view a watched variables value in real time as you step through code.
...
Note: If many parameters are being sent via the control interface, it is advisable to send all parameters as a single array to a single Buffer Source module in the design. In the screenshot below, a BufferSourceInt module named “Control_IPC_In” receives an array from the application code, then outputs to a Control_Logic subsystem for next steps.
...