Download Renesas Peripheral Driver Library User`s Manual (RX63N Group)

Transcript
RX63N 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 PCLKB 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 input and output pins */
R_TMR_Set(
0,
PDL_TMR_TMR0_TMO0_PB3
);
/* 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-19: Example of Pulse Output code
255
199
99
Counter
value
00
TMO0
Figure 5-20: Example of pulse output operation
R20UT1963EE0100 Rev.1.00
Jul 19, 2012
Page 414 of 487