User`s manual
RX62N Group, RX621 Group 5. Usage Examples
5.8. 8-bit Timer
5.8.1. Periodic operation
Timer channel 0 is configured to provide pulses on pin TMO0, with a pulse width of 500µs and an on-time of
200µs.
/* Peripheral driver function prototypes */
#include "r_pdl_tmr.h"
#include "r_pdl_cgc.h"
#include "r_pdl_intc.h"
/* RPDL device-specific definitions */
#include "r_pdl_definitions.h"
void main(void)
{
/* Initialise the system clocks */
R_CGC_Set(
12.0E6,
96E6,
48E6,
24E6,
PDL_CGC_BCLK_HIGH
);
/* Set the CPU’s Interrupt Priority Level to 0 */
R_INTC_Write(
PDL_INTC_REG_IPL,
0
);
/* Configure TMR0 for 500µs period, 200µs pulsewidth */
R_TMR_CreatePeriodic(
PDL_TMR_TMR0,
PDL_TMR_PERIOD | PDL_TMR_OUTPUT_HIGH,
500E-6,
200E-6,
PDL_NO_FUNC,
PDL_NO_FUNC,
0
);
/* Re-configure, using frequency (2MHz) and duty cycle (40%) */
R_TMR_CreatePeriodic(
PDL_TMR_TMR0,
PDL_TMR_FREQUENCY | PDL_TMR_OUTPUT_HIGH,
2E6,
40,
PDL_NO_FUNC,
PDL_NO_FUNC,
0
);
}
Figure 5-13: Example of Pulse Output code
R20UT0084EE0112 Rev.1.12 Page 5-28
July. 16, 2014