在线时间0 小时
UID249938
ST金币0
蝴蝶豆0
注册时间2010-11-26
新手上路
- 最后登录
- 1970-1-1
|
a0a.1 0b0c
我的板子是STM8S系列,发送我采用轮询方式,可以正常发送,接收采用轮询方式,也可以正常接收;但是接收我采用中断方式,不能进入中断。现将我的代码贴出来,希望大家指教下
初始化UART1:
void UART1_Init(u8 nData_Bit, u8 nStop_Bit, u16 nUart_BRR1, u16 nUart_BRR2)
{
u32 nUartDiv = 0x0;
//初始化UART1寄存器
UART1->SR = 0xc0;
UART1->DR = 0x0;
UART1->BRR1 = 0x0;
UART1->BRR2 = 0x0;
UART1->CR1 = 0x0;
UART1->CR2 = 0x0;
UART1->CR3 = 0x0;
UART1->CR4 = 0x0;
UART1->CR5 = 0x0;
UART1->GTR = 0x0;
UART1->SCR = 0x0;
//配置UARTDIV(波特率)
UART1->BRR1 = nUart_BRR1;
UART1->BRR2 = nUart_BRR2;
IRQ_SetSoftPriority(18, ITC_IRQ_SOFT_PRIORITY_2);
//UART1->CR2 = 0x2c;//允许发送和接收,能够产生接收中断
UART1->CR2 = 0x0c;
UART1->CR1 |= nData_Bit CR3 |= nStop_Bit CR1 |= 0x0 DR;
UART1_SendBit((uc8)uRevBit);
}
主函数:
void main(void)
{
IRQ_Init();
//LED_Init();
//KEY_Init();
//BEEP_Init(BEEP_FREQUENCY_1KHZ);
CLK_Init();
UART1_Init(DATA_BIT8, STOP_BIT1, BAND_RATE_9600_BRR1, BAND_RATE_9600_BRR2);
while (1);
} |
|