This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

How to transmit more than 256 bytes one time by SPI DMA on CC254X?

Other Parts Discussed in Thread: BLE-STACK

On CC254X, I configured the SPI DMA transmission:

halDMADesc_t* ch = HAL_DMA_GET_DESC1234(HAL_DMA_CH_TX);
HAL_DMA_ABORT_CH(HAL_DMA_CH_TX);
HAL_DMA_SET_DEST(ch, HAL_DMA_U0DBUF);
HAL_DMA_SET_VLEN(ch, HAL_DMA_VLEN_USE_LEN);
HAL_DMA_SET_WORD_SIZE(ch, HAL_DMA_WORDSIZE_BYTE);
HAL_DMA_SET_TRIG_MODE(ch, HAL_DMA_TMODE_SINGLE);
HAL_DMA_SET_TRIG_SRC(ch, HAL_DMA_TRIG_UTX0);
HAL_DMA_SET_SRC_INC(ch, HAL_DMA_SRCINC_1);
HAL_DMA_SET_SOURCE(ch, buf);
HAL_DMA_SET_DST_INC(ch, HAL_DMA_DSTINC_0);
HAL_DMA_SET_IRQ(ch, HAL_DMA_IRQMASK_ENABLE);
HAL_DMA_SET_M8(ch, HAL_DMA_M8_USE_8_BITS);
HAL_DMA_SET_PRIORITY(ch, HAL_DMA_PRI_HIGH);
HAL_DMA_SET_LEN(ch, len);
HAL_DMA_ABORT_CH(HAL_DMA_CH_TX);
HAL_DMA_ARM_CH(HAL_DMA_CH_TX);
asm("NOP"); asm("NOP"); asm("NOP"); asm("NOP");
asm("NOP"); asm("NOP"); asm("NOP"); asm("NOP"); asm("NOP");
HAL_DMA_MAN_TRIGGER(HAL_DMA_CH_TX);

It can send up to 255 bytes at a time.

Now I want to tranmit more than 256 bytes, that is len > 256, How to configure it? Thanks!

  • Hi,

    Please take a look at TRM page 99. If Vlen is different than 000 and 111, then the max length is 0x1FFF bytes

  • Hello Hansome,

    Take a look at the _hal_uart_spi.c file where the SPI maximum packet length is defined:

    #define SPI_MAX_PKT_LEN            256

    Could this solve your issue?

  • Christin,

    I had debugged carefully,
    a. VLEN = 00
    b. LEN = 0x02d0

    But the SPI only transmits the first 255 bytes, Is it the limit of SPI interface?

    Hansome
  • Eirik,

    I am pure manual operation, No dependent firmware library.

    Hansome
  • Try to utilize _hal_uart_spi.c file from the ble-1.4.1 stack installer instead of using your own implementation.
  • Eirik,

    In other words, based on CC254x BLE Stack V1.4.0, can you tell me how to:

    a. Config the SPI macros(SPI master)

    b. Initialize the SPI interface(SPI master)

    c. Transmit the SPI bytes by DMA continuously(SPI master)

    I tried to search on this forum, TI documents, TI websites, google, etc.

    There is no result about SPI interface usage on CC254x.

    That is why I used my own implementation for SPI TX DMA, Could you help me? Thanks!

    Hansome
  • This is implemented in hal_uart used in the HostTest Project. I would advise you to use the latest ble-stack (version 1.4.1) as a basis. The _hal_uart_spi.c provide a full API to use SPI-DMA. Try to set up a basic program then you can modify your copy of _hal_uart_spi.c as you see fit.
  • Eirik,

    I am not a person who has no experience, the SPI is really hard to use.

    Based on SimpleBLEPeripheral,
    a. Config the project
    HAL_UART=TRUE
    HAL_UART_PORT=TRUE
    HAL_UART_SPI=1
    HAL_SPI_MASTER
    HAL_UART_DMA=1
    b. Write the testing codes
    HalUARTInit();
    halUARTCfg_t cfg;
    cfg.callBackFunc = NULL;
    HalUARTOpen(HAL_UART_PORT_1, &cfg);
    uint8 buf[16];
    uint8 i;
    for(i = 0; i < 16; i++){
    buf[i] = i;
    }
    while(1){
    HalUARTWrite(HAL_UART_PORT_1, buf, 16);
    for(i = 0; i < 64; i++){
    asm("nop");
    }
    }

    P0.0 P0.1 P0.2 P0.3 P0.4 P0.5 P0.6 P0.7 don't have normal waveforms.
    Could you try it too?I really need the guidance of the details.Thank you very much!

    Hansome