📄 usart1.c
字号:
#define _USART1_H
#include "AT90CAN128.H"
uint8 rec_Buf[16];
uint8 volatile USART1_sendPosi =0;
uint8 volatile USART1_sendCount=0;
//UART1 initialize
// desired baud rate:9600
// actual baud rate:9615 (0.2%)
// char size: 8 bit
// parity: Disabled
void USART1_Init(void)
{
uint8 i;
UCSR1B = 0x00; //disable while setting baud rate
UCSR1A = 0x00;
UCSR1C = 0x06;
UBRR1L = 0x33; //set baud rate lo单片机内部晶振=8M
UBRR1H = 0x00; //set baud rate hi
UCSR1B = (1 << TXEN1) | (1 << TXCIE1);
}
void USART1_Begin_Send(void)
{
USART1_sendCount = 16;
USART1_sendPosi = 0;
UDR1 = rec_Buf[USART1_sendPosi++];
}
#pragma interrupt_handler USART1_TX_ISR:iv_USART1_TX
void USART1_TX_ISR(void)
{
if (USART1_sendPosi < USART1_sendCount)
UDR1 = rec_Buf[USART1_sendPosi++];
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -