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

nRF52832 + EM4325 RX problem using SPI

Hi everyone,

I am trying the following project to work with my SPI peripheral device( EM4325): nRF5_SDK_11.0.0_89a8197\examples\peripheral\spi\pca10040\arm5_no_packs

Info of the SPI peripheral is here : www.emmicroelectronic.com/.../4325-ds_0.pdf

I am using the following connections to connect the nRF52832 and EM4325:

P0.29 (CS) to Pin 6 (P3_CS)

P0.03 (SCLK) to Pin 5 (P2_SCLK)

P0.04 (MOSI) to pin 4 (P0_MOSI)

P0.28 (MISO) to pin 3 (P1_MISO)

VDD to pin 7 (VBAT)

GND to pin 8 (VSS)

I have defined the same pins in the nrf_drv_config.h

#define SPI0_ENABLED 1

#if (SPI0_ENABLED == 1)
#define SPI0_USE_EASY_DMA 1

#define SPI0_CONFIG_SCK_PIN 3
#define SPI0_CONFIG_MOSI_PIN 4
#define SPI0_CONFIG_MISO_PIN 28
#define SPI0_CONFIG_IRQ_PRIORITY    APP_IRQ_PRIORITY_LOW

This is the code which i am using :

#define TEST_STRING "Nordic"
static uint8_t       m_tx_buf[]=TEST_STRING;     /**< TX buffer. */
static uint8_t       m_rx_buf[sizeof(TEST_STRING)+1];   /**< RX buffer. */
static const uint8_t m_length = sizeof(m_tx_buf);        /**< Transfer length. */


void spi_event_handler(nrf_drv_spi_evt_t const * p_event)

{

spi_xfer_done = true;

NRF_LOG_PRINTF(" Transfer completed.\r\n");

if (m_rx_buf[0] != 0)

{
    NRF_LOG_PRINTF(" Received: %s\r\n",m_rx_buf);

}
}

int main(void)

{

APP_ERROR_CHECK(NRF_LOG_INIT());
NRF_LOG_PRINTF("SPI example\r\n");

nrf_drv_spi_config_t spi_config;
spi_config.ss_pin = SPI_CS_PIN;
spi_config.mosi_pin = SPI0_CONFIG_MOSI_PIN;
spi_config.sck_pin = SPI0_CONFIG_SCK_PIN;
spi_config.miso_pin = SPI0_CONFIG_MISO_PIN;
spi_config.frequency = NRF_DRV_SPI_FREQ_125K;      
spi_config.mode = NRF_DRV_SPI_MODE_0;               
spi_config.bit_order = NRF_DRV_SPI_BIT_ORDER_MSB_FIRST; // Matches Default.
spi_config.ss_pin = SPI_CS_PIN;
APP_ERROR_CHECK(nrf_drv_spi_init(&spi, &spi_config, spi_event_handler));

while(1)
{
    // Reset rx buffer and transfer done flag
    memset(m_rx_buf, 0, m_length);
    spi_xfer_done = false;
	
			
    APP_ERROR_CHECK(nrf_drv_spi_transfer(&spi, m_tx_buf, m_length, m_rx_buf, m_length));

    while (!spi_xfer_done)
    {
        __WFE();
    }

    LEDS_INVERT(BSP_LED_0_MASK);
    nrf_delay_ms(200);
}
}

I am not receive the transmitted packet in my receiver buffer that is m_rx_buf. I have done it for all the frequency and clock modes which are available and with EasyDMA enable and disable.

What might be the issue any suggestions will be helpfull .

This is my project file spi (3).zip

Thank you.

Parents Reply Children
Related