arrow-left

All pages
gitbookPowered by GitBook
1 of 1

Loading...

DEMO: APA102 RGB LED control via UCANS32K146 with PX4-Autopilot

hashtag
Introduction

This tutorial explains how to operate 3-LED APA102 RGB board via UCANS32K146 over SPI.

hashtag
Items Needed

  • An APA102 based RGB LED board

  • UCANS32K146 or UCANS32K1SIC

  • Jumper wires

hashtag
APA102 LED Board

hashtag
Connections

The input connector of 3-LED APA102 board has 4 wired connections: SDI, CKI, PWR, GND. To connect the LED board to the UCAN board, refer the configuration of 'stemma qt / qwiic jst sh cable'. The connections would be as follows:

3-LED APA102 Board Input
Name
SPI Port (P1) Pin Number on UCAN

hashtag

hashtag
Network

All the LEDs in the board are daisy chained together. Note: These boards can also be daisy chained from one board to the next. From the software point of view these are just considered one long string of LEDs daisy chained together.

hashtag
Software Procedure

Note: You may refer the steps for building and flashing PX4 on this gitbook .

hashtag
Software Setup

Change the value of 'NUM_LEDS' in '/platforms/nuttx/NuttX/apps/examples/apa102/apa102_main.c' to the number of LEDs in your APA102 board. For our case, it will be '3'.

hashtag
Building PX4

After compilation is done, the new firmware is available under: build/nxp_ucans32k146_default/deploy/34.bin

hashtag
Flashing PX4

Flash the firmware and bootloader, if the board already doesn't have one, using 'jlink.exe'.

circle-info

You may flash the attached files (configured for a 3-LED APA102 board), to skip the above steps.

hashtag
Operating the LEDs

Connect your board and access to the terminal using MobaXterm, minicom,...

Type the following command:

STEMMA QT / Qwiic JST SH 4-pin Cable
  • Segger J-Link debugger

  • GND

    7

    Red

    PWR (5V)

    1

    Yellow

    CLK

    2

    Blue

    MOSI

    4

    link
    file-download
    22KB
    nxp_ucans32k146_canbootloader.bin
    arrow-up-right-from-squareOpen
    PX4-Autopilot Bootloader
    file-download
    582KB
    34.bin
    arrow-up-right-from-squareOpen
    PX4-Autopilot Firmware

    Black

    git clone -b UCANS32K146 https://github.com/NXPHoverGames/PX4-Autopilot.git --recursive
    cd PX4-Autopilot
    make nxp_ucans32k146_canbootloader
      // output: build/nxp_ucans32k146_canbootloader/nxp_ucans32k146_canbootloader.bin
    make nxp_ucans32k146
      // output: build/nxp_ucans32k146_default/deploy/34.bin
    connect
    // specify the following:
      // device: s32k146;
      // target interface: s (which stands for swd);
      // interface speed: 1000 khz (recommended);
    loadbin <path to nxp_ucans32k146.bin> 0x0
    loadbin <path to 34.bin> 0x6000
    // quit jlink tools by typing 'q'.
    apa102