ADXL345 on Creality V4.2.2 Board (STM32F103 MCU)

Hello,

I’m having troubles trying to use the pins of LCD connector on a Creality 4.2.2 Board (Ender 3 V2), which in Klipper config is not used as the screen is not supported.

I want to take advantage of the exposed SPI2 Bus pins of STM32F103 and connect a ADXL345 to MCU board for input shaper (i know that i could use RPi directly, but i’m using OPi, so no compatibility with RPi pinout).

I configured printer.cfg to use SPI2 and connected pins into the ADXL345 accordingly (PB13 → SCLK, PB14 → MISO, PB15 → MOSI). Problem occurs when tried to set cs_pin: PB12, as klipper throws error mcu ‘mcu’: Unable to extract params from: config_spi

I tried with another unused pins and same error. Tried to use cs_pin: None, which starts klipper without issue but when i send ACCELEROMETER_QUERY command, i received i receive Invalid adxl345 id (got 0 vs e5).

I also tried to set PB12 as initial pin in firmware menuconfig but nothing. And finally to be sure it is not the module, i connected it to an arduino mega and compiled a program which shows it works without problems. Furthermore i tested the jumper cables with a multimeter, measured 5V in module and nothing. The only thing i can’t test is SPI data line signal (no oscilloscope).

I’ll appreciate some guidance in finding the issue. Attached klippy.log

klippy.log (27.4 KB)

Can’t really offer any advice, since I do not own the board. Just two things I find noteworthy:

  • Do not use the mcu pin prefix, since it is on the mcu anyway. And if, it would be mcu:pin without blank
  • Your config from the firmware build shows CONFIG_INITIAL_PINS="PB12", so this pin looks like reserved already. Did you compile it with CAN enabled?

Thanks for replying,

  • I’ll remove the mcu:pin prefix as it’s not required in my case.
  • I set this as a test, honestly not aware of how it really work, but without it i have same result. I compiled with USB as Communication Interface, so no CAN set in menuconfig.

Sorry, my bad. I fixed the issue.

had not changed the name of firmware.bin as klipper instructions says.

In addition, i’ve clean the makeconfig, configured again but this time with USART enabled (i’m connected through USB port, but i found in reddit that still needs to be set with serial).

Resuming:

  • Microcontroller Architecture (STMicroelectronics STM32)
  • Processor Model (STM32F103)
  • Bootloader Offset (28 KiB Bootloader)
  • Communication Interface (Serial (on USART1 PA10/PA9))

Then in Klipper:

[adxl345]
cs_pin: PB12
spi_speed: 5000000
spi_bus: spi2