Configuring AD4130 through SPI on nRF52dk (nrf52832)

Hello,

I am working on setting up the nrf52 (nrf52832) to communicated with the AD4130 from Analog Devices via the SPI Port. However, I am encountering a problem that I have not been able to solve. Below I have included my overlay file and the error that I am getting -- My code is essentially following the example in the dev academy tutorials but to much lower success.

Overlay section:

&spi1 {
              compatible = "nordic,nrf-spi";
              status = "okay";
              pinctrl-0 = <&spi1_default>;
              pinctrl-1 = <&spi1_sleep>;
              pinctrl-names = "default", "sleep";
              cs-gpios = <&gpio0 25 GPIO_ACTIVE_LOW>;

              ad4130: ad4130@0 {
                        compatible = "spi-device";
                        reg = <0>;
                        spi-max-frequency = <5000000>;
                        label = "ad4130";
        };
};
Lines with problem in c file:
#define SPIOP SPI_WORD_SET(8) | SPI_TRANSFER_MSB | SPI_MODE_CPOL | SPI_MODE_CPHA
struct spi_dt_spec spispec = SPI_DT_SPEC_GET(DT_NODELABEL(ad4130), SPIOP, 0);
error message: identifier "DT_N_S_soc_S_spi_40004000_S_ad4130_0_P_spi_max_frequency" is undefined
Thank you for your help!
Parents
  • Note 5000000 is not a frequency supported by the nRF52832 SPIM, it will default to 4Mbps:

    K125  0x02000000 125 kbps
    K250  0x04000000 250 kbps
    K500  0x08000000 500 kbps
    M1     0x10000000 1 Mbps
    M2     0x20000000 2 Mbps
    M4     0x40000000 4 Mbps
    M8     0x80000000 8 Mbps

    If anyone happens to know where the translation is done from spi-max-frequency to SPIM1->FREQUENCY if would be most helpful as I am currently searching ..

  • The translation is exactly where you would expect it: In zephyr/drivers/spi/spi_nrfx_spim.c source file.

    The code would select the correct frequency code (4 MHz here).

    The "undefined" label makes me think something is off in the dts, look at the combined (resulting) dts in build/zephyr. It may not have pulled in your overlay properly.

Reply Children
No Data
Related