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
  • Hi there,

    I have just started working on Initializing MAX 30009 Bioimpedance sensor with NRF 5340. Since, there are no examples or libraries related to max 30009 sensor in any platforms it has been very difficult for me to initialize it. I tries using sensor.h API to do so but I think that doesn't work for outside sensors apart from the sensors given by nordic SDK.I saw this post and found that you have been working with max 30001, which is kind of similar to mine. It would be of great help for me if you could provide me the code for it, so I could understand it and later I could make necessary changes according to my sensor's datasheet.

Children
Related