Only some AVR models (ATmega128, ATmega1281 and a few more others) support serial programming via USART. All other AVRs including ATmega16 are using SPI for serial programming, unless you are talking about serial bootloader, which is actually accomplished by USART.
I mean, I connected my ATMega16 board with my AVR programmer board (there're two ATTiny 2313 on that), besides the AVR programmer also provide serial communication trought USB. I tested the serial communication between my ATMega16 and my laptop through the AVR programmer and it works using the following code
Code:
char uart_rd;
void main() {
UART1_Init(9600); // Initialize UART module at 9600 bps
Delay_ms(100); // Wait for UART module to stabilize
while (1) { // Endless loop
if (UART1_Data_Ready()) { // If data is received,
uart_rd = UART1_Read(); // read the received data,
UART1_Write(uart_rd); // and send data via UART
}
}
}
how it works?
every I press a character on the keyboard, the character shown on the hyperterminal screen. So it means, both my ATMega16 board and also the program has no problem, right?
What compiler are you using? Normally this is no initialization code but initialization routine call, unless your compiler has build up functions like this one which takes care of USART initialization.
I'm using mikroC for AVR
In general I would suggest the following:
If you have other signals on your RXD pin, remove them and keep only RXD signal on it. See with the osciloscope your RXD pin on ATmega16. When PC sends, then you should see digital signal on that pin. If you see the signal and has a good voltage level too, then hardware is OK and you should deal with your program. If not, then going backwards (R1OUT->R1IN->DB9.pin3) you should spot the problem.
Hope that helped.
the RXD pin is save, no other signals connected to it. I tested the pin and there's no voltage level come out (I use voltmeter to test it). I think the problem is on the hardware, but I don't know yet what is the problem.
UPDATE
I tested again, I checked the V+ pin, it gives me +8V and the V- gives me -8V
Then when I give +5V on T1in pin, then the T1out gives me -8V, and it gives me +8V for +5V in T1in.
it is the correct voltage level right?
but still, no responding when connected to PC