RM57L843: HET1 DMA

Part Number: RM57L843

Hello,

I am working with HET IDE code as shown below:

L00   CNT { next=L01,reqnum=0,request=GENREQ,reg=A,max=5};
L01 ECMP { next=L02,hr_lr=HIGH,en_pin_action=ON,cond_addr=L03,pin=27,action=PULSEHI,reg=A,data=0,hr_data=0};
L02 MOV32 { remote=L01,type=IMTOREG&REM,reg=NONE,data=0,hr_data=0};
L03 BR { next=L00,cond_addr=L00,event=NOCOND};

I am trying to transmit data stored in g_test_tx_buf using HET + HTU:

uint32_t g_test_tx_buf[2048];

Setup function:

void Transmit_Engine_Setup(uint32_t* sourceAddr, uint32_t targetIdx, uint32_t len)
{
htuREG1->GC = 0x00010000;
for(volatile int i=0; i<3000; i++);

htuREG1->CPENA = 0x00;
htuREG1->MPCS = 0x00000005;

htuDCP1[0].IFADDRA = (uint32_t)sourceAddr;
htuDCP1[0].IHADDRCT = (1U << 23) | (1U << 18) | targetIdx;
htuDCP1[0].ITCOUNT = 0x00010000 + len;

hetREG1->GCR = 0x00010001;
hetREG1->REQENS = (1U << 0);

htuREG1->CPENA = 0x01;
}

Function call:

Transmit_Engine_Setup(g_test_tx_buf, HTU_DCP0_TARGET, 2048);

According to the TRM (SPNU562A, page 1168), the IFTCOUNT field in ITCOUNT is 8 bits, so the maximum transfer count per frame is 255.

Because of this limitation, it seems that transferring 2048 words in a single operation is not possible.

My questions are:

  1. Is there a recommended method to transfer a buffer larger than 255 words using HTU?
  2. Should this be handled by splitting the transfer into multiple HTU frames?
  3. Is there any hardware-supported mechanism (e.g., auto-reload, chaining, or circular mode) to handle larger transfers efficiently?

Any guidance would be appreciated.

Thank you.

  • Hi Jung,

    On the first phase i would suggest you to refer the below response of our internal AI tool, if you have further questions i will again assist you to resolve them.

    Handling Large HTU Transfers on RM57L843

    You're correct that the IFTCOUNT field is limited to 8 bits (max 255 transfers per frame). Here are the recommended approaches for transferring 2048 words:

    1. Multi-Frame Transfer with Control Packet Chaining

    The HTU supports control packet chaining which is the hardware mechanism designed for this purpose.

    Implementation:
    #define MAX_FRAME_SIZE 255
    #define TOTAL_WORDS 2048
    #define NUM_FRAMES ((TOTAL_WORDS + MAX_FRAME_SIZE - 1) / MAX_FRAME_SIZE) // = 9 frames
    
    void Transmit_Engine_Setup(uint32_t* sourceAddr, uint32_t targetIdx, uint32_t len)
    {
        uint32_t remaining = len;
        uint32_t offset = 0;
        uint32_t frameIdx = 0;
        
        // Disable HTU
        htuREG1->GC = 0x00010000;
        for(volatile int i=0; i<3000; i++);
        htuREG1->CPENA = 0x00;
        htuREG1->MPCS = 0x00000005;
        
        // Setup control packets with chaining
        while(remaining > 0)
        {
            uint32_t frameSize = (remaining > MAX_FRAME_SIZE) ? MAX_FRAME_SIZE : remaining;
            
            htuDCP1[frameIdx].IFADDRA = (uint32_t)(sourceAddr + offset);
            htuDCP1[frameIdx].IHADDRCT = (1U << 23) | (1U << 18) | targetIdx;
            htuDCP1[frameIdx].ITCOUNT = (0x00010000) | frameSize;
            
            // Setup chaining: point to next control packet
            if(remaining > MAX_FRAME_SIZE)
            {
                // Enable chaining (bit 20) and set next CP address
                htuDCP1[frameIdx].IHADDRCT |= (1U << 20); // TMBA bit
                htuDCP1[frameIdx].ITCOUNT |= ((frameIdx + 1) << 24); // Next CP index
            }
            
            offset += frameSize;
            remaining -= frameSize;
            frameIdx++;
        }
        
        // Enable HET and HTU
        hetREG1->GCR = 0x00010001;
        hetREG1->REQENS = (1U << 0);
        htuREG1->CPENA = 0x01;
    }

    2. Interrupt-Driven Approach

    If you prefer more control, use HTU interrupts to trigger the next transfer:

    volatile uint32_t g_current_offset = 0;
    volatile uint32_t g_remaining_words = 0;
    volatile uint32_t* g_source_ptr = NULL;
    
    void Transmit_Engine_Setup(uint32_t* sourceAddr, uint32_t targetIdx, uint32_t len)
    {
        g_source_ptr = sourceAddr;
        g_current_offset = 0;
        g_remaining_words = len;
        
        htuREG1->GC = 0x00010000;
        for(volatile int i=0; i<3000; i++);
        htuREG1->CPENA = 0x00;
        htuREG1->MPCS = 0x00000005;
        
        // Enable HTU interrupts
        htuREG1->INTENAS = 0x01; // Enable interrupt for CP0
        
        // Start first frame
        Start_Next_Frame(targetIdx);
        
        hetREG1->GCR = 0x00010001;
        hetREG1->REQENS = (1U << 0);
        htuREG1->CPENA = 0x01;
    }
    
    void Start_Next_Frame(uint32_t targetIdx)
    {
        uint32_t frameSize = (g_remaining_words > MAX_FRAME_SIZE) ? 
                             MAX_FRAME_SIZE : g_remaining_words;
        
        htuDCP1[0].IFADDRA = (uint32_t)(g_source_ptr + g_current_offset);
        htuDCP1[0].IHADDRCT = (1U << 23) | (1U << 18) | targetIdx;
        htuDCP1[0].ITCOUNT = 0x00010000 | frameSize;
    }
    
    #pragma INTERRUPT(htuInterrupt, IRQ)
    void htuInterrupt(void)
    {
        // Check if transfer complete
        if(htuREG1->INTFLG & 0x01)
        {
            htuREG1->INTFLG = 0x01; // Clear flag
            
            g_current_offset += MAX_FRAME_SIZE;
            g_remaining_words -= MAX_FRAME_SIZE;
            
            if(g_remaining_words > 0)
            {
                Start_Next_Frame(HTU_DCP0_TARGET);
            }
            else
            {
                // Transfer complete
                htuREG1->CPENA = 0x00;
            }
        }
    }

    3. Key Points

    • TMBA bit (bit 20 in IHADDRCT): Enables control packet chaining
    • NXTCP field (bits 31-24 in ITCOUNT): Specifies next control packet index
    • Maximum 16 control packets available per HTU instance
    • For 2048 words: need 9 frames (8×255 + 1×8)

    Recommendation

    Use Method 1 (Control Packet Chaining) as it's hardware-supported and most efficient. The HTU will automatically process all chained packets without CPU intervention.

    --
    Thanks & Regards,
    Jagadish.

  • Thank you for your response. I would like to ask an additional question about Method 1.

    In the SPN215C Datasheet, on page 182 (section 7.6.7.2 “Trigger Connections”), it appears that each module is connected through 8 lines. Is it possible to have 16 connections?

    Thank you.