[ Log In ]
Serial to USB converter with Micro USB cable

USB to Serial Converter

$10.95
Qty:
Thumbnail: Crystal Oscillator 18.432 MHz for UART

18.432 MHz Crystal Oscillator 18pf 30ppm

$0.94
Qty:
Thumbnail: 22 pF Capacitor

22 pF Multilayer Ceramic Capacitor

$0.43
Qty:
Thumbnail: Quartz crystal oscillator - 16 MHz

16 MHz Crystal Oscillator 20 pF Through Hole

$0.75
Qty:
USB 2.0 Cable 10 Foot Type A Male to Type B Male

USB 2.0 Cable Type A Male to Type B Male - 10 FT

$4.80
Qty:
3 Foot USB Cable Type A to USB Cable Type A

USB Cable Type A Male to USB Type A Male - 3 FT

$2.65
Qty:
Tumbnail: 62 oz-in NEMA 17 Stepping motors (also called stepper motor)

NEMA 17 Stepping Motor (62 oz-in 5mm single shaft)

$19.95 Out of Stock
Qty:
Image of the Atmega324p

Atmega324P

$8.50
Qty:

10K timmer potentiometer

10K Trimmer Potentiometer (Through Hole)

$0.85
Qty:

Programming: UART/USART Creating a Receive Data Function (Specifically for a Library or Include File)

This is a function that is created for a library to be reused whenever the microcontroller needs to receive data from the UART/USART. The RXC is the Receive Complete Flag and lets us know when the receive is complete so we can get the data in the UDR (UART Data Register). The return type is unsigned char because we want the returned data in the positive realm of 0-255 so it conforms to the ASCII set of characters.

The 0's at the end of each register is used because the microcontroller has two USARTs.
unsigned char ReceiveUART0(void)
{
while (! (UCSR0A & (1 << RXC0)) );
return UDR0;
}

If the microcontroller only has one USART, then use the following code:

unsigned char ReceiveUART0(void)
{
while (! (UCSRA & (1 << RXC)) );
return UDR;
}

Comments and Additional Information

Have some code to share? Or additional information? Respond here:

You need to be logged in to save a response on this page. The response must be constructive, helpful, supplimentary or to correct the existing video, code or narrative content.

Description:

Code (optional):