This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

nrf52 Preview DK SPI Master - No Slave Select Toggle

Hi All,

I'm working with the NRF52 Preview DK, with SDK V 0.92.

I've been looking at and tweaking the SPI_Master tutorial found under /examples/peripheral/spi_master/ while following the documentation for the SPI Hardware Drivers found here:

So far, I've been able to successfully write data out on the MOSI pin of the SPI1 peripheral, verified using a saleae logic analyzer. However, I've had to change the trigger settings because the slave select pin does not seem to be toggling low to initialize the transaction. (see attached screen capture).

image description

I've tried overriding the default NRF_DRV_SPI_DEFAULT_CONFIG() value for ss_pin with the SPIM1_SS_PIN found in the pca13006.h file like so, but still no luck.

	// 2) Configure and Initialize the instance 
nrf_drv_spi_config_t config = NRF_DRV_SPI_DEFAULT_CONFIG(1);
config.frequency 						= NRF_DRV_SPI_FREQ_1M;						
config.mode 								=	NRF_DRV_SPI_MODE_3;							
config.bit_order						= NRF_DRV_SPI_BIT_ORDER_LSB_FIRST; 
config.ss_pin								= SPIM1_SS_PIN;

Any other ideas on how I can "enable" the slave select of the SPI1 peripheral?

I've attached my entire main code at the bottom of this post

Thanks!

int main(void){

uint32_t err_code;
const uint8_t *tx_buf="Helloooo";
uint8_t tx_buf_len=9;
uint8_t *rx_buf="World";
uint8_t rx_buf_len=6;

SEGGER_RTT_printf(0, "Hello World! Let's Initialize the SPI1 Peripheral as master\n");

// 1) Create an SPI master driver instance to control SPI1 peripheral
static const nrf_drv_spi_t m_spi_master_1 = NRF_DRV_SPI_INSTANCE(1);

// 2) Configure and Initialize the instance 
nrf_drv_spi_config_t config = NRF_DRV_SPI_DEFAULT_CONFIG(1);
config.frequency 						= NRF_DRV_SPI_FREQ_1M;						
config.mode 								=	NRF_DRV_SPI_MODE_3;							
config.bit_order						= NRF_DRV_SPI_BIT_ORDER_LSB_FIRST; 
config.ss_pin								= SPIM1_SS_PIN;
	
err_code = nrf_drv_spi_init(&m_spi_master_1, &config, NULL);	// NULL event handler = blocking mode

if (err_code != NRF_SUCCESS){
		SEGGER_RTT_printf(0, "Could not properly run nrf_drv_spi_init() to initialize SPI Peripheral\n");
		return -1;
}

// Send data continuously in infinite loop
for(;;){
	err_code = nrf_drv_spi_transfer(&m_spi_master_1, tx_buf, tx_buf_len, rx_buf, rx_buf_len);
	nrf_delay_ms(100);
}

// Uninitialize the SPI Master Driver instance
nrf_drv_spi_uninit(&m_spi_master_1);

return 0;

}

Related