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.

Shifted Pulses with N2HET

Shifted Pulses with N2HET
I created the following program to produce shifted pulses.

L00 CNT  {  reg=A, irq=OFF, max = 60};
    ECMP {   hr_lr=LOW, en_pin_action=ON, pin=0, action=PULSEHI, reg=A, irq=OFF, data= 10, hr_data = 0x0 }
    ECMP {   hr_lr=LOW, en_pin_action=ON, pin=1, action=PULSEHI, reg=A, irq=OFF, data= 14, hr_data = 0x0 }
    ECMP {   hr_lr=LOW, en_pin_action=ON, pin=2, action=PULSEHI, reg=A, irq=OFF, data= 20, hr_data = 0x0 }
    ECMP {   hr_lr=LOW, en_pin_action=ON, pin=3, action=PULSEHI, reg=A, irq=OFF, data= 24, hr_data = 0x0 }
    ECMP {   hr_lr=LOW, en_pin_action=ON, pin=4, action=PULSEHI, reg=A, irq=OFF, data= 30, hr_data = 0x0 }
    ECMP {   hr_lr=LOW, en_pin_action=ON, pin=5, action=PULSEHI, reg=A, irq=OFF, data= 34, hr_data = 0x0 }
    ECMP {   hr_lr=LOW, en_pin_action=ON, pin=6, action=PULSEHI, reg=A, irq=OFF, data= 40, hr_data = 0x0 }
    ECMP {   hr_lr=LOW, en_pin_action=ON, pin=7, action=PULSEHI, reg=A, irq=OFF, data= 44, hr_data = 0x0 }
    ECMP {   hr_lr=LOW, en_pin_action=ON, pin=8, action=PULSEHI, reg=A, irq=OFF, data= 50, hr_data = 0x0 }
    ECMP {  next= L00, hr_lr=LOW, en_pin_action=ON, pin=9, action=PULSEHI, reg=A, irq=OFF, data= 54, hr_data = 0x0 }

It's possible to specify the duration of the pulses and delay between pulses.
But this program needs to set XOR between couple of pin and this loses 5 pins.
Is it possible to write another program which do not use XOR share?
Thanks for your help.
Kind regards
Jerome

  • Jerome,

    One of our NHET experts will help you with this.

  • Jerome,

    You probably have more N2HET resources than pins on the device,  so usually if you use a pin in XOR mode there is another function on that pin that you can use in your app.   But hard to say this without knowing your pinout.

    Needless to say - check your device datasheet.  There is a good chance that the XOR share pin (odd #) might not even be bonded out if you are using a QFP package.  Or alternatively there could be an N2HET pin from the 2nd N2HET or another timer function that can use the same pin on the package.  

    This way - you can possibly keep the scheme but not waste physical pins on the package.

    -Anthony

  • Anthony,
    Thanks for your reply and for your help.
    I can better understand why a lot of odd pins of N2HET1 are multiplexed with even pins of N2HET2.
    I suppose we have to consider this fact when we establish the pinout in a project.
    About the N2HET code, do you think it’s a good practice for generate shifted pulses?
    Thank a lot
    Kind Regards

  • Hi Jerome,

    I was actually giving the answer some second thoughts.

    The answer I gave is probably the most general.

    XORSHARE is really only needed if you need to take one pin and toggle it *twice* during a given loop resolution period.  This would be the case as a PWM approaches 0% or 100% duty cycle where one of the pulse widths becomes less than a loop resolution period.

    But your code says you are using ECMP at loop resolution.    So you are only changing the pin state once during a loop resolution period.

    In this case, there is an alternative which doesn't require XORSHARE.

    It is a pattern that you'll see in some of the HET code that we have posted, for example the 3Phase PWM example on the e2e forum.


    You take 3 instructions:

    L1 ECMP   *initially* set pin high,  conditional address = M1

    L2 ....

    M1 MOV64  -> Reconfigure L1 ECMP to:   set pin low,  conditional address = M2, next=L2

    M2 MOV64  -> Reconfigure L1 ECMP to:   set pin high,  conditional address = M1, next=L2

    (You can also use DADM64 or RADM64 if you want to change the compare value / data field in the same step

      as you reconfigure the ECMP opcode)

    The way this code would execute it would be like this:

    Loop Start..

      L1  ECMP, no match

      L2

     ...

    Loop Start...

      L1  ECMP, no match

      L2

    ...

    Loop Start

      L1  ECMP matches,  sets pin high, branch to M1

      M1  Reconfigure ECMP to set pin low, and conditional address is now M2

      L2

     ...

    Loop Start..

      L1  ECMP, no match

      L2

     ...

    Loop Start...

      L1  ECMP, no match

      L2

    ...

    Loop Start

      L1  ECMP matches,  sets pin low,  branch to M2

      M2  Reconfigure ECMP to set pin high, and conditional address is now M1

      L2

     ...

    Loop Start..

      L1  ECMP, no match

      L2

     ...

    Loop Start...

      L1  ECMP, no match

      L2

    ...

    Loop Start

      L1  ECMP matches,  sets pin high, branch to M1

      M1  Reconfigure ECMP to set pin low, and conditional address is now M2

      L2

     ...

    repeating forever like this.


    If you are using CNT in a periodic mode also make sure the 1st trip point is written into L1 initially and also M2. 
    The 2nd trip point should be written into M1  (data field).