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.

N2HET example using multiple IO pins



I am using the TMS520LS3137 Hercules part (note that part-number did not work in the part-number-field above); I have a single-IO-pin N2HET application running based somewhat on the sine-wave demo, but I cannot figure out how this simple control loop can be extended to multiple IO pins (like 3 motor-phases). 

Do you have an example application that manipulates multiple IO pins? I thought the CNT/ECMP pairs might be extended to each IO pin, but CNT increments the counter value each execution (so there cannot be a second CNT instruction for the second ECMP instruction). Then I thought just a second ECMP instruction to manipulate the second IO pin, but the Z flag only stays active for 1 cycle, so the second ECMP would not be able to act on the CNT (Z=1) action. So what does an application look like that requires 3 different pins to be set to 3 different values?

Thanks,

Jim

  • Hi Jim,

    This is a example to generate 3 channels with different PWM frequencies using MCMP.

    L00  CNT    {  reg=A, irq=OFF, max= 2 }
    L01  MCMP { en_pin_action=ON, order=REG_GE_DATA, pin=0, action=PULSELO, reg=A, data=1, hr_data=64 };
    L02  CNT    {  reg=A, irq=OFF, max= 3 }
    L03  MCMP { en_pin_action=ON, order=REG_GE_DATA, pin=1, action=PULSELO, reg=A, data=2, hr_data=4 }; 
    L04  CNT    {  reg=A, irq=OFF, max= 4 }
    L05  MCMP { en_pin_action=ON, order=REG_GE_DATA, pin=2, action=PULSELO, reg=A, data=1, hr_data=0 };
    L06  BR      { next= L00, cond_addr=L00, event= NOCOND }

    Regards,

    QJ

  • QJ,
    Thanks for the quick reply. I have an application that I think would be the common application for motor control -- I need to have 3 IO pins (3 phases), that are running the same counter-period (CNT max) and synchronized. Each of the 3 IO pins has an independent compare value (might be the same, might be different).

    So the loop above can only increment the counter-value once per loop, because each CMP needs to see every possible counter value. But the manual states "The counter value stored in the data field [D31:7] is incremented unconditionally on each resolution when in time mode", so each CNT increments the counter value.

    Thanks,
    Jim
  • I think I understand how the example program would work, but now the 3 MCMP values need to be dynamically updated via the main CPU every cycle. I have a single-IO-pin version of this (shown below):

    L00 CNT { reqnum=0, request=GENREQ, reg=A, irq=ON, max=PWM_PERIOD};

    L01 ECMP { next=L03, hr_lr=HIGH, en_pin_action=ON, cond_addr=L02, pin=PWM_PIN_NUM,
    action=PULSELO, reg=A, irq=OFF, data=INIT_COMPARE, hr_data=INIT_HR_DELAY};

    L02 MOV32 { remote=L01, type=IMTOREG&REM, reg=NONE, data=INIT_COMPARE, hr_data=INIT_HR_DELAY};

    L03 BR { next= L00, cond_addr=L00, event= NOCOND }

    And the ECMP-compare-value is "DMA-ed" in via the MOV32 command and the HTU.

    Is there an example of how the HTU would transfer 3 different UINT16 values (3 different phase voltages) to the 3 different MOV32-data-locations? Or can you suggest another way to transfer 3 different values to the 3 ECMP/MCMP commands?

    Thanks,

    Jim