| 
 
| 大家好!我现在在使用MEGA48芯片,外部晶振是8M,希望串口波特率是9600, 我用ICCAVR软件,生产的设置代码,然后向PC的串口发送数据,实际效果是要1200才能正确收到数据。别人说是熔丝位的问题,也有人说不是。到底是哪里出了问题啊?请高人指点一下。谢谢!
 //UART0 初始化
 void uart0_init(int bps)
 {
 int  temp;
 temp=Fosc/bps/8-1;
 
 UCSR0B = 0x00; //disable while setting baud rate
 UCSR0A = 0x00;
 
 UBRR0L =temp;
 UBRR0H =(temp>>8);
 
 UCSR0C = 0x06;
 UCSR0A = 0x02; //enable    2倍波特率
 UCSR0B = 0x98;
 }
 //call this routine to initialize all peripherals
 void init_devices(void)
 {
 //stop errant interrupts until set up
 CLI(); //disable all interrupts
 port_init();
 uart0_init();
 
 MCUCR = 0x00;
 
 SEI(); //re-enable interrupts
 //all peripherals are now initialized
 
 }
 | 
 |