Usage example
Start conversion digital input to analog signal from 0x00. Add 0x10 to digital input at fixed interval. Stop conversion when digital input becomes 0xFF.
[GUI setting example]
D/A convertor |
Used | |||
DAC |
Used | |||
DAC0 |
||||
D/A convertor operation setting |
Used | |||
D/A convertor operation setting |
Normal mode | |||
Analog output (ANO0) |
Used | |||
Conversion value |
0x00 |
Timer |
Used | |||
TAU0 |
Used | |||
Channel0 |
||||
channel 0 |
Interval timer | |||
Interval value (16 bits) |
100ms (Actual value:100) | |||
Generates INTTM00 when counting is started |
Unused | |||
End of timer channel 0 count, generate an interrupt (INTTM00) |
Used | |||
Priority (INTTM00) |
Low |
[API setting example]
r_main.c
void main(void)
{
R_MAIN_UserInit();
/* Start user code. Do not edit comment generated here */
/* Start TAU0 channel 0 counter */
R_TAU0_Channel0_Start();
/* Enable the DA converter channel 0 */
R_DAC0_Start();
while (1U)
{
;
}
/* End user code. Do not edit comment generated here */
}
r_cg_timer_user.c
/* Start user code for include. Do not edit comment generated here */
#include "r_cg_dac.h"
/* End user code. Do not edit comment generated here */
/* Start user code for global. Do not edit comment generated here */
volatile uint16_t g_dac0_value = _00_DA0_CONVERSION_VALUE;
/* End user code. Do not edit comment generated here */
static void __near r_tau0_channel0_interrupt(void)
{
/* Start user code. Do not edit comment generated here */
g_dac0_value += 0x0010U;
if (g_dac0_value <= 0x00FFU)
{
/* Set the DA converter channel 0 value */
R_DAC0_Set_ConversionValue((uint8_t)g_dac0_value);
}
else
{
/* Stop the DA converter channel 0 */
R_DAC0_Stop();
/* Stop TAU0 channel 0 counter */
R_TAU0_Channel0_Stop();
}
/* End user code. Do not edit comment generated here */
}