User`s manual
RX62N Group, RX621 Group 5. Usage Examples
For full flexibility, the R_TMR_CreateChannel() function can be used.
In this example, Timer channel 0 is configured to provide pulses on pin TMO0, with a pulse width of 200 ticks of
PCLK and a duty cycle of 50%.
Note that the output transitions and counter clearing occur after the compare match has occurred. So the values
for compare match A and compare match B should be 1 less than the required count.
/* Peripheral driver function prototypes */
#include "r_pdl_tmr.h"
#include "r_pdl_definitions.h"
void main(void)
{
/* Configure TMR0 to clear on a compare match A, output 1 at a compare match A and output
0 at a compare match B */
R_TMR_CreateChannel(
0,
PDL_TMR_CLK_PCLK_DIV_1 | PDL_TMR_CLEAR_CM_A,
PDL_TMR_OUTPUT_HIGH_CM_A | PDL_TMR_OUTPUT_LOW_CM_B,
0,
(200 – 1),
(200 / 2) – 1,
PDL_NO_FUNC,
PDL_NO_FUNC,
PDL_NO_FUNC,
0
);
}
Figure 5-14: Example of Pulse Output code
Figure 5-15: Example of pulse output operation
255
199
99
00
Counter
value
TMO0
R20UT0084EE0112 Rev.1.12 Page 5-29
July. 16, 2014