我正在尝试通过 Attiny167 的 uart 以 57600 的波特率在中断模式下获取数据,但是当我调试程序时,我只收到并且没有收到数据CR
,LF
为什么它会在下面的控制器中发生是我的代码:
#define CPU_CLOCK_FREQ 8000000UL
#define SAMPLES_PER_BIT 8
#define BAUD_RATE 57600
ISR(LIN_TC_vect)
{
cli();
temp=LINDAT;
buff[i]=temp;
i++;
sei();
}
void USARTInit()
{
DDRA = 0x02; // Port A Rx / Tx as input / output for PIN0 and PIN1
/* Set PORTB as input from FACS MAin BOX on PIN0 and PIN1 , initially high */
DDRB = 0x00;
PORTB= 0xFF;
/* Set samples per bit and UART baud */
LINBTR = (1 << LDISR) | SAMPLES_PER_BIT;
LINBRR = (((CPU_CLOCK_FREQ) / SAMPLES_PER_BIT) / BAUD_RATE) - 1;
/* Configure LIN UART in UART mode */
LINCR = (1 << LENA) | (1 << LCMD0) | (1 << LCMD1) | (1 << LCMD2);
// enable transmit and recieve interrupts for LIN/UART transfer
LINENIR = (1 << LENRXOK);
sei();
}
请帮忙。