This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

PPI to SPIM Task, How to?

Hello,

I am having much fun with nrf52. I'd like to implement SPI read (few bytes) per GPIOTE event over PPI, the source is the GPIO event and the destination task is a SPI read of few specified bytes. The event is currently generated without Interrupt, and this is preferred.

I'd like to use easyDMA on the SPIM end. I have done the easyDMA setup, the MAXCNT, PTR, LIST are all setup register writes are verified correctly.

The issue is I am still missing something, I can not stitch together in my mind the steps needed to setup a READ task for SPI without interrupts to trigger a START Task, also how it looks from PPI to easyDMA. Please help to explain. Would the p_spim->START register contains actually a pointer to a chunk of code? How to best take advantage of the sweet nRF52 features?

I have checked the path over PPI assignment and verified the external event are generated and general routing (from event to task) over PPI is working via a test GPIO output:

err_code = nrf_drv_ppi_channel_assign(ppi_channel1,
	  nrf_drv_gpiote_in_event_addr_get(trigPIN),
	  nrf_drv_gpiote_out_task_addr_get(testOutPin));
	  //nrf_drv_spi_start_task_get(&afeSpi));

Please enlight! Thanks in advance!

FI

  • Hi Ken,

    It there are way to generate event on a compare value when the timer is in counter mode? I am thinking if I could count the SCK toggles and generate event based on a set number, it would give me more knobs to turn.

  • I don't see any reason why there should not be generated a compare event in counter mode, I am though a bit unsure how it can be used in this case.

  • Ken, thanks for the response. I was out a week. Where it ended up was that, I set the timer in counter mode get counts from PIN event. But was not able to have a compare event generated from the timer in the counter mode. As you said, if it is possible, that would be great, I will get back to the code a little more and capture some code segment and maybe you can point out what I am doing wrong. Thanks again.

    FI

  • It is working now.... Hmm, I must have a double at my desk, that works when I am away. Well actually I cleaned up some conflicting calls to the timer for debugging in the main loop. It is working as how I wanted. Thanks Ken!

    FI

  • Ken, I have another strange issue today. It amounts to SPIM PPI operation is breaking something. I have a loop in main that toggles using

    nrf_drv_gpiote_out_toggle(testOutPin);
    

    and have a uart print using

    NRF_LOG_PRINTF("In the loop \r\n");
    

    As soon as the PPI channel for the SPIM is assigned, via

    nrf_drv_ppi_init();
    nrf_drv_ppi_channel_alloc(&ppi_channel1);
    nrf_drv_ppi_channel_alloc(&ppi_channel4);
    
    nrf_drv_ppi_channel_assign(ppi_channel1,
      nrf_drv_gpiote_in_event_addr_get(AFE_DRDY_PIN),
      nrf_spim_task_address_get(NRF_SPIM0, NRF_SPIM_TASK_START));
    
    nrf_drv_ppi_channel_assign(ppi_channel4,
      nrf_spim_event_address_get(NRF_SPIM0, NRF_SPIM_EVENT_ENDTX),
      nrf_spim_task_address_get(NRF_SPIM0, NRF_SPIM_TASK_STOP));
    
    nrf_drv_ppi_channel_enable(ppi_channel1);
    err_code = nrf_drv_ppi_channel_enable(ppi_channel4);
    
    NRF_LOG_PRINTF("err: %x \r\n", err_code);
    

    The toggle and Uart Print stop working. On a scope, the SPI is clocking and PPI works just fine.

    The SPI is setup as

    NRF_SPIM0->RXD.MAXCNT = 6; //AFE_STREAM_ARRAY_SIZE;
    NRF_SPIM0->RXD.PTR = (int32_t) &afeStreamArrayList;
    NRF_SPIM0->RXD.LIST = SPIM_RXD_LIST_LIST_ArrayList;
    
    NRF_SPIM0->TXD.MAXCNT = 3-1;
    NRF_SPIM0->TXD.PTR = (int32_t) bufTx;
    NRF_SPIM0->TXD.LIST = 0;
    
    //spim_xfer()with
    //nrf_drv_spi_xfer_desc_t xfer_desc;
    //xfer_desc.rx_length = 6;
    
    nrf_drv_spi_xfer(&afe_spi, &xfer_desc,
    		//NRF_DRV_SPI_FLAG_RX_POSTINC
            //|NRF_DRV_SPI_FLAG_TX_POSTINC
    		//|NRF_DRV_SPI_FLAG_NO_XFER_EVT_HANDLER
            NRF_DRV_SPI_FLAG_HOLD_XFER
            |NRF_DRV_SPI_FLAG_REPEATED_XFER
    		);
    

    What is going on? Thanks

Related