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.

TMS570LS1224: N2HET + HTU : how to implement switching between different sine frequencies?

Part Number: TMS570LS1224
Other Parts Discussed in Thread: HALCOGEN

Hello,

Based on the Application Note https://www.ti.com/lit/an/spna217/spna217.pdf we succeeded in generating a Sine Wave on one of our HET pins.
We also succeeded in constantly toggling between periods of a sine wave with full amplitude and a similar sine wave with half amplitude using autoswitch. ( Buffers assigned via HTU buffer A and B).

What we would like to achieve is to be able to switch between different Sine Waves (slightly different frequencies) at zero crossings controlled by the cpu.

While trying this we are running into some challenges:

- to obtain sine waves with just slightly different frequencies, we created tables with a different amount of samples. However it does not seem to be possible to use the HTU with mixed different table lengths? (e.g. Buffer A with 128 samples, Buffer B with 120 samples). Is there a way to achieve this?

- How can we use a cpu signal to switch between sine waves on a zero crossing? Is there an interrupt available (e.g. at the point where the autoswitch can happen)? Is that fast enough to seamlessly switch over between two sines?

We are referring to the TMS570 techref manual and App notes 217 and 485.
If there are other useful related resources, we'd be happy to check them.

Thanks.

  • Hello Geert,

    You can adjust the frequency of the sine waves through:

    1. changing the PWM frequency: this can be achieved by changing the CNT_MAX_PERIOD. CNT_MAX_PERIOD is used by CNT instruction which is the first instruction of NHET code for this application note.

    2. changing the # of samples.

    Both can be changed dynamically. 

    The configiNHET1() function can be called to change the max number of CNT instruction:

    hetRAM1->Instruction[pHET_L00_0].Control = (uint32)(CNT_MAX_PERIOD - 1) |

    If you increase or decrease the number of samples, you need to reinitialize the HTU (frame count, and source address of DMA transfer).

  • Hello QJ,

    We tried your suggestion on the CNT_MAX_PERIOD. We see the frequency change, but due to changing the frequency at a random moment we don't get clean transitions from one wave to another.

    If we understand the TechRefManual correctly, it should be possible to trigger an interrupt from the HTU BFINTS register when CP A and CP B are finished reading.We could use this interrupt to either switch the CNT_MAX_PERIOD or we could also put CP A and B in autoswitch and replace the contents of both buffers one at a time using the interrupt to get a new frequency sine wave.

    However, we don't see where we can find an interrupt handler for this HTU BFINTS functionality? Can it be created in some way?

    Or is there a better approach to handle this?

  • Hello,

    The HTU transfer is triggered by the request from CNT (first instruction of NHET code) when counter reaches the PWM_PERIOD value. You can enable the HTU buffer full interrupt and change the PWM frequency in this interrupt handler.

    I don't have an example for handling the HTU interrupts.

  • Hi,

    We're trying to trigger an N2HET interrupt from the assembler code to see if that can be of use.

    In the assembler code we set IRQ_ON on instruction 1 (second line).

    In Halcogen on the tab page for HET2 we enabled an interrupt for the Address1. (HET1 is not used)
    We also enabled VIM channel 10 and 24 (HET hi and Lo).
    Is this correct for HET2?

    Because when compiling we get "unresolved symbol het1HighLevelInterrupt, first referenced in ./source/sys_vim.obj" and the same for LowLevelInterrupt

    The interrupt handlers are referenced but have not been created.
    An idea how we can solve this?
    Thank you.

  • In Halcogen on the tab page for HET2 we enabled an interrupt for the Address1. (HET1 is not used)
    We also enabled VIM channel 10 and 24 (HET hi and Lo).
    Is this correct for HET2?

    No. The VIM channel 63 and channel 73 are used for NHET2

    "unresolved symbol het1HighLevelInterrupt, first referenced in ./source/sys_vim.obj"

    Since NHET1 is not enabled, HAL doesn't generate code for NHET1 including the ISR het1HighLevelInterrupt() for NHET1 

    Please uncheck VIM channel 10 and 24, and check VIM 63 and 73, so HAL will generate het2HighLevelInterrupt(0 and het2LowLevelInterrupt().