The A7 and M4 applications here are based on C code from various sources:
- Avnet's Starter Kit Out-of-Box demo code
- Microsoft's "Inter-core Communication ADC" sample code
- New custom enhancements from Avid and Avnet developers (OLED display messaging support with local- and cloud-sourced content, elevation calculation, inclusion of additional parameters in the telemetry message payload, etc)
For full step-by-step procedure and clarifying details, refer to the Azure Sphere Advanced Tutorial blog posting on Element14
The Microsoft Inter-core Communication ADC sample code demonstrates how to exchange messages between applications running on the high-level and real-time capable cores. Once per second the high-level application sends a message "Read-ADC-%d", where %d is an incrementing counter to the real-time capable application. The real-time capable application prints the received data (output on the M4 UART IO0, that can be accessed via pins 1 and 3 on header J11), reads the ADC channel 0 (light sensor) and sends the measured value to the high-level application.
The high-level application uses the following Azure Sphere libraries and includes beta APIs:
Library | Purpose |
---|---|
application.h | Communicates with and controls real-time capable applications |
log.h | Displays messages in the Visual Studio Device Output window during debugging |
The real-time capable features used in the sample are in Beta.
To use this sample, clone the repository locally if you haven't already done so:
git clone https://github.com/CloudConnectKits/Azure_Sphere_SK_ADC_RTApp.git
- Avnet Azure Sphere MT3620 Starter Kit.
- A breakout board and USB-to-serial adapter (for example, FTDI Friend) to connect the real-time capable core UART to a USB port on your PC.
- A terminal emulator (such as Telnet or PuTTY) to display the output.
Prep your device
-
Ensure that your Azure Sphere device is connected to your PC, and your PC is connected to the internet.
-
Even if you've performed this set up previously, ensure that you have Azure Sphere SDK version 19.05 or above. In an Azure Sphere Developer Command Prompt, run azsphere show-version to check. Download and install the latest SDK as needed.
-
Right-click the Azure Sphere Developer Command Prompt shortcut and select More>Run as administrator.
-
At the command prompt, issue the following command:
azsphere dev prep-debug --EnableRTCoreDebugging
This command must be run as administrator when you enable real-time capable core debugging because it installs USB drivers for the debugger.
-
Close the window after the command completes because administrator privilege is no longer required.
Note: As a best practice, you should always use the lowest privilege that can accomplish a task.
Set up hardware to display output
To set up the hardware to display output from the Hello World sample, follow these steps.
- Connect the RxD wire of USB-Serial Adapter to J11 pin 1 (IO0_TXD)
- Connect the GND wire of USB-Serial Adapter to J11 pin 3 (GND)
- Attach the USB-Serial Adapter to a USB port on your PC.
- Determine which COM port the adapter uses on your PC.
- Start Device Manager.
- Select View>Devices by container,
- Look for your adapter and note the number of the assigned COM port.
- On the PC, start the terminal emulator and open a serial terminal with the following settings: 115200-8-N-1 and the COM port assigned to your adapter .
Build and deploy the real-time capable application
- Start Visual Studio. From the File menu, select Open>CMake... and navigate to the folder that contains the sample.
- Select the file CMakeLists.txt and then click Open
- From the CMake menu (if present), select Build All. If the menu is not present, open Solution Explorer, right-click the CMakeLists.txt file, and select Build. This step automatically performs the manual packaging steps. The output location of the Azure Sphere application appears in the Output window.
- From the Select Startup Item menu, on the tool bar, select GDB Debugger (RTCore).
- Press F5 to start the application with debugging.
Build and deploy the high level application
- Start another instance of Visual Studio.
- Open Project/Solution and navigate to the folder that contains the sample (../AvnetStarterKitOLED)
- Select AvnetStarterKitOLED.sln and click Open
- From the Build menu select Build Solution
- Press F5 to start the application with debugging.
The high-level application output will be displayed in the Output window in Visual Studio.
Remote debugging from host 192.168.35.1
High-level intercore application.
Sends data to, and receives data from the real-time core.
Sending: Read-ADC-0
Received 4 bytes: Light intensity: 316.171539 Lux
Sending: Read-ADC-1
Received 4 bytes: Light intensity: 313.829498 Lux
Sending: Read-ADC-2
The real-time core application output will be sent to the serial terminal for display.
IntercoreCommsADC_RTApp_MT3620_BareMetal
App built on: Jun 7 2019, 17:33:13
Received message of 30bytes:
Component Id (16 bytes): 685f13af-25a5-40b2-8dd8-8cbc253ecbd8
Reserved (4 bytes): 00280003
Payload (10 bytes as hex): 52:65:61:64:2d:41:44:43:2d:30
Payload (10 bytes as text): Read-ADC-0
ADC channel 0: 0.149 V
Received message of 30bytes:
Component Id (16 bytes): 685f13af-25a5-40b2-8dd8-8cbc253ecbd8
Reserved (4 bytes): 00000032
Payload (10 bytes as hex): 52:65:61:64:2d:41:44:43:2d:31
Payload (10 bytes as text): Read-ADC-1
ADC channel 0: 0.151 V
Received message of 30bytes:
Component Id (16 bytes): 685f13af-25a5-40b2-8dd8-8cbc253ecbd8
Reserved (4 bytes): 00000032
Payload (10 bytes as hex): 52:65:61:64:2d:41:44:43:2d:32
Payload (10 bytes as text): Read-ADC-2
ADC channel 0: 0.148 V
For details on license, see LICENSE.txt in this directory.
This project has adopted the Microsoft Open Source Code of Conduct.