nRF5340 incorrect SPI read

I'm trying to interface the MAX30001 ECG and bioimpedance sensor with nrf5340 using Zephyr OS.

SPI write seems to work fine (not verified yet), but read definitively returns incorrect values.

For comparison, here's how SPI read looks like using the Maxim development kit and their software to read the MAX30001 sensor. It returns the expected value of 0x040027.

This is how SPI read of the same register with the same value looks when using Zephyr and nRF5340. It results in 0x000018, which is not correct.

Some differences are marked with red circles. It seems like the MISO pin rises, but then falls down quicker than expected; if there is just one 1 bit followed by one or more 0 bits then it rises juts for a few ns.

Another difference is that with the Maxim devkit the MISO and MOSI pins seem to be high by default, but with Zephyr low by default. For reference, here's my board overlay fie:

&pinctrl {
    spi_didzis_max30001: spi2_default_alt {
       group1 {
          psels = <NRF_PSEL(SPIM_MOSI, 0, 11)>,
                  <NRF_PSEL(SPIM_MISO, 0, 12)>,
                  <NRF_PSEL(SPIM_SCK, 0, 10)>;
       };
    };
 };
 
&spi2 {
    compatible = "nordic,nrf-spim";
    status = "okay";
        clock-frequency = <125000>;
        cs-gpios = <&gpio0 8 GPIO_ACTIVE_LOW>;
        pinctrl-0 = <&spi_didzis_max30001>;

    max30001: max30001@0 {
        compatible = "maxim,max30001";
        spi-max-frequency = <125000>;
        reg = <0>;
        status = "okay";
        label = "MAX30001";
    };
};
Parents Reply Children
Related