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 ..

  • I switched the frequency in my overlay to 4000000 to be in line with he default and this is the result in the zephyr.dts although it is still giving me that "frequency undefined" error when I build:

    spi1: spi@40004000 {
         compatible = "nordic,nrf-spi";
         #address-cells = < 0x1 >;
         #size-cells = < 0x0 >;
         reg = < 0x40004000 0x1000 >;
         interrupts = < 0x4 0x1 >;
         max-frequency = < 0x7a1200 >;
         easydma-maxcnt-bits = < 0x8 >;
         status = "okay";
         pinctrl-0 = < &spi1_default >;
         pinctrl-1 = < &spi1_sleep >;
         pinctrl-names = "default", "sleep";
         cs-gpios = < &gpio0 0x19 0x1 >;
         ad4130: ad4130@0 {
            compatible = "spi-device";
            reg = < 0x0 >;
            spi-max-frequency = < 0x3d0900 >;
            label = "ad4130";
          };
    };
Reply
  • I switched the frequency in my overlay to 4000000 to be in line with he default and this is the result in the zephyr.dts although it is still giving me that "frequency undefined" error when I build:

    spi1: spi@40004000 {
         compatible = "nordic,nrf-spi";
         #address-cells = < 0x1 >;
         #size-cells = < 0x0 >;
         reg = < 0x40004000 0x1000 >;
         interrupts = < 0x4 0x1 >;
         max-frequency = < 0x7a1200 >;
         easydma-maxcnt-bits = < 0x8 >;
         status = "okay";
         pinctrl-0 = < &spi1_default >;
         pinctrl-1 = < &spi1_sleep >;
         pinctrl-names = "default", "sleep";
         cs-gpios = < &gpio0 0x19 0x1 >;
         ad4130: ad4130@0 {
            compatible = "spi-device";
            reg = < 0x0 >;
            spi-max-frequency = < 0x3d0900 >;
            label = "ad4130";
          };
    };
Children
No Data
Related