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.

TMS570LS3137: Generating square wave as clock output using N2HET

Part Number: TMS570LS3137
Other Parts Discussed in Thread: HALCOGEN

Hello there,

Using the N2HET, I need to generate a 4-MHz square wave signal to fed another device as its clock input, but couldn't see an instruction for such purpose. Am I overlooking the instructions set?

Thank you for any indication.

  • I think that I can use the CNT and ECMP instructions to achieve a clock generation output. Is this right?

    I can use ALU register B with the CNT instruction but couldn't figure out how to configure the ECMP instruction, beside the fact that I should set hr_lr=1 (no delay), enable_pin_action=1 and opposite_pin_action=1.


    Is it all it takes?

    EDITED: Need also to set action=pulse_low (toggle output), comp_mode=ECMP.

    How to reload the ALU register B=0 for next compare with the 25-bit data field?

    Thanks.

  • Hi Chuck,

    We have a nice simulation tool: HET IDE. You can try the instruction in the IDE and output the waveform to the WaveViewer. The IDE provides several examples to generate PWM, and capture the input waveform. The algorithms are located in IDE->Edit->Insert Algorithm. This is a simple PWM output using NHET instructions: CNT, ECMP, BR. The highlighted waveform is the generated PWM.

    But, 4MHz is too high. The NHET can not generate exact 4MHz PWM for you.

  • Hi QJ,

    I'm using the MAX frequency of 100 MHz to clock the N2HET and I've 8 instructions for the lr loop.

    When you said 4 MHz is too high to be output, is it the limitation of the Halcogen or the MCU itself?

    If it is because of the MCU, could you point me to the TRM or device datasheet for this limitation?

    Thanks,

    Chuck.

  • Hello Chuck,

    VCLK2=100MHz for NHET, you use 8 cycle loop resolution (maximum 7 instructions allowed).

    you would need at least two loop resolution periods - one to set the pin high and one low.

    CNT_MAX=Period/LRP-1=250ns/80ns-1=2  -->240ns period -->4.167Mhz not exactly 4Mhz

    The simulation shows that the PWM is 4.16MHz too. (#12, watch_0_Out)

  • Hello QJ,

    I understood from your previous post that the N2HET is not capable to physically output 4 MHz, apparently not the case.

    My hr is 10 ns and my lr loop is 80 ns for 8 instructions, with the last one loop back to the first one. Any problem here? Otherwise why only 7 are available?

    The ECMP instruction has a toggle pin function, so the maximum output frequency that a pin can achieve is 100/8/2=6.25 MHz, am I right?

    I understand that I can not output 4 MHz because the divider is not an integer.

    Thanks!

  • Hello Chuck,

    The execution of a N2HET program begins with the first loop resolution clock, after the N2HET is turned on. At the first and subsequent occurrences of the loop resolution, the instruction at location address 00h is prefetched.

    N2HET programs must be written so that they complete execution and return to address 00h before the occurrence of the next loop resolution clock. If the N2HET program exceeds this execution time limit, then a program overflow condition occurs.

    My sentence is not accurate. One instruction may take more than 1 cycle. The program loop time is the sum of all cycles used for instruction execution. The last instruction of a program must branch back to 0x00. If the loop resolution is 8, the maximum instructions excluding the last BR instruction is 7.
  • Thank you.

    So the maximum allowable cycles count (some 1 cycle/instruction and some 2 cycles/instruction) of a N2HET program must be lower or equal to [loop resolution - 1].

    Regards.

  • my bad, it must be lower or equal to loop resolution.
  • That's was my understanding before.

    So the number of cycles must be lower or equal to the loop resolutions (lr), NOT lr-1.

    Regards :)