SPI encoder with CS_N on GPIO2 issue

Hello,

I have 2 SPI encoders connected to my ODrive v3.6. First encoder is has the CS_N on the GPIO1 and it works fine. The other one has CS_N on GPIO2, however the chip select doesn’t work. I’m aware that on the GPIO1 and 2 there is the UART_A, I disabled it. Is there anything else that could prevent the GPIO2 to work properly?

odrive config:

brake_resistance: 0.4699999988079071 (float)
dc_bus_overvoltage_ramp_end: 25.68000030517578 (float)
dc_bus_overvoltage_ramp_start: 25.68000030517578 (float)
dc_bus_overvoltage_trip_level: 25.68000030517578 (float)
dc_bus_undervoltage_trip_level: 8.0 (float)
dc_max_negative_current: -1.0 (float)
dc_max_positive_current: inf (float)
enable_brake_resistor: False (bool)
enable_can_a: True (bool)
enable_dc_bus_overvoltage_ramp: False (bool)
enable_i2c_a: False (bool)
enable_uart_a: False (bool)
enable_uart_b: False (bool)
enable_uart_c: False (bool)
error_gpio_pin: 0 (uint32)
gpio10_mode: 11 (uint8)
gpio11_mode: 2 (uint8)
gpio12_mode: 12 (uint8)
gpio13_mode: 12 (uint8)
gpio14_mode: 2 (uint8)
gpio15_mode: 7 (uint8)
gpio16_mode: 7 (uint8)
gpio1_mode: 0 (uint8)
gpio1_pwm_mapping:
  endpoint: None (object_ref)
  max: 0.0 (float)
  min: 0.0 (float)
gpio2_mode: 0 (uint8)
gpio2_pwm_mapping:
  endpoint: None (object_ref)
  max: 0.0 (float)
  min: 0.0 (float)
gpio3_analog_mapping:
  endpoint: None (object_ref)
  max: 0.0 (float)
  min: 0.0 (float)
gpio3_mode: 3 (uint8)
gpio3_pwm_mapping:
  endpoint: None (object_ref)
  max: 0.0 (float)
  min: 0.0 (float)
gpio4_analog_mapping:
  endpoint: None (object_ref)
  max: 0.0 (float)
  min: 0.0 (float)
gpio4_mode: 3 (uint8)
gpio4_pwm_mapping:
  endpoint: None (object_ref)
  max: 0.0 (float)
  min: 0.0 (float)
gpio5_mode: 3 (uint8)
gpio6_mode: 0 (uint8)
gpio7_mode: 0 (uint8)
gpio8_mode: 0 (uint8)
gpio9_mode: 11 (uint8)
max_regen_current: 1.0 (float)
uart0_protocol: 3 (uint8)
uart1_protocol: 3 (uint8)
uart2_protocol: 3 (uint8)
uart_a_baudrate: 115200 (uint32)
uart_b_baudrate: 115200 (uint32)
uart_c_baudrate: 115200 (uint32)
usb_cdc_protocol: 3 (uint8)

encoder config:

abs_spi_cs_gpio_pin: 2 (uint16)
bandwidth: 1000.0 (float)
calib_range: 0.019999999552965164 (float)
calib_scan_distance: 50.26548385620117 (float)
calib_scan_omega: 12.566370964050293 (float)
cpr: 16384 (int32)
direction: 0 (int32)
enable_phase_interpolation: True (bool)
find_idx_on_lockin_only: False (bool)
hall_polarity: 0 (uint8)
hall_polarity_calibrated: False (bool)
ignore_illegal_hall_state: False (bool)
index_offset: 0.0 (float)
mode: 257 (uint16)
phase_offset: 0 (int32)
phase_offset_float: 0.0 (float)
pre_calibrated: False (bool)
sincos_gpio_pin_cos: 4 (uint16)
sincos_gpio_pin_sin: 3 (uint16)
use_index: False (bool)
use_index_offset: True (bool)

Thanks

Hmm, what actual error are you getting?

I get the ABS_SPI_COM_FAIL. Which makes sense, as on the scope I can see the CS_N on the GPIO2 is not going low.

Interesting – can you switch that to another GPIO pin and try?

Oh yes I forgot to mention that, if I set one on GPIO1 and the other on GPIO3 it works fine

Probably some weird interplay with the UART stuff – is there an issue with using GPIO1/GPIO3 like that?

Ideally I could solve it, but I can botch the PCB to which my ODrive is interfacing. Now I have a neat direct pin header connection.

Ah, understood. Happy to check later, but yeah I’d say it’s probably not worth your time to dig into it, if you can bodge the PCB.