cancel
Showing results for 
Search instead for 
Did you mean: 

STM32446RE with Stepper Motor Driver L6470 IC

JHERI
Senior

Hello

I understand the Nucleo 401 board was developed with the l6470 stepper motor driver

I have been trying to interfacel6470 it with the nucleo 446re arm, with very little joy,... actually no joy due to the very poor C code support from ST and the L6470 / nucleo, the available code is very poorly written from ST, with 100s of lines of non meaning or important code, for just simply trying to set up a single board solution of the L6470 and sending some SPI instructions to the chip

the ST C code / dspin code out there for the L6470 is so over the top complicated !! as it supports multiple nucleo boards and multiple l6470 stepper boards, and various configuration jumper settings, it is an absolute nightmare trying to hack and extract the code for a single board STM32F44RE solution with the L6470

Is there any simply code to work the L6470 in basic building blocks that can port in to my nucleo 446RE / SPI bus? or better any video tutorial on how to configure the L6470 ic

this is a simple SPI interface, just need to have a few easy to understand starter points on how to configure and use the l6470

most of whats out there is old, non HAL drivers, or for the Arduino which i'm not interested

in

why do ST not make it simple to build single board code/solutions for the many nucleo boards and add on boards

the ST C code and library codes is so over the top complicated and a maze or strange C code, it easier to start fresh and again and scrap the ST code!!! what a crazy situation

the ST IHM02A C code is hard to port and understand and only designed for a few old necleo boards 401 /302 f072 etc

ST you could have made it much more easier for designers to understand interfacing the l6740 to any micro, with some easy to understand logical C code, showing step by step configuration and operation of the L6470

But no ... just confuse the poor designer and chuck out there loads of complex non commented crappy code that no one can understand or port !!!

simply i would like some child like tutorial and video on using the l6470

just would like some simple to understand and get working C code for interfacing the L6470

any help will be very much appreciated

thank you

1 REPLY 1
Ibrahimsha
Associate II

Hey JHERI,

I understand your frustration with the complexity of integrating the L6470 stepper motor driver with the Nucleo 446RE board. It can be challenging when the provided code examples aren't straightforward. Please try this simple snippet for running a stepper with default settings.

void SPI_32Bit_Write(uint8_t command,uint32_t data)
{
uint8_t WriteData[4];

WriteData[0] = command;
WriteData[1] = (data >> 16) & 0xFF;
WriteData[2] = (data >> 😎 & 0xFF;
WriteData[3] = data & 0xFF;

HAL_GPIO_WritePin(GPIOA, CS_PIN, GPIO_PIN_RESET);
HAL_SPI_Transmit(&hspi1, &WriteData[0], 1, HAL_MAX_DELAY);
HAL_GPIO_WritePin(GPIOA, CS_PIN, GPIO_PIN_SET);

HAL_GPIO_WritePin(GPIOA, CS_PIN, GPIO_PIN_RESET);
HAL_SPI_Transmit(&hspi1, &WriteData[1], 1, HAL_MAX_DELAY);
HAL_GPIO_WritePin(GPIOA, CS_PIN, GPIO_PIN_SET);

HAL_GPIO_WritePin(GPIOA, CS_PIN, GPIO_PIN_RESET);
HAL_SPI_Transmit(&hspi1, &WriteData[2], 1, HAL_MAX_DELAY);
HAL_GPIO_WritePin(GPIOA, CS_PIN, GPIO_PIN_SET);

HAL_GPIO_WritePin(GPIOA, CS_PIN, GPIO_PIN_RESET);
HAL_SPI_Transmit(&hspi1, &WriteData[3], 1, HAL_MAX_DELAY);
HAL_GPIO_WritePin(GPIOA, CS_PIN, GPIO_PIN_SET);

}

where command - "0x50 | Direction", Data "33554", refer datasheet for speed register to set data.

Have a nice day !