SPI Not Working on MDBT Dev Kit

Hi there,

I am using MDBT dev kit based on MDBT53-1M module. I have a simple application of reading an SD card and printing the data on the LOG. While the current application runs perfectly on the nRF5340 dev kit, MDBT dev kit is refusing to let the SPI module run. 

nRF Connect SDK version 3.00
Toolchain version 3.00

prj.conf:

#
# Copyright (c) 2018 Nordic Semiconductor
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#


CONFIG_SERIAL=y
CONFIG_UART_ASYNC_API=y

CONFIG_PRINTK=y
CONFIG_PWM=y
CONFIG_FAULT_DUMP=2

CONFIG_SERIAL=y

CONFIG_UART_ASYNC_API=y
CONFIG_SPI=y

CONFIG_GPIO=y

CONFIG_LOG=y
CONFIG_LOG_DEFAULT_LEVEL=1
CONFIG_LOG_BUFFER_SIZE=8192
CONFIG_LOG_BACKEND_FORMAT_TIMESTAMP=n

# Debugging Needs for the Application

CONFIG_ASSERT=y
CONFIG_DEBUG=y
CONFIG_DEBUG_INFO=y
CONFIG_FAULT_DUMP=2

# Thread Stack Tracking
CONFIG_INIT_STACKS=y
CONFIG_THREAD_STACK_INFO=y

# Related to Sending the Data to Console

CONFIG_RING_BUFFER=y

# About both threads distributing their time

CONFIG_TIMESLICING=y

# UART Asynchronous API aand data sending

CONFIG_UART_ASYNC_API=y

# Configuration options for SD Card and the drive access

#Allows printing floating-points (used to print voltage)
CONFIG_CBPRINTF_FP_SUPPORT=y

#System will reset upon reaching a fatal error, disabled to allow for debugging
CONFIG_RESET_ON_FATAL_ERROR=n

CONFIG_DISK_ACCESS=y
CONFIG_DISK_DRIVERS=y
CONFIG_FAT_FILESYSTEM_ELM=y
CONFIG_FILE_SYSTEM=y

CONFIG_DISK_DRIVER_SDMMC=y
CONFIG_MAIN_STACK_SIZE=2048

# regarding Power Setup


# FIFO operation in Zephyr

CONFIG_DATA_FIFO=y

# FIle name operations in Zephyr

CONFIG_FS_FATFS_LFN=y
CONFIG_FS_FATFS_MAX_LFN=255

overlay:

&clock {	
	status = "okay";
	hfclkaudio-frequency = <11289600>;
};

&gpio_fwd {
    status = "disabled";    
};

&gpio0 {
    status = "okay";
};

&gpio1 {
    status = "okay";
};


&spi1 {
    compatible = "nordic,nrf-spim";
	status = "okay";
	pinctrl-0 = <&spi1_default>;
	pinctrl-1 = <&spi1_sleep>;
	pinctrl-names = "default", "sleep";
	cs-gpios = <&gpio0 7 GPIO_ACTIVE_LOW>; //CS for SD	

    sdhc0: sdhc@0 {
        compatible = "zephyr,sdhc-spi-slot";
        reg = <0>;
        status = "okay";
        label = "SDHC0";
        
		spi-max-frequency = <400000>;
		mmc {
			compatible = "zephyr,sdmmc-disk";
			status = "okay";			
			disk-name = "SD";
		};
    };
};

&pinctrl {
	spi1_default: spi1_default {		
		group1 {
			psels = <NRF_PSEL(SPIM_SCK, 1, 0)>,
					<NRF_PSEL(SPIM_MOSI, 1, 1)>,
					<NRF_PSEL(SPIM_MISO, 0, 10)>;  					
			
		};
	};

	spi1_sleep: spi1_sleep {
		group1 {			
					psels = <NRF_PSEL(SPIM_SCK, 1, 0)>,
						<NRF_PSEL(SPIM_MOSI, 1, 1)>,
						<NRF_PSEL(SPIM_MISO, 0, 10)>;
				// psels = <NRF_PSEL(SPIM_SCK, 0, 14)>, // 26 on MDBT dev kit
				// 	<NRF_PSEL(SPIM_MOSI, 0, 17)>,  // 27 on MDBT dev kit
				// 	<NRF_PSEL(SPIM_MISO, 0, 10)>;  					
				low-power-enable;
		};
	};
};

&uart1{
	status="disabled";
};

&i2c1{
	status="disabled";
};

Pin assignment for CS is 0.07. 

The application is too big to be pasted here. But I believe it is an issue with the overlay and prj.conf files. 

Here is the trace from logic analyzer:

As you can see, there is no activity on SCK and MOSI. Strangely CS oscillates. 

Any pointers on what configuration settings I may be missing?

Update: The log results from printing the returning state after trying to initialize the SPI module and the SD card are as follows:

*** Booting nRF Connect SDK v3.0.0-3bfc46578e42 ***<\r><\n>
*** Using Zephyr OS v4.0.99-3e0ce7636fa6 ***<\r><\n>
[00014093] <27>[0m<inf> Main: Starting main thread<27>[0m<\r><\n>
[00014096] <27>[0m<inf> Main: Set up LED on gpio@842500 pin 28<27>[0m<\r><\n>
[00014096] <27>[0m<inf> SDCard: Initializing SPI device...<\n><27>[0m<\r><\n>
[00014096] <27>[0m<inf> SDCard: SPI initialization successful!<27>[0m<\r><\n>
[00020921] <27>[1;31m<err> sd: Card error on CMD0<27>[0m<\r><\n>
disk_access_init failed. Error code: -116 ()<\r><\n>
[00027629] <27>[1;31m<err> SDCard: Failed to initialize SD card<\n><27>[0m<\r><\n>
[00027630] <27>[1;31m<err> Main: Failed to initialize SPI<27>[0m<\r><\n>

Parents
  • Hi, and thanks for the patience during this Easter period. 

    Have you gotten the right boardfiles for this MDBT dev kit? Or is this overlay file maybe what has been given to play that role, and you are otherwise just building for nRF5340 as the main buildtarget? That can also work. 

    Are you getting other samples to work on this board? Is it just this application that fails?

    Regards,

    Elfving

  • No worries. I appreciate your response. 

    I was able to make it all work. It must have been a combination of the following few things I tried:

    • I needed to provide 5V to the adapter instead of 3.3V
    • Making sure the physical connections were correctly capturing everything. A number of times I realized that the channels being captured in my cheap logic analyzer were not the ones I had chosen. 
    • Turning off all the unnecessary modules: QSPI, SPI4, SPI3 

    But, yeah, I got it to work!

Reply
  • No worries. I appreciate your response. 

    I was able to make it all work. It must have been a combination of the following few things I tried:

    • I needed to provide 5V to the adapter instead of 3.3V
    • Making sure the physical connections were correctly capturing everything. A number of times I realized that the channels being captured in my cheap logic analyzer were not the ones I had chosen. 
    • Turning off all the unnecessary modules: QSPI, SPI4, SPI3 

    But, yeah, I got it to work!

Children
Related