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.

help request: sending 128 16-bit values with buffered SPI (RM46)

Other Parts Discussed in Thread: HALCOGEN

I'm working on a design that matches the Educational BoosterPack MKII display with Hercules microcontrollers.

I am struggling with a particular problem: Sending 128 16-bit  values  with MibSPI in one go.
I am able to send 128 separate 16-bits values with MIBSPI. 

I'm using MIBSPI 3.

I created a data format for 16 bits.

I created a transfer group that uses that group.

When calling the MIBSpi Functions (TXDATA contains 128 16-BIT values)

    mibspiSetData(mibspiREG3, 2, &TXDATA[0]);
    mibspiTransfer(mibspiREG3, 2 );
    while(!(mibspiIsTransferComplete(mibspiREG3, 2))) {
    }

I don't get the expected results.

In the HALCoGen generated mibspiSetData() function , the "start" and "end" variable get value "1" and "2".

I was expecting to have the a value of  0 and 127.

Because the values are 1 and 2, the mibspiSetData() function only copies one value into the MIBSpi Buffers.

  • Hi Jan,

     What is the buffer length you configure for group0 and group1?

     The "start" should be the PSTART for group2 and the "end" should be the PSTART for group3. I'm seeing 0 and 127 for the start and end.

       uint32 start  = (mibspi->TGCTRL[group] >> 8U) & 0xFFU;

       uint32 end    = (group == 7U) ? (((mibspi->LTGPEND & 0x00007F00U) >> 8U) + 1U) : ((mibspi->TGCTRL[group+1U] >> 8U) & 0xFFU);

    mibspiREG3->TGCTRL[2U] = (uint32)((uint32)0U << 30U) /* oneshot */
    | (uint32)((uint32)1U << 29U) /* pcurrent reset */
    | (uint32)((uint32)TRG_ALWAYS << 20U) /* trigger event */
    | (uint32)((uint32)TRG_DISABLED << 16U) /* trigger source */
    | (uint32)((uint32)(0U+0U) << 8U); /* start buffer */

    mibspiREG3->TGCTRL[3U] = (uint32)((uint32)1U << 30U) /* oneshot */
    | (uint32)((uint32)0U << 29U) /* pcurrent reset */
    | (uint32)((uint32)TRG_ALWAYS << 20U) /* trigger event */
    | (uint32)((uint32)TRG_DISABLED << 16U) /* trigger source */
    | (uint32)((uint32)(0U+0U+127U) << 8U); /* start buffer */

  • (if I manipulate the values of start and end in debug mode, mibspi nicely sends my data)

  • Group 0 and 1 both have 1;

    I use group0 to send single 8-bit values,

    and group1 to send single 16-bit values.

    Here's the values in the HalCoGen generated init():

        /** - initialize transfer groups */
        mibspiREG3->TGCTRL[0U] = (uint32)((uint32)1U << 30U)  /* oneshot */
                               | (uint32)((uint32)0U << 29U)  /* pcurrent reset */
                               | (uint32)((uint32)TRG_ALWAYS << 20U)  /* trigger event */
                               | (uint32)((uint32)TRG_DISABLED << 16U)  /* trigger source */
                               | (uint32)((uint32)0U << 8U);  /* start buffer */
    
        mibspiREG3->TGCTRL[1U] = (uint32)((uint32)1U << 30U)  /* oneshot */
                               | (uint32)((uint32)0U << 29U)  /* pcurrent reset */
                               | (uint32)((uint32)TRG_ALWAYS << 20U)  /* trigger event */
                               | (uint32)((uint32)TRG_DISABLED << 16U)  /* trigger source */
                               | (uint32)((uint32)1U << 8U);  /* start buffer */
    
        mibspiREG3->TGCTRL[2U] = (uint32)((uint32)0U << 30U)  /* oneshot */
                               | (uint32)((uint32)1U << 29U)  /* pcurrent reset */
                               | (uint32)((uint32)TRG_ALWAYS << 20U)  /* trigger event */
                               | (uint32)((uint32)TRG_DISABLED << 16U)  /* trigger source */
                               | (uint32)((uint32)(1U+1U) << 8U);  /* start buffer */
    
        mibspiREG3->TGCTRL[3U] = (uint32)((uint32)1U << 30U)  /* oneshot */
                               | (uint32)((uint32)0U << 29U)  /* pcurrent reset */
                               | (uint32)((uint32)TRG_ALWAYS << 20U)  /* trigger event */
                               | (uint32)((uint32)TRG_DISABLED << 16U)  /* trigger source */
                               | (uint32)((uint32)(1U+1U+127U) << 8U);  /* start buffer */
    

  • HALCoGen config complete:

  • Hi Jan,

    I think the reason is that bit15 in the TGCTRL register is reserved. When (1U+1U+127U) << 8U is used the upper bit is chopped off. So what is really stored in the TGCTRL[3U] for the PSTART is only 1.
  • Hi Jan,
    Also that MibSPI3 only supports 128 buffers. The three transfer groups together exceeds 128.
  • Thanks, . I didn't know that the groups add up to the buffer limit.
    I'll restructure my code to get the 3 groups to fit into 128.
    I'll report back...

  • Reporting success.
    I have set my buffer for group2 to 64.
    When debugging, start is 2, end is 66. Yes!
    Everything works perfectly. I get 64 16-bit values streamed in one go.

    Thank you very much, .
  • Hi Jan,
    Glad your problem is resolved.