Renesas Solution Starter Kit for RX23W
R20UT4449EG0100 Rev. 1.00
Page 51 of 64
Aug.30.19
/******************************************************************************
* Function Name : get_adc
* Description : Reads the ADC result, converts it to a string and displays
* it on the LCD panel.
* Argument : none
* Return value : uint16_t adc value
******************************************************************************/
static
uint16_t get_adc (
void
)
{
/* A variable to retrieve the adc result */
uint16_t adc_result = 0;
/* Start a conversion */
R_Config_S12AD0_Start();
/* Wait for the A/D conversion to complete */
while (FALSE == g_adc_complete)
{
/* Wait */
nop();
}
/* Stop conversion */
R_Config_S12AD0_Stop();
/* Clear ADC flag */
g_adc_complete = FALSE;
R_Config_S12AD0_Get_ValueResult(ADCHANNEL0, &adc_result);
return
(adc_result);
}
/******************************************************************************
* End of function get_adc
******************************************************************************/
/******************************************************************************
* Function Name : lcd_display_adc
* Description : Converts adc result to a string and displays
* it on the LCD panel.
* Argument : uint16_t adc result
* Return value : none
******************************************************************************/
static
void
lcd_display_adc (
const
uint16_t adc_result)
{
/* Declare a temporary variable */
uint8_t a;
/* Declare temporary character string */
char
lcd_buffer[11]
=
" ADC: XXXH"
;
/* Convert ADC result into a character string, and store in the local.
Casting to ensure use of correct data type. */
a
=
(uint8_t)((adc_result
&
0x0F00)
>>
8);
lcd_buffer[6]
=
(
char
)((a
<
0x0A)
?
(a
+
0x30) : (a
+
0x37));
a
=
(uint8_t)((adc_result
&
0x00F0)
>>
4);
lcd_buffer[7]
=
(
char
)((a
<
0x0A)
?
(a
+
0x30) : (a
+
0x37));
a
=
(uint8_t)(adc_result
&
0x000F);
lcd_buffer[8]
=
(
char
)((a
<
0x0A)
?
(a
+
0x30) : (a
+
0x37));
/* Display the contents of the local string lcd_buffer */
R_LCD_Display(3, (uint8_t
*
)lcd_buffer);
}
/******************************************************************************
* End of function lcd_display_adc
******************************************************************************/
Содержание RSSK
Страница 64: ...R20UT4449EG0100 RX23W Group ...