NerdKits - electronics education for a digital generation

You are not logged in. [log in]

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
banerjen's Avatar

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,
_FDEV_SETUP_RW);

stdin = stdout = &uart_stream;

while(1)

{

pc_read();

}

}

Thanks.

Nandan.

December 28, 2009
by hevans
(NerdKits Staff)

hevans's Avatar

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
banerjen's Avatar

Thanks a lot Humberto. It worked just fine.

Nandan.

Post a Reply

Please log in to post a reply.

Did you know that you can build a circuit to convert the "dit" and "dah" of Morse code back into letters automatically? Learn more...