RX13T MTU3-interrupt for simple PWM

Hi everybody,

I'm kind of stuck with trying to get a simple PWM out of P71/MTIOC3B with an RX13T,
and reading the hardware manual "R01UH0822EJ0100 Rev.1.00" didn't help me to get it working.

Below I describe what I was thinking and how I tried. Can someone help me to get it working, or
explain why it can't work?

Of course there is not a standard way to do this, as 19. Multi-Function Timer Pulse Unit 3 (MTU3c) says:

  1. PWM mode 1: MTIOC3A and MTIOC3C pins, with TGR3B and TGR3D used as buffer registers.
  2. PWM mode 2: not possible with MTU3
  3. Reset-synchronized PWM: 3-phase of positive and negative PWM waveforms: I don't want to loose MTU4.
  4. Complementary PWM mode with or without dead time output: looks too complicated for simple PWM.
  5. Brushless DC motor control setting: also looks too complicated for simple PWM.

Because I'm using PB7/MTIOC3C as RxD1-pin the obvious choice seemed to simulate PWM as follows:

  • TGR3B as compare match, init high, low on match and output on MTIOC3B.
  • TCNT3 as periodic counter, with TGR3C counter clear and interrupt on match.
    The interrupt would be used to stop TCNT3, reset it to get the init-value on MTIOC3B-pin, and restart.
  • Changing the duty-cycle could be done on the fly (with possible glitches) or in the interrupt routine.

Several problems had to be overcome, apart from the obvious PDR-bit to 1, PFS-function to 1 and PMR-bit to 1:

  1. Nothing happens on the pin as there is a MTU.TOERA-register disabling MTU3 and MTU4 output.
  2. Nothing happens on the pin as there is a POE.POECR2-register holding the pins in high-impedance state.

After setting a bit in the first and clearing a bit in the second register I got one change in output, as expected,
but no interrupt to get it back. When using high-toggle as MTIOC3B-setting I could verify that the counter was
reset by changing the TGR3C-setting to change the output frequency, but no interrupt.

At this moment I have no clue why the interrupt doesn't happen and the day I thought would be well enough
for getting it working has passed without the pin working as expected.

What did I do wrong, or is it just not possible with that pin?

  • Hi everybody,

    I've found out how to have a simple PWM on any of the MTU3- or MTU4-pins.
    Spending the weekend on testing all kinds of settings, the conclusion is that
    a single PWM or some combinations of multiple simple PWM's are possible in
    the following ways on the MTIOCxy-pins (x from 3 4) (y from A B C D):

    1. 3A, 3C, 4A, 4C: one or more by PWM mode 1
    2. 3B, 4A, 4B: reset-synchronized by enabling the needed pin in MTU.TOERA
    3. 3D, 4C, 4D: reset-synchronized by enabling the needed pin in MTU.TOERA,
      and MTU.TOCR1A and/or MTU.TOCR2A for specifying the active level as

    With solutions 2 and 3 there is only 1 period setting, as if it was PWM mode 2,
    in MTU3.TGRA, but the advantage is that no interrupt is needed for generating
    the PWM-output, so precision gains and less software-overhead during the PWM.

    When I described the problem above, I mistakenly assumed that interrupt vector
    number and interrupt priority vector number were the same, like in the
    RX600-/RX700-series, but the RX13T shares IPR-settings for TGIA and TGIV with
    other interrupt vectors of the respective MTU.

    The method I described above can be used to have PWM mode 2 on all MTIOC-pins
    of MTU0, MTU1 and MTU2, without another MTU for the period setting, as you can
    use interrupt TGI0E- or TGI0F-interrupt for that with the following interrupt-code:

    MTU.TSTRA.BYTE &=~7;//stop counters MTU0..2
    MTU0.TCNT=MTU1.TCNT=MTU2.TCNT=0;//clear counters to have initial MTIOC-pin setting
    MTU.TSTRA.BYTE |= 7;//restart counters MTU0..2

    The weekend gave me some time to answer my own question.

  • sir, iam confused with interrupt of MTU5. I want to blink an led using MTU5 @ 500 milliseconds..(just begining). please send me a blink software using any timer in rx13T. My mcu is R5F513T5ADFL by microsanju@gmail.com