本帖最后由 ningling_21 于 2014-6-4 19:36 编辑
明显程序有问题...
外部晶振8MHZ ....MEGA128
以下程序正常运行...
- /***************串口0初始化********************/
- void uart0_init(void)
- {
- UCSR0B = 0x00; //disable while setting baud rate
- UCSR0A = 0x00;
- UCSR0C = 0x06;
- //UBRR0L = 0x47; //baud rate=9600
- UBRR0L = 0x33;
- UBRR0H = 0x00; //
- UCSR0B = 0x98;
- }
- /**************发送采用查询方式**************/
- void uart0_send(uchar c)
- {
- while( !(UCSR0A & (1<<UDRE0)) );
- UDR0=c;
- }
|