📜  uart 中断 - 任何代码示例

📅  最后修改于: 2022-03-11 14:57:31.940000             🧑  作者: Mango

代码示例1
#include 
#include 
#include  
#ifndef F_CPU
//define cpu clock speed if not defined
#define F_CPU 3686400
#endif
//set desired baud rate
#define BAUDRATE 19200
//calculate UBRR value
#define UBRRVAL ((F_CPU/(BAUDRATE*16UL))-1)
void USART_Init()
{
    //Set baud rate
    UBRRL=UBRRVAL;      //low byte
    UBRRH=(UBRRVAL>>8);   //high byte
    //Set data frame format: asynchronous mode,no parity, 1 stop bit, 8 bit size
    UCSRC=(1<