Using multiple interrupts generated by PWMs, F28379D and c2000

4 views (last 30 days)
Hi- I'd like to generate two different clocks at different frequencies to call two different functions. How would I do this, from only using the one hardware interrupt block that is allowed?

Answers (1)

Aabha
Aabha on 24 Mar 2025
Two separate Hardware Interrupt blocks can be used to trigger two separate functions at different frequencies, as long as the interrupts of both the blocks are mapped to different ePWM triggers on the microcontroller. You can try the following steps to map the interrupts to ePWM events with different frequencies:
  1. Add ‘Hardware Interrupt’ and ePWM blocks, from the library of the microprocessor family that you will be using.
  2. Go to the ‘Block Parameters’ of the ‘Hardware Interrupt’ block and click on ‘Hardware Mapping’. This will open a new window for ‘Hardware Mapping, where the Hardware Interruptscan be mapped to their corresponding ePWM Trigger Events.
Please refer to the following example on ‘Asynchronous Scheduling’ for more information regarding the same:
Additionally, if you want to trigger two functions at different frequencies, using a single ‘Hardware Interrupt’ block, you can try the following steps:
  1. Configure the Hardware Interrupt block to trigger at the base clock frequency. This should be the highest frequency required by any of the functions.
  2. Use Counter blocks to count the number of interrupt occurrences and generate lower frequency clocks. For each function, implement a counter that resets after reaching a specific count threshold, effectively dividing the base clock frequency.
  3. Use the output of each counter to trigger the respective function call. When the counter reaches its threshold, it should reset and generate a pulse or signal to call the function.
For example, suppose you have a 1 kHz base clock, and you wish to create two additional clocks: one at 100 Hz, and another at 200 Hz. This can be done using two separate ‘Counter’ blocks. Set the first counter to reset after every 10 interrupts (1 kHz / 100 Hz = 10) and trigger the first function with its output. This will make sure that the function is triggered at a frequency of 100 Hz. Similarly, set the second counter to reset every 5 interrupts (1 kHz / 200 Hz = 5) which will trigger the second function at a frequency of 200Hz.
I hope this is helpful to you.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!