Crazy-Geeks / STM32-ARGB-DMA

STM32 Library for Addressable LEDs: WS2812(b), WS2811, SK6812, etc. Supports RGB & RGBW LEDs.
MIT License
92 stars 25 forks source link

Incorrect signals on STM32F411 #4

Open nikitax75 opened 2 years ago

nikitax75 commented 2 years ago

Hi there,

Thanks for all the work in putting this together, very clear code & instructions. I am trying to use this lib on an STM32F411 (Nucleo STM32F411RE) and the output signal is incorrect:

image

This is the signal supposed to be sent for to clear a strip of one pixel:

ARGB_Init();  // Initialization

  ARGB_Clear(); // Clear strip
  while (ARGB_Show() != ARGB_OK); // Update - Option 1

  //ARGB_SetBrightness(100);  // Set global brightness to 40%

  //ARGB_SetRGB(2, 0, 255, 0); // Set LED №3 with 255 Green
  //while (!ARGB_Show());  // Update - Option 2

  //ARGB_SetHSV(0, 0, 255, 255); // Set LED №1 with Red
  //while (!ARGB_Ready()); // Update - Option 3
  //ARGB_Show();

  //ARGB_FillWhite(230); // Fill all white component with 230
  //while (ARGB_Ready() == ARGB_BUSY); // Update - Option 4
  //ARGB_Show();

  //ARGB_FillRGB(200, 0, 0); // Fill all the strip with Red
  //while (!ARGB_Show());

I have checked all the CubeMX configuration which is as per your instructions and really don't understand what's happening. Any idea?

For reference, here is my clock configuration:

image

Timer configuration:

image

RCC configuration:

image

Crazy-Geeks commented 2 years ago

Hello! Can you please show your settings in .h file? What connection type do you use?

nikitax75 commented 2 years ago

Hey, thanks for the reply!

Sure, settings in the header are:

/**
 *******************************************
 * @file    ARGB.h
 * @author  Dmitriy Semenov / Crazy_Geeks
 * @version 1.31
 * @date    21-November-2021
 * @brief   Header file for ARGB (Adreassable RGB)
 *******************************************
 *
 * @note Repo: https://github.com/Crazy-Geeks/STM32-ARGB-DMA
 * @note RU article: https://crazygeeks.ru/stm32-argb-lib
 */

#ifndef ARGB_H_
#define ARGB_H_

#include "libs.h"

/**
 * @addtogroup ARGB_Driver
 * @brief Addressable RGB LED Driver
 * @{
 * @addtogroup User_settings
 * @brief LED & Timer's settings
 * @{
 */

#define WS2812       ///< Family: {WS2811S, WS2811F, WS2812, SK6812}
// WS2811S — RGB, 400kHz;
// WS2811F — RGB, 800kHz;
// WS2812  — GRB, 800kHz;
// SK6812  — RGBW, 800kHz

#define NUM_PIXELS 1 ///< Pixel quantity

#define USE_GAMMA_CORRECTION 1 ///< Gamma-correction should fix red&green, try for yourself

#define TIM_NUM    2  ///< Timer number
#define TIM_CH     TIM_CHANNEL_1  ///< Timer's PWM channel
#define DMA_HANDLE hdma_tim2_ch1  ///< DMA Channel
// DMA channel can be found in main.c / tim.c

The LEDs are WS2812, connected to the F411RE nucleo board through breadboard cables. The Logic Analyzer capture above was a direct connection F411RE<->Logic Analizer to rule out any cabling issues

Crazy-Geeks commented 2 years ago

@nikitax75 Try to set NUM_PIXELS to 2 or 3 For LED connection type I meant: Logic Translator / Open Drain / Direct