CLK Amplitude Low

Hi,

I am using the nrf52dk_nrf52832 board and adding a peripheral SPI Flash. I had previously gotten the SPI Flash to work but now it does not.

I've hooked it up to the oscilloscope and determined that my CLK is likely the problem.

I can see the CS and and the MOSI line perfectly but the CLK alternates between 0 V and 1.02V which I believe is too low for the device to recognize.

I am using pin 28 as the CLK which, again, did at one point work; I have switch which pin I am using to no avail.

I have attached my overlay and my initialization functions - I am using the Zephyr drivers and attached an example command.

All help is appreciated,

Tom

void releasePowerDown(void){
	// Set up the buffers
	uint8_t tx_buffer[5];
	tx_buffer[0] = 0xab;
	for(int i = 1; i < 5; i ++){
		tx_buffer[i] = 0x00;
	}
	uint8_t rx_buffer[5];

	const struct spi_buf tx_buf = {
		.buf = tx_buffer,
		.len = sizeof(tx_buffer)
	};
	const struct spi_buf_set tx = {
		.buffers = &tx_buf,
		.count = 1
	};

	struct spi_buf rx_buf = {
		.buf = rx_buffer,
		.len = sizeof(rx_buffer),
	};
	const struct spi_buf_set rx = {
		.buffers = &rx_buf,
		.count = 1
	};
	
	int err;
	
	err = spi_transceive(spi_dev, &spi_cfg, &tx, &rx);
	if(err){
		printk("SPI transceive fail: %i. Release power down.\n", err);
	}	
	printk("Release Power Down RX recv: ");
	for(int i = 0; i < 5; i ++){
		printk("%X ", rx_buffer[i]);
	}
	printk("\r\n");
}
&spi1 {
    compatible = "nordic,nrf-spi";
    status = "okay";
    sck-pin = <28>;
    mosi-pin = <30>;
    miso-pin = <31>;
    cs-gpios = <&gpio0 29 GPIO_ACTIVE_LOW>;

    w25: w25q32@0 {
            compatible = "winbond,w25q32", "jedec,spi-nor";
            label = "W25Q32";
            reg = <0>;
            jedec-id = [ef 40 14];
            size = <0x4000000>;
            // Can be up to 45000000
            spi-max-frequency = <5000000>;
            wp-gpios = < &gpio0 4 GPIO_ACTIVE_LOW >;
            hold-gpios = < &gpio0 3 GPIO_ACTIVE_LOW >;
            // reset-gpios = < &gpio0 5 GPIO_ACTIVE_LOW >;
    };
};


&radio{
    status = "disabled";
};
&i2c0{
    status = "disabled";
};
&adc{
    status = "disabled";
};
&temp{
    status = "disabled";
};
&rng{
    status = "disabled";
};
&wdt{
    status = "disabled";
};
&spi2{
    status = "disabled";
};
&pwm0{
    status = "disabled";
};

  • The initialization function did not attach.

    Here it is.

    #define CS_PIN 29
    #define size SPI_WORD_SET(8)
    
    struct spi_cs_control cs_cfg = {
    	// delay measured in microseconds
    	.delay = .055,
    	.gpio_dt_flags = GPIO_ACTIVE_LOW,
    	.gpio_pin = CS_PIN,
    };
    struct spi_config spi_cfg = {
    	.operation = SPI_OP_MODE_MASTER | !SPI_MODE_CPOL | !SPI_MODE_CPHA | SPI_TRANSFER_MSB | 
    		size | SPI_LINES_SINGLE | SPI_FRAME_FORMAT_MOTOROLA, // | !SPI_CS_ACTIVE_HIGH,
        // Can be up to 45000000 must match devicetree
    	.frequency = 5000000,
    	.slave = 0,
    	.cs = &cs_cfg,
    };
    
    const struct device * spi_dev;
    const struct device * dev;
    
    void spi_init(void)
    {
    	const char* const spiName = "SPI_1";
    	spi_dev = device_get_binding(spiName);
    	if (spi_dev == NULL) {
    		printk("Could not get %s device\n", spiName);
    		return;
    	}
    }
    
    void cs_init(void){
    	dev = device_get_binding("GPIO_0");
    	if (!dev) {
    		printk("Device not found\n");
    		return;
    	}
    	cs_cfg.gpio_dev = dev;
    }

Related