Skip to content

Azure Sphere Starter Kit "advanced tutorial" - OLED display + Elevation + M4 + ADC sampling of Ambient Light Sensor

Notifications You must be signed in to change notification settings

CloudConnectKits/Azure_Sphere_SK_ADC_RTApp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Azure Sphere Starter Kit Advanced Tutorial

The A7 and M4 applications here are based on C code from various sources:

  1. Avnet's Starter Kit Out-of-Box demo code
  2. Microsoft's "Inter-core Communication ADC" sample code
  3. 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

Prerequisites

  1. Avnet Azure Sphere MT3620 Starter Kit.
  2. 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.
  3. A terminal emulator (such as Telnet or PuTTY) to display the output.

To build and run the sample

Prep your device

  1. Ensure that your Azure Sphere device is connected to your PC, and your PC is connected to the internet.

  2. 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.

  3. Right-click the Azure Sphere Developer Command Prompt shortcut and select More>Run as administrator.

  4. 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.

  5. 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.

  1. Connect the RxD wire of USB-Serial Adapter to J11 pin 1 (IO0_TXD)
  2. Connect the GND wire of USB-Serial Adapter to J11 pin 3 (GND)
  3. Attach the USB-Serial Adapter to a USB port on your PC.
  4. Determine which COM port the adapter uses on your PC.
    1. Start Device Manager.
    2. Select View>Devices by container,
    3. Look for your adapter and note the number of the assigned COM port.
  5. 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

  1. Start Visual Studio. From the File menu, select Open>CMake... and navigate to the folder that contains the sample.
  2. Select the file CMakeLists.txt and then click Open
  3. 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.
  4. From the Select Startup Item menu, on the tool bar, select GDB Debugger (RTCore).
  5. Press F5 to start the application with debugging.

Build and deploy the high level application

  1. Start another instance of Visual Studio.
  2. Open Project/Solution and navigate to the folder that contains the sample (../AvnetStarterKitOLED)
  3. Select AvnetStarterKitOLED.sln and click Open
  4. From the Build menu select Build Solution
  5. 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

License

For details on license, see LICENSE.txt in this directory.

Code of Conduct

This project has adopted the Microsoft Open Source Code of Conduct.

About

Azure Sphere Starter Kit "advanced tutorial" - OLED display + Elevation + M4 + ADC sampling of Ambient Light Sensor

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published