Intel® System Studio for Microcontrollers includes multiple sample applications to help you get up to speed with its basic functionality and become familiar with the Intel® Quark™ Microcontroller Software Interface (Intel® QMSI). This sample application reads and outputs accelerometer data to the serial port.
Requirements
- Ensure you have completed the Getting Started instructions prior to following this tutorial
- Intel® Quark™ SE Microcontroller C1000 developer board and USB cable
Instructions
-
Connect the USB cable to the developer board and the host PC:
Note: This is the USB port that is connected to the FTDI chip
- Launch the Intel ® System Studio for Microcontrollers IDE.
-
Create a project with the "Accelerometer" sample project file:
- From the File menu, select New, and then select Intel Project for Microcontrollers.
-
Follow the “Create a new Project” screens
- Developer board: Intel® Quark™ SE C1000 Developer Board
- Project type: Intel® QMSI (1.1)
- Core: Sensor Subsystem
- Project name: Accelerometer found in the Developer Board Sensors folder
-
Click Finish.
Note: The Accelerometer sample application runs on the Sensor Subsystem core, which doesn’t support the IPP library. Therefore it is not possible to build this sample application using the IPP library.
-
Configure the Serial Terminal window to see the sensor output. This window will display your accelerometer sensor’s data via the UART interface over the serial cable.
-
On the bottom right-hand of the screen select the Serial Terminal pane and click on the plus sign + icon to open a new serial terminal connection:
-
Ensure the correct serial port is selected; the Custom configuration menu can also be clicked to modify the default serial connection settings:
Tip: The port will vary depending on the serial hardware used, and there may be more than one listed. There are a few ways to check your port:
- Linux*: Use the ‘dmesg’ command to view your port status.
-
Windows*: Open Device Manager to view the Ports (COM & LPT) status.
With either of these options, you can unplug the USB cable from your PC and reconnect it to see which COM port appears for the board.
-
Click OK and the connection to the Serial Terminal will be made. You should see status “Connected” in the serial console.
Note: If you close the Serial Terminal window, you can open it again from:
Window › Show View › Other › Intel ISSM › Serial Terminal
-
-
Build and deploy your project.
- Select the "Accelerometer" project in the Project Explorer.
- Click the Build button to compile the project.
-
From the Run drop-down list, select "Accelerometer (flashing)".
Note: you can also deploy and debug. From the Debug drop-down list, select "Accelerometer (flashing)". -
You can now view X, Y, and Z values from the accelerometer in the Serial Terminal window.
How it Works
The accelerometer sample uses the on-board Bosch BMC160 accelerometer connected to the microcontroller using the I2C interface, and the RTC (real time clock) integrated in the Intel® Quark™ microcontroller. It also uses integrated UART module for the data output over serial port.
The sample begins in the main function with setting up RTC parameters in an rtc configuration structure:
This configuration enables the RTC alarm, and sets accel_callback as the callback function for the RTC alarm. It is used to periodically print accelerometer data.
Next the code requests an interrupt for the RTC by using a QMSI API call, and also enables the RTC clock:
After that it configures the accelerometer parameters depending on the accelerometer type (BMC150 or BMI160):
Next the RTC configuration is set up, thus enabling the RTC alarm:
A while loop is used to wait for the defined number of samples from the accelerometer to be read and printed to the serial console output:
Each time the 125 millisecond interval is reached and the RTC alarm is triggered, the following accel_callback function is invoked. The accel data structure defined at the start of the function is passed into the bmx1xx_read_accel function which populates it with the current accelerometer data read. If this read is successful the accelerometer data is printed to the serial console output, otherwise an error message is printed.
The callback function checks if the defined number of samples have been read, if not the RTC alarm is reset and the count is incremented, otherwise the complete variable is set to true.
Note that the application by default reads 500 samples (NUM_SAMPLES) before exiting.
Finally when the complete variable is set to true, the while loop exits and the applications prints a final statement to the serial console output and exits.