W25Q16JVSSIQ flash power down

Good day

I am trying to send the flash to power down mode by shifting an instruction code.  The flash is located on spi.  I have found a method to send instruction code in spi_nor.c located in the zephyr drivers.  However, I am struggling to reference this in my project.  I have added 

CONFIG_SPI_NOR=y to my config file and added   "zephyr\drivers\flash\spi_nor.h" to my main.c file but the project doesn't include the functions used in spi_nor.c.  Is there something I need to do to include these functions.
Thank you in advance.
Kind regards,
Hassan
  • My intention is to send the flash to DPD mode.  My board file includes this:

    &spi3 {
        compatible = "nordic,nrf-spim";
        status = "okay";
        cs-gpios = <&gpio0 7 GPIO_ACTIVE_LOW>;
        pinctrl-0 = <&spi3_default>;
        pinctrl-1 = <&spi3_sleep>;
        pinctrl-names = "default", "sleep";
        w25q32jv: w25q32jv@0 {
            compatible = "jedec,spi-nor";
            reg = <0>;
            spi-max-frequency = <40000000>;
            wp-gpios = <&gpio0 8 GPIO_ACTIVE_LOW>;
            hold-gpios = <&gpio0 10 GPIO_ACTIVE_LOW>;
            size = <0x2000000>;
            has-dpd;
            t-enter-dpd = <3000>;
            t-exit-dpd = <30000>;
            jedec-id = [ ef 40 15 ];
        };
    };
    and my overlay file contains this:
    / {
        chosen {
            nordic,pm-ext-flash = &w25q32jv;
           
           
        };
       
    };
    my prj file contains this:
    CONFIG_PM_DEVICE=y
    By doing some research i've learnt that the device should enter dpd mode if I use
    pm_device_action_run(F_dev, PM_DEVICE_ACTION_SUSPEND); 
    where F_dev is the flash in question.  Im wondering if this is the right way to do it as i'm not seeing anything in the logs at the moment.
  • I've also tried to send the chip to deep power down mode manually by sending one byte of instruction code.

    static int spi_deep_power_down(const struct device *const dev,
                                   uint8_t opcode, unsigned int access)
    {
        const struct spi_nor_config *const driver_cfg = dev->config;
        struct spi_nor_data *const driver_data = dev->data;
        bool is_write = (access & NOR_ACCESS_WRITE) != 0U;
        uint8_t buf[1] = {0};
        buf[0] = opcode;
        const struct spi_buf tx_buf = {

            .buf = &opcode,

            .len = 1

        };

        const struct spi_buf_set tx_set = {
            .buffers = &tx_buf,
            .count = 1,
        };

        // return spi_write_dt(&F_dev, &tx_set);
        return spi_write(F_dev, &driver_cfg->spi, &tx_set);
    )
    However, ive found that when I use this function, the CS pin never goes low and therefore I cant write the device.  Please assist me in  finding a driver that will work for this if in fact it is the best way to do it.  If not, how do am I able to make the CS pin go low dynamically within the code.
    Thank you in advance.
    Kind regards,
    Hassan
  • Hello Hassan,

    Thank you for contacting DevZone at NordicSemi.

    I have added 

    CONFIG_SPI_NOR=y to my config file and added   "zephyr\drivers\flash\spi_nor.h" to my main.c file but the project doesn't include the functions used in spi_nor.c

    Is it not that you need to have device in your DTS and then you reference it using DT macros,

    and accordingly when you will use it, it (zephyr) will be using the underlying driver

    I can see you have updated your ticket with more comments. I will look at it more tomorrow.

    Regards,
    Naeem

  • Hi Naeem 

    My flash device has "has-dpd" in its configuration.  Im just wondering how to do I use it when suspending SPI 

  • You can use:

    CONFIG_SPI_NOR_IDLE_IN_DPD=y

    (make sure to check dependencies)

Related