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

hardware CS not working when using BLE with nRF5340DK

Hello,

I'm using NCS 1.4.99 with a nRF5340DK and want to use the hardware CS of the SPI and also use BLE.

Here is a simple code that work on a nRF5340PDK but only work on a nRF5340DK when CONFIG_BT is not defined.

/* Includes ------------------------------------------------------------------*/

#include <assert.h>
#include <stdint.h>

#include <nrfx_spim.h>

/* Private define ------------------------------------------------------------*/

#define SPI_TRANSFER_SIZE 2
#define TX_DATA 0x1234

#define SCLK_PIN NRF_GPIO_PIN_MAP(1, 5)
#define MOSI_PIN NRF_GPIO_PIN_MAP(1, 4)
#define MISO_PIN NRF_GPIO_PIN_MAP(1, 6)
#define CSN_PIN  NRF_GPIO_PIN_MAP(1, 1)

/* Private variables ---------------------------------------------------------*/

static uint8_t rx_buffer[SPI_TRANSFER_SIZE];
static uint8_t tx_buffer[SPI_TRANSFER_SIZE];

static const nrfx_spim_t spi = NRFX_SPIM_INSTANCE(4);
static const nrfx_spim_xfer_desc_t xfer = NRFX_SPIM_XFER_TRX(tx_buffer, SPI_TRANSFER_SIZE, rx_buffer, SPI_TRANSFER_SIZE);

/* Public functions ----------------------------------------------------------*/

void main(void)
{
    nrfx_err_t err_code;

    nrfx_spim_config_t spi_config = NRFX_SPIM_DEFAULT_CONFIG(
            SCLK_PIN,
            MOSI_PIN,
            MISO_PIN,
            NRFX_SPIM_PIN_NOT_USED);
    spi_config.frequency = NRF_SPIM_FREQ_8M;
    spi_config.mode = NRF_SPIM_MODE_0;

    err_code = nrfx_spim_init(&spi, &spi_config, NULL, NULL);
    assert(err_code == NRFX_SUCCESS);
    spi.p_reg->PSEL.CSN = CSN_PIN; // workaround, if set in spi_config, the CS pin is set/clear by software

    tx_buffer[0] = (TX_DATA >> 8) & 0xFF;
    tx_buffer[1] = TX_DATA & 0xFF;

    while(1) {
        nrfx_spim_xfer(&spi, &xfer, NRFX_SPIM_FLAG_NO_XFER_EVT_HANDLER);
    }
}
7077.prj.conf.

Parents Reply
  • Hi,

    Nicolas Brunner said:
    HCI RPMsg, for what function is this UART used ? Is there a documentation about it ?

    It is used for logging. It is not explicitly documented in that example, but logging is enabled by default. You can disable it by setting CONFIG_LOG=n in hci_rpmsg's prj.conf.

    Nicolas Brunner said:
    I saw that pins are configure to be used by the network core in the function remoteproc_mgr_config(). Why isn't there a way to desactivate this function with prj.conf ?

    Calling of remoteproc_mgr_config() among other things is configured via CONFIG_TRUSTED_EXECUTION_NONSECURE, but there is no way to disable configuration of just the UART pins via prj.conf out of the box. I agree that would make sense though, if you do not want UART logging from the network core.

Children
No Data
Related