You will need to the I/O library
#include <stdio.h>
You will need to link printf to the USART
fdevopen((void*) Usart_Tx, (void*) Usart_Rx);
You will then need to provide the low level "get a byte to/from the USART
routines (called Usart_Tx and Usart_Rx above)
You will also need to init the USART to the correct baud rate.
You might want to get a copy of the AVR Butterfly demo program that was
ported to WinAVR and look at UART.h and UART.c for examples of Usart_TX,
Usart_Rx, and the USART init routine.
After that code like
unsigned char a = 0xA;
printf("\r\nThe value of a = %d", a);
will cause printf to produce the string "\r\nThe value of a = 10" and send
the string one character at a time to the low level routine Usart_Tx which
is responsible for sending the characters to the USART. An example of a
polled Usart_Tx routine is
void Usart_Tx(char data)
{
while (!(UCSRA & (1<<UDRE))); // Wait for the USART to become ready
UDR = data; // Put the character into
the Usart
}
-Mike
----- Original Message -----
From: "Mike" <k5atm@comcast.net>
To: <AVR-Chat@yahoogroups.com>
Sent: Wednesday, January 23, 2008 6:50 PM
Subject: Re: [AVR-Chat] Simple casting winavr
> You will need to the I/O library
> #include <stdio.h>
>
> You will need to link printf to the USART
> fdevopen((void*) Usart_Tx, (void*) Usart_Rx);
>
> You will then need to provide the low level "get a byte to/from the USART
> routines (called Usart_Tx and Usart_Rx above)
>
> You will also need to init the USART to the correct baud rate.
>
>
> You might want to get a copy of the AVR Butterfly demo program that was
> ported to WinAVR and look at UART.h and UART.c for examples of Usart_TX,
> Usart_Rx, and the USART init routine.
>
>
> -Mike
>
>
>
>
> ----- Original Message -----
> From: "Bryan Martin" <registration@myplaceinspace.com>
> To: <AVR-Chat@yahoogroups.com>
> Sent: Wednesday, January 23, 2008 6:04 PM
> Subject: [AVR-Chat] Simple casting winavr
>
>
>>I am attempting to move to C (winavr) from bascom for programming but
>> getting hung up on some fundamentals.
>>
>> Given the following
>>
>> unsigned char byte_in = 0xA;
>>
>> I need to print the decimal value to UART so I want to see 10. Similar
>> to
>> printf("%d", byte_in). Lord I hope this makes sense.
>>
>> Poor planning on your part does not constitute an emergency on my part.
>>
>>
>>
>>
>> Yahoo! Groups Links
>>
>>
>>
>
>
>
>
> Yahoo! Groups Links
>
>
>Message
Re: [AVR-Chat] Simple casting winavr -- oops, hit send too soon
2008-01-24 by Mike
Attachments
- No local attachments were found for this message.