Tình hình là em đang làm vụ truyền dòng chữ lên PC từ atmega8. Mà nó không thèm truyền lên. Mọi người xem hộ mình cái code này vs.
PHP Code:
/*****************************************************
This program was produced by the
CodeWizardAVR V2.05.0 Professional
Automatic Program Generator
© Copyright 1998-2010 Pavel Haiduc, HP InfoTech s.r.l.
http://www.hpinfotech.com
Project : TRUYEN THONG UART VOI PC
Version : V1.0.0
Date : 10/7/2012
Author : Bui Trong Thien
Company : Khong biet phai mo
Comments:
- Truyen du lieu len PC.
Chip type : ATmega8
Program type : Application
AVR Core Clock frequency: 8.000000 MHz
Memory model : Small
External RAM size : 0
Data Stack size : 256
*****************************************************/
#include <main.h>
// Declare your global variables here
void main(void)
{
char Data;
char str[15];
// Declare your local variables here
// Input/Output Ports initialization
// Port B initialization
// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In
// State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T
PORTB=0x00;
DDRB=0x00;
// Port C initialization
// Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In
// State6=T State5=T State4=T State3=T State2=T State1=T State0=T
PORTC=0x00;
DDRC=0x00;
// Port D initialization
// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In
// State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T
PORTD=0x00;
DDRD=0x00;
// KHOI TAO USART
// Communication Parameters: 8 Data, 1 Stop, No Parity
// USART Receiver: On
// USART Transmitter: On
// USART Mode: Asynchronous
// USART Baud Rate: 9600
UCSRA=0x00;
UCSRB=0x98;
UCSRC=0x86;
UBRRH=0x00;
UBRRL=0x33;
// KHOI TAO LCD1602
// Connections specified in the
// Project|Configure|C Compiler|Libraries|Alphanumeric LCD menu:
// RS - PORTD Bit 4
// RD - PORTD Bit 3
// EN - PORTD Bit 2
// D4 - PORTB Bit 4
// D5 - PORTB Bit 5
// D6 - PORTB Bit 6
// D7 - PORTB Bit 7
// Characters/line: 16
// Global enable interrupts
#asm("sei") // Cho phep ngat toan cuc
lcd_init(16);
lcd_clear();
lcd_gotoxy(0,0);
lcd_puts("Chao Dai Ca");
sprintf(str,"Chao Dai Ca");
puts(str);
putchar(13);
sprintf(str,"ABCDEFG \n");
puts(str);
while (1)
{
Data = getchar();
if(Data)
{
lcd_gotoxy(0,1);
sprintf(str,"Ky tu: %c",Data);
lcd_puts(str);
}
delay_ms(1);
// Place your code here
}
}
// ------------------END OF FILE-------------------
// ------------------------------------------------