Microchip® Advanced Software Framework

usart_example2.c File Reference

USART example 2 application for AVR UC3 USART driver.

Copyright (c) 2014-2018 Microchip Technology Inc. and its subsidiaries.

#include "board.h"
#include "sysclk.h"
#include "usart.h"
#include "conf_example_usart.h"


int main (void)
 Application main loop. More...


static const usart_options_t usart_opt
 USART configuration options. More...

int main ( void  )

Application main loop.

the call to sysclk_init() will disable all non-vital peripheral clocks, except for the peripheral clocks explicitly enabled in conf_clock.h.

Enable the clock to the selected example USART peripheral module. The clocks to all non-essential peripherals are disabled in the conf_clock.h file, so we need to re-enable our USART clock here.

Write the example USART module configuration to the hardware registers. The example USART is selected in the conf_example_usart.h file.

Write a welcome message on the USART and busy-wait for the listener to press the enter key.

Busy-wait for a carriage return sent from the listener. Any received characters are echoed back.

Send a goodbye message before entering a forever non-return loop.

References board_init(), EXAMPLE_USART, sysclk_enable_peripheral_clock(), sysclk_get_peripheral_bus_hz(), sysclk_init(), USART_FAILURE, usart_get_echo_line(), usart_init_rs232(), and usart_write_line().

const usart_options_t usart_opt
Initial value:
= {
.channelmode = USART_NORMAL_CHMODE,
.charlength = 8,
.paritytype = USART_NO_PARITY,
.stopbits = USART_1_STOPBIT,
Don't use a parity bit.
Definition: usart.h:81
Normal communication.
Definition: usart.h:96
Use 1 stop bit.
Definition: usart.h:88

USART configuration options.

This struct contains the configuration options for the USART module in use by the example application.