Adafruit Nexopixel Library not working...

Working libraries, libraries being ported and related hardware
Post Reply
User avatar
Mangy_Dog
Posts: 99
Joined: Sat May 02, 2020 11:45 pm
Answers: 1

Adafruit Nexopixel Library not working...

Post by Mangy_Dog »

Hi @fpiSTM has said in other threads this lirbary has been forked/ported to stm32core.
But im having a real hard time getting it to work.
Basically my led strip is only showing white. (full RGB)
Whats interesting. if I set the leds less than my strip length, it only lights that number of leds. So some data at least the reset bit is getting across.
Just not the RGB...

Ive ran out of ideas has anyone else got any ideas what to check?

Running on STM32F030, 3.3V powered to the STM32, The strip 5V powered with a shared ground. Power supply is stable and clean.
Just a dogs body developer, mostly making props and stuff...
User avatar
Mangy_Dog
Posts: 99
Joined: Sat May 02, 2020 11:45 pm
Answers: 1

Re: Adafruit Nexopixel Library not working...

Post by Mangy_Dog »

2 things. Firstly im not convinced my mcu is running full speed. Even though I have this in my generic_clock.c

Code: Select all

void SystemClock_Config(void)
{
  RCC_OscInitTypeDef RCC_OscInitStruct = {0};
  RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
  RCC_PeriphCLKInitTypeDef PeriphClkInit = {0};

  /** Configure LSE Drive Capability
  */
  HAL_PWR_EnableBkUpAccess();
  __HAL_RCC_LSEDRIVE_CONFIG(RCC_LSEDRIVE_HIGH);

  /** Initializes the RCC Oscillators according to the specified parameters
  * in the RCC_OscInitTypeDef structure.
  */
  RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE|RCC_OSCILLATORTYPE_LSE;
  RCC_OscInitStruct.HSEState = RCC_HSE_ON;
  RCC_OscInitStruct.LSEState = RCC_LSE_ON;
  RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
  RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
  RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL6;
  RCC_OscInitStruct.PLL.PREDIV = RCC_PREDIV_DIV1;
  if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
  {
    Error_Handler();
  }

  /** Initializes the CPU, AHB and APB buses clocks
  */
  RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
                              |RCC_CLOCKTYPE_PCLK1;
  RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
  RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
  RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;

  if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1) != HAL_OK)
  {
    Error_Handler();
  }
  PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_RTC;
  PeriphClkInit.RTCClockSelection = RCC_RTCCLKSOURCE_LSE;
  if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK)
  {
    Error_Handler();
  }
  HAL_RCC_MCOConfig(RCC_MCO, RCC_MCO1SOURCE_PLLCLK, RCC_MCODIV_1);
}
I also discovered a mistake in the adafruit library.
It uses these div calcs for the timings...

Code: Select all

uint32_t top = (F_CPU / 800000);       // 1.25µs
uint32_t t0 = top - (F_CPU / 2500000); // 0.4µs
uint32_t t1 = top - (F_CPU / 1250000); // 0.8µs
Assuming the 8mhz base clock of the crystal hsi/hse before pll. The deviders wont give the desired nanoseconds...
I tried changing it to

Code: Select all

uint32_t top = (F_CPU / 6400000);       	// 1.25µs
uint32_t t0 = top - (F_CPU / 20000000); 	// 0.4µs
uint32_t t1 = top - (F_CPU / 10000000); 	// 0.8µs
But still no luck. Which is whats leading me to think my MCU might not be running at 48mhz.
Im also looking at the signal on the oscilloscope, its only reaching 282Khz after my timing change. Its slower on the original dividers.
Nowhere near 800khz.
Which might explain why im getting just white.

How do I configure PA8 to output the MCO so I can check?
Just a dogs body developer, mostly making props and stuff...
Post Reply

Return to “Libraries & Hardware”