NRF52 config SPIS by register can't work

i want config spis by register, but it can't work, when spi master send data, spis irq handler can,t enter, could you tell me what's wong happen?if i use spis library ,it works successful.

this is my code:

void nrfx_spis_1_irq_handler(void)
{

    if (NRF_SPIS1->EVENTS_ENDRX)

    {
         NRF_SPIS1->EVENTS_ENDRX = 0;
         NRF_LOG_INFO("123123");
    }
}

void spis_init(void)
{
    NRF_SPIS1->CONFIG = NRF_SPIS_BIT_ORDER_MSB_FIRST << 0 | 0 << 1 | 0 << 2;


    NRF_SPIS1->PSEL.CSN = 0x0 << 31 | AP_SPIS_CS_PIN << 0;
    NRF_SPIS1->PSEL.SCK = 0x0 << 31 | AP_SPIS_SCK_PIN << 0;
    NRF_SPIS1->PSEL.MOSI = 0x0 << 31 | AP_SPIS_MOSI_PIN << 0;
    NRF_SPIS1->PSEL.MISO = 0x0 << 31 | AP_SPIS_MISO_PIN << 0;


    nrf_gpio_cfg(AP_SPIS_CS_PIN,
                 NRF_GPIO_PIN_DIR_INPUT,
                 NRF_GPIO_PIN_INPUT_CONNECT,
                 NRF_GPIO_PIN_NOPULL,
                 NRF_GPIO_PIN_S0S1,
                 NRF_GPIO_PIN_NOSENSE);

    nrf_gpio_cfg(AP_SPIS_SCK_PIN,
                 NRF_GPIO_PIN_DIR_INPUT,
                 NRF_GPIO_PIN_INPUT_CONNECT,
                 NRF_GPIO_PIN_NOPULL,
                 NRF_GPIO_PIN_S0S1,
                 NRF_GPIO_PIN_NOSENSE);

    nrf_gpio_cfg(AP_SPIS_MOSI_PIN,
                     NRF_GPIO_PIN_DIR_INPUT,
                     NRF_GPIO_PIN_INPUT_CONNECT,
                     NRF_GPIO_PIN_NOPULL,
                     NRF_GPIO_PIN_S0S1,
                     NRF_GPIO_PIN_NOSENSE);

    nrf_gpio_cfg(AP_SPIS_MISO_PIN,
                     NRF_GPIO_PIN_DIR_INPUT,
                     NRF_GPIO_PIN_INPUT_CONNECT,
                     NRF_GPIO_PIN_NOPULL,
                     NRF_GPIO_PIN_H0H1,
                     NRF_GPIO_PIN_NOSENSE);

    NRF_SPIS1->DEF = 0x00;
    NRF_SPIS1->ORC = 0x00;

    NRF_SPIS1->EVENTS_ACQUIRED = 0;
    NRF_SPIS1->EVENTS_END = 0;
    NRF_SPIS1->EVENTS_ENDRX = 0;

    NRF_SPIS1->TXD.MAXCNT = AP_SPIS_MAX_DATA_LENGTH;
    NRF_SPIS1->TXD.PTR = (uint32_t)m_spis_tx_buf;

    NRF_SPIS1->RXD.MAXCNT = AP_SPIS_MAX_DATA_LENGTH;
    NRF_SPIS1->RXD.PTR = (uint32_t)m_spis_rx_buf;

    NRF_SPIS1->INTENSET |= 0x1 << 4 | 0x1 << 1 | 1 << 10;

    NVIC_SetPriority(SPI1_TWI1_IRQn, 1);
    NVIC_EnableIRQ(SPI1_TWI1_IRQn);

    NRF_SPIS1->ENABLE = 0x02;

}

Parents
  • Hi,

    • Have you checked the register values with a debugger, to make sure they are set to the expected values?
    • What pins are defined in 
    • It looks like you have configured the MISO pin as an input, this should be an output for SPIS.
    • SPI1_TWI1_IRQn, which you use with the NVIC functions are for nRF51, the correct for nRF52832 should be SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQn. Can you try this? You can also define the IRQ handler as: "void SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQHandler(void)" when not using the NRFX drivers.

    Best regards,
    Jørgen

  • 1、yes, i use debug mode for check my config, it's correct.

    2、i check pin defined, they are correct

    3、though i config miso as input, the master couldn't receive anything,but slave should receive master data

    4、i use SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQn and void SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQHandler(void), it can,t works

Reply Children
No Data
Related