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 use 16 HTU Channels for 64 HET Pins?

Other Parts Discussed in Thread: TMS570LC4357

Hi TI,

I am using TMS570LC4357. In my project I want to use N2HET Peripheral to generate PWM waveform.

In TMS570LC4357 Controller, there are totally two N2HET Peripherals namely N2HET1, N2HET2 and two HTU Peripherals namely HTU1, HTU2.

Each N2HET has 32 HET Pins and each HTU has 8 HTU Channels.

So now I want to use only 17 Pins to generate PWM waveform.

My HET Code is given below.

; PWM, 1 channel, using MCMP
L00  CNT    {  reg=A, irq=OFF, max= 15, req=genreq, reqnum=0}
L01  MCMP { en_pin_action=ON, pin=0, order=REG_GE_DATA, action=PULSELO, reg=A,data=2};

I am having the same code 8 times in N2HET1 RAM to control 8 pins of N2HET1 and having the same code 9 times in N2HET2 RAM to control 9 pins of N2HET2. And the max field and data field of CNT and MCMP instructions are updated by HTU.

So for first 8 Pins, Updates to datafield in N2HET1 RAM is happening by 8 channels of HTU1 and for remaining 8 pins,  Updates to N2HET2 RAM is happening by 8 channels of HTU2,.


So totally I can produce waveform (as I expected) in only 16 pins. But for the last 17th pin I can not update the data fields since because HTU has no more HTU channel to support update for the 17 th pin HET code data field.

So this is my problem. It seems like, my hardware resources is sufficient to handle up to 16 N2HET pins alone.

But TI gives totally 64 pins in N2HET peripheral and only 16 HTU Channels in TMS570LC4357. So there should be any way or trick to handle more than 16 pins by N2HET peripheral.

So please anybody help me to update/handle that 17th N2HET2 pin code data field in N2HET2 RAM.

Thanks in advance.

Karthikeyan.K

  • Hello Karthikeyan,

    I have forwarded your post to one of our N2HET experts. They should get back with you shortly.
  • Hello Karthikeyan,

      I will suggest you rearrange your code sequence slight so you don't have to use all 8 HTU channels per N2HET. Instead of replicating the CNT->MCMP pair 8 times, you can do something like below. Here I'm using an example with two CNT->MCMP pairs. You can expand on this idea.

    L00 CNT   { reg=A, ......}
    L01 CNT { reg=B........}
    L02 MCMP { ........ reg=A,......};
    L03 MCMP { ........ reg=B,......};

    In this code sequence you just need to setup one HTU channel to update the data field of both MCMP instructions since these two MCMP instructions are next to each other. You will setup
    ADDMH for increment by 16 bytes and IHADDR pointing to the first MCMP data field. In the ITCOUNT register, you will change the IECOUNT to 2 instead of 1.

  • One note I want to add is that the example assumes that your application can somehow allow to change the data field of the second MCMP the same time as the first MCMP. The reason is that different MCMP in your application may have different compare value. When there is a compare match in the first MCMP, you generate a DMA request to the HTU and HTU will not only update the data field of the first MCMP but also the second MCMP. So your second MCMP data field may be updated earlier or later than it would have generated its own DMA request to the HTU. If your application can tolerate this then the example will work. Perhaps you want to evaluate which two of the 17 pins can tolerate this.

  • One more idea is that if you have not used up all the global DMA channels, you can send the 17th pin's request to the DMA module instead of HTU. The difference between DMA and HTU is that HTU is tightly coupled to the N2HET so the data transfer will be more efficient. But if you are transfering only one element at a time, I don't think the difference will be that much. Please look at the HETREQDS register to select sending DMA request to either DMA module or HTU module. The default is to send to HTU.
  • Hi Charles Tsai,

    Thanks for your ideas.
    In my setup no two het instruction are to be updated at the same time. So I cannot use the first trick. Seperate trigger is needed for every instruction as they has separate timings.

    So I am coming to the second solution. It may be useful for me. But I am having a doubt in that trick.

    When I am trying to implement the second trick, I encounter a problem described below.

    For example,
    My 16th MCMP HET Instruction is using 7th HTU channel of HTU2 unit. So DCP7 is configured to by-pass a trigger to HTU2 unit and not to DMA.
    i.e:
    HET2->HETREQDS &= ~((1<<23) | (1<<7)) ;

    So How can I write 17th MCMP HET Instruction to trigger DMA instead of HTU2 using same 7th DCP?

    or else clearly,
    Is it possible to write two HET Instructions in such a way that one instruction is to trigger HTU and other instruction is to trigger DMA but both are using same channel / reqnum but? How?

    For example.

    L00 CNT   {  reg=A, irq=OFF, max= 9,reqnum=7, request= genreq } ; I want this instruction to trigger DMA using N2HET2 DMAREQ[7] Channel.
    L01 ECMP {  en_pin_action=ON, pin=0, action=PULSELO, reg=A, data= 4} ; This data field updated by HTU2 and control pin 0.
    
    L02 CNT   {  reg=A, irq=OFF, max= 15, reqnum=7, request= quiet }; I want this instruction to trigger HTU2 using N2HET2 HTUREQ[7] Channel. That's why I put request=quiet here. (to give request only to HTU).
    L03 ECMP {  en_pin_action=ON, pin=1, action=PULSELO, reg=A, data= 5}; This data field updated by DMA and control pin 1.
    

    In the third line of the above example code, I used request = quiet. I believe that quiet request will be given only to the HTU and not to DMA to initiate transaction. But in TRM, it is specified that Quiet requests are not to initiate the transaction and only to detect the request lost. If it's that so, I can not give a trigger to HTU alone isn't it? Please clarify about quiet request. May be I can use GenReq to trigger DMA and Quiet ReQ to trigger HTU for my objective, if I clear in using Quiet requests.

    And also another doubt sir. Just now I have this doubt while referring the TMS570LC4357 trm.

    TMS570LC4357 TRM says that,
    N2HET1 DMAREQ[4] to N2HET DMAREQ[7] are mapped to DMAREQ[20,21,24,25]
    and at the same time N2HET2 DMAREQ[4] tp DMAREQ[7] are also mapped to the same DMAREQ[20,21,24,25].

    This means that we can use N2HET1 DMAREQ[4] or N2HET2 DMAREQ[4] at a time.
    So theoretically N2HET can trigger 8 DMA Channels but actually it can only trigger 4 DMA Channels out of available 8 DMA Channel.
    (This is what I understand from TRM. May be this is wrong. If wrong, please corect me sir.)

    Please give some guidance sir.


    Thanks in advance.
    Karthikeyan.K

  • Hello Karthik,

     I don't think my second idea and your idea for two instructions to share the same request will work. EVen if you use quite Request for the first one, the Dma module does not understand the difference BTW quite and normal Request. So the DMA will still see two back to back  requests on the same channel coming to it. If the first idea is not possible for your application then I will suggest you use interrupt for the 17th pin.  Your have 17 PWM which are totally asynchronous and independent from each other. I can't think of a way to share HTU or DMA channel among different instructions.

     For your second question your understanding is correct that s/w needs to ensure that at any one time there is only one active request from one module when multiple modules share the same DMA channel.

  • Hi Charles Tsai,

    A Great Thanks for your support in clarifying my doubts until now.

    Actually I don't want to use Interrupt in my project. Because I am using Free-RTOS in TMS570LC4357 controller and using 1ms, 10ms Tasks.

    I doubt about that using interrupt will make my RTOS code to be stopped for reasonable time (I am performing very time-critical tasks). This will conflict my concept of execution flow.

    But anyhow if suppose interrupt routine is just to trigger a DMA channel which is already configured to transfer elements to N2HET RAM, this will not corrupt my other code timings. So I can use Interrupt concept as you mention.

    Ok sir.

    If I am using Interrupt concept, and my 17th instruction is giving interrupt, then there is no complexity to detect which instruction is giving interrupt since only one instruction is giving interrupt. So my concept is done.

    But for understanding purpose I am asking this.

    If I am using two instructions to give interrupt then how to detect which instruction is giving interrupt?

    (By reading which register or any other way).

    Thanks in advance.

    Regards,

    Karthikeyan.K

  • Hi Chales Tsai,

    Thank you so much for your support until now sir. The suggestions given by you are really helpful to me.

    I found the way to detect from which instruction line, the interrupt comes from. By using HETFLG register we can find from which instruction line the interrupt comes from.

    So I am clear with the concept sir. Really this talk will be more helpful to newbies.

    Thanks a lot sir.

    Regards,
    Karthikeyan.K
  • Hi Karthik,

    Apologize for my late response as I'm out of office this week. The NHET will differentiate the source of the interrupt by the instruction's location in the program. I think you have realize this. One note to add is that the NHET can differentiate among 32 instructions. When you have more than 32 instructions generating interrupts, the interrupt flags will be shared. For example, instruction 0, 32, 64 and so on will share the same interrupt flag. Please be aware of this limitation.

  • Karthik,

    This interrupt servicing mechanism is also described in the technical reference manual. See section 23.2.7 on page 969 of SPNU563.

    Sunil