Guten Tag, ich fange gerade an mich mit Uart zu beschäftigen dazu habe ich mir die Libary von Flury geholt und folgenden Versuch gemacht, allerdings stehe ich jetzt auf dem Schlauch, wie kann ich meinen Variablen Inhalt von x richtig senden ? vielleicht kann mir bitte jemand weiter helfen. also das Problem ist wie im Bild bekomme ich nur lauter Nullen angezeigt.
1 | /*************************************************************************
|
2 | Title: Example program for the Interrupt controlled UART library
|
3 | Author: Peter Fleury <pfleury@gmx.ch> /peterfleury
|
4 | File: $Id: test_uart.c,v 1.7 2015/01/31 17:46:31 peter Exp $
|
5 | Software: AVR-GCC 4.x
|
6 | Hardware: AVR with built-in UART/USART
|
7 | |
8 | DESCRIPTION:
|
9 | This example shows how to use the UART library uart.c
|
10 | |
11 | *************************************************************************/
|
12 | #include <stdlib.h> |
13 | #include <avr/io.h> |
14 | #include <avr/interrupt.h> |
15 | #include <avr/pgmspace.h> |
16 | |
17 | #define F_CPU 16000000
|
18 | |
19 | #include "uart.h" |
20 | |
21 | |
22 | /* define CPU frequency in Hz in Makefile */
|
23 | #ifndef F_CPU
|
24 | #error "F_CPU undefined, please define CPU frequency in Hz in Makefile"
|
25 | #endif
|
26 | |
27 | /* Define UART buad rate here */
|
28 | #define UART_BAUD_RATE 9600
|
29 | |
30 | |
31 | int main(void) |
32 | {
|
33 | |
34 | uint8_t x = 1024; |
35 | |
36 | char buffer[7]; |
37 | |
38 | |
39 | uart_init(UART_BAUD_SELECT(UART_BAUD_RATE,F_CPU) ); |
40 | sei(); |
41 | |
42 | |
43 | while (1) |
44 | {
|
45 | |
46 | itoa( x, buffer, 10); // convert interger into string (decimal format) |
47 | uart_puts(buffer); // and transmit string to UART |
48 | |
49 | |
50 | }
|
51 | |
52 | |
53 | |
54 | }
|