I am trying to program ATmega8 for testing purposes using CVAVR as cross compiler and avrdude GUI as burner. Though I am able to burn the program, I think I am missing something in the coding part. It may be quite silly.
I have 2 questions:
I am using Xbee Pro for wireless communication. It works with 5V and my ATmega8 board, I think provided the required voltage. But there is no communication happening with the other Xbee Pro module attached to my laptop. I am using XCTU and have checked the baud rate and other settings. On the other hand, when I used a MAX 232 circuit and then communicate with my laptop using a Serial to USB converter, I was able to send data to my laptop on XCTU. I used
putchar("f")
; on the XCTU sometimes "." was getting printed and sometimes "K" (then I realized that it was junk).So I want to ask: is voltage causing problems with transmission?
In the coding part, when I am using MAX, I am using the following code:
x = getchar(); if(x == 97) { lcd_clear(); lcd_gotoxy(0,0); lcd_putsf("x"); PORTB = 0b00000001; delay_ms(300); } else { lcd_clear(); lcd_gotoxy(0,0); lcd_putsf("Shailendra Singh"); PORTB = 0b00000010; delay_ms(300); }
The rest of code and registers initialization is done by CVAVR itself but this is the code of main concern. What I want is that when I press "a" on my laptop, if operation must be performed but I am confused by
if(x == 97)
97 is the ASCII value of "a". Am I using it correctly by comparing x
with 97 (I assumed that when "a" is pressed).
Along with that with getchar()
, I can receive only one character, what if I want to receive a full string?