How to trigger DTC transfer with r_spi TXI?

Hi everyone,

I'm new to Renesas MCUs and currently working with the EK-RA2L1 to control a WS2812B LED strip using the r_spi peripheral. I'm trying to automate the SPI0 transmission with the Data Transfer Controller (DTC). However, I'm running into an issue: although the TXI interrupt for SPI0 triggers correctly, the DTC itself doesn’t seem to activate.

Here’s how I configured the SPI peripheral:

And here’s how I configured the DTC transfer:

When the SPI transfer completes, I print a message to confirm it.

void spi_callback(spi_callback_args_t *p_args)
{
    if (SPI_EVENT_TRANSFER_COMPLETE == p_args->event)
    {
        APP_PRINT("\r\nSPI Transfer Complete\r\n");
    }
}

Through J-Link RTT Viewer, I receive the "SPI Transfer Complete" message, confirming that the TXI interrupt is working. However, I only see the initial byte that I manually placed in the SPI buffer on the oscilloscope. This suggests that the DTC is not transferring additional data as expected.

This is the code I’m currently using for configuring SPI and setting up the DTC:

void hal_entry(void)
{
    APP_PRINT("\r\nWS2812B controller with SPI\r\n");

    fsp_err_t err = FSP_SUCCESS;
    uint8_t data4SPIbuffer = 0b11011011;
    uint8_t data_to_send[2] = {0b01101101, 0b10110110};

    err = R_SPI_Open(&g_spi0_ctrl, &g_spi0_cfg);
    /* Handle error */
    if (FSP_SUCCESS != err)
    {
        APP_ERR_PRINT("\r\n ** SPI Open API failed ** \r\n");
        APP_ERR_TRAP(err);
    }

    err = R_DTC_Enable(&g_transfer2_ctrl);
    /* Handle error */
    if (FSP_SUCCESS != err)
    {
       APP_ERR_PRINT("\r\n ** DTC Enable API failed ** \r\n");
       APP_ERR_TRAP(err);
    }

    /* Configure DTC */
    g_transfer2_cfg.p_info->p_dest = (void *) R_SPI0->SPDR;
    g_transfer2_cfg.p_info->p_src = &data_to_send;
    g_transfer2_cfg.p_info->length = sizeof(data_to_send);

    err = R_DTC_Reconfigure(&g_transfer0_ctrl, g_transfer0_cfg.p_info);
    /* Handle error */
    if (FSP_SUCCESS != err)
    {
       APP_ERR_PRINT("\r\n ** DTC Reconfigure API failed ** \r\n");
       APP_ERR_TRAP(err);
    }

    err = R_SPI_Write(&g_spi0_ctrl, data4SPIbuffer, 1, SPI_BIT_WIDTH_8_BITS);
    /* Handle error */
    if (FSP_SUCCESS != err)
    {
        APP_ERR_PRINT("\r\n SPI Write failed!\r\n");
        APP_ERR_TRAP(err);
    }
}

Thank you in advance for any insights or suggestions on getting the DTC to trigger!

Parents Reply Children