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

NRF52810 SPI PSEL pins wont set & infinite loop

Currently blocked by this issue.

// CFG_PIN_GLUE_DAT = 5

// CFG_PIN_GLUE_CLK = 6

NRF_GPIO->PIN_CNF[CFG_PIN_GLUE_DAT] = pinDisconnectInputBuffer | (GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos);
NRF_GPIO->PIN_CNF[CFG_PIN_GLUE_CLK] = (GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos);

NRF_SPI0->PSEL.SCK = CFG_PIN_GLUE_CLK;
NRF_SPI0->PSEL.MOSI = CFG_PIN_GLUE_DAT;
NRF_SPI0->PSEL.MISO = SPI_PSEL_MOSI_CONNECT_Disconnected << SPI_PSEL_MOSI_CONNECT_Pos; // unused

// WARN - pins appear not be set, see screenshot! Huh?!?

NRF_SPIM0->ENABLE = SPIM_ENABLE_ENABLE_Enabled << SPIM_ENABLE_ENABLE_Pos;

NRF_SPI0->TXD = 15;

while (!NRF_SPI0->EVENTS_READY) {}  // STUCK HERE. Does writing to TXD auto trigger a send?
NRF_SPI0->EVENTS_READY = 0;

Parents Reply
  • Further investigation. The EVENT_READY is most likely set by interrupt, which I wasn't using. I've therefore set this with an inner loop.

    inline void GLUE_Start (void) {
    
      NVIC_SetPriority(SPIM0_SPIS0_SPI0_IRQn, 4);
      NVIC_EnableIRQ(SPIM0_SPIS0_SPI0_IRQn);
      __enable_irq(); // TODO: maybe not required
      NRF_SPIM0->ENABLE = SPIM_ENABLE_ENABLE_Enabled << SPIM_ENABLE_ENABLE_Pos;
    }
    
    void SPIM0_SPIS0_SPI0_IRQHandler (void) {
    
      waiton = 0;
      NRF_SPI0->EVENTS_READY = 0;
    }
    
    static void sendWait (uint8_t payload) {
    
      waiton = 1;
      NRF_SPI0->TXD = payload;
      while (waiton) {
        __WFE();
      }
    }
    


    Unfortunately the behaviour is the same, the interrupt isn't called. All this is pre-softdevice.




Children
Related