NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.
Microcontroller Programming » Trouble in sending information in UART
December 27, 2009 by banerjen |
Hi, I am having trouble in sending data by PuTTY to the microcontroller. The reverse works fine (i.e, I'm able to receive data from the microcontroller). I used the uart.h functions to receive the data on the microcontroller. Instead of printing something valid, the LCD is print gibberish. Code : #define F_CPU 14745600 #include <stdio.h> #include <math.h> #include <avr/io.h> #include <avr/interrupt.h> #include <avr/pgmspace.h> #include "../libnerdkits/lcd.h" #include "../libnerdkits/uart.h" char tc; pc_read() { tc = uart_read(); lcd_write_nibble(tc); } main() { lcd_init(); FILE lcd_stream = FDEV_SETUP_STREAM(lcd_putchar, 0, _FDEV_SETUP_WRITE); lcd_write_string(PSTR(" PC CONTROL ")); uart_init(); FILE uart_stream = FDEV_SETUP_STREAM(uart_putchar, uart_getchar, stdin = stdout = &uart_stream; while(1) {
} } Thanks. Nandan. |
---|---|
December 28, 2009 by hevans (NerdKits Staff) |
Hi Nandan, I think you want to use lcd_write_data() instead of lcd_write_nibble(). lcd_write_nibble is used by lcd_write_data to set up the LCD to accept data, and then send the character. Let us know if that fixes it! Humberto |
January 20, 2010 by banerjen |
Thanks a lot Humberto. It worked just fine. Nandan. |
Please log in to post a reply.
Did you know that LEDs (light emitting diodes) only conduct current in one direction, like normal diodes? Learn more...
|