Renesas Solution Starter Kit for RX23W
R20UT4449EG0100 Rev. 1.00
Page 58 of 64
Aug.30.19
while
(1U)
{
uint16_t adc_result;
/* Wait for user requested A/D conversion flag to be set (SW1 or SW2) */
if
(TRUE
==
g_adc_trigger)
{
/* Call the function to perform an A/D conversion */
adc_result
=
get_adc();
/* Display the result on the LCD */
lcd_display_adc(adc_result);
/* Increment the gs_adc_count and display using the LEDs */
if
(16
==
(
++
gs_adc_count))
{
gs_adc_count
=
0;
}
led_display_count(gs_adc_count);
/* Send the result to the UART */
uart_display_adc(gs_adc_count, adc_result);
/* Reset the flag */
g_adc_trigger
=
FALSE;
}
else
{
/* do nothing */
}
}
}
Then, add the following function definition at the end of the file:
/******************************************************************************
* Function Name : led_display_count
* Description : Converts count to binary and displays on 4 LEDS0-3
* Argument : uint8_t count
* Return value : none
******************************************************************************/
static
void
led_display_count (
const
uint8_t count)
{
/* Set LEDs according to lower nibble of count parameter */
LED0 = (uint8_t)((count & 0x01) ? LED_ON : LED_OFF);
LED1 = (uint8_t)((count & 0x02) ? LED_ON : LED_OFF);
LED2 = (uint8_t)((count & 0x04) ? LED_ON : LED_OFF);
LED3 = (uint8_t)((count & 0x08) ? LED_ON : LED_OFF);
}
/******************************************************************************
* End of function led_display_count
******************************************************************************/
Select ‘Build Project’ from the ‘Project’ menu, or use the
button. e
2
studio will build the project with no
errors.
The project may now be run using the debugger as described in §6. The code will perform the same but now
the LEDs will display the gs_adc_count in binary form.
Содержание RSSK
Страница 64: ...R20UT4449EG0100 RX23W Group ...