|
STM8S003F3P6串口无法进入接收中断,定时器中断是可以进入的。
[复制链接]
2芯积分
恳请大家半个忙,解决这个问题,困扰我一段时间了!
一、串口配置如下:
void Uart1Init()
{
UART1_CR2=0x00;//使发送禁用TEN=0;
UART1_CR1=0x00;//设置M字长,8位数据位
UART1_CR3=0x00;//1位停止位
UART1_BRR2=0x02;
UART1_BRR1=0x68;
UART1_CR2|=0x2C;//0x08 0x2c
}
二、中断服务函数
@far @interrupt void UART1RECE_Intterupt(void)
{
RxBuffer=UART1_DR;//Store the received byte in RxBuffe
if(RxBuffer==0x45)
{
//PC_ODR&=0xdf;
UartCompleteFlag=1;
//UartGetdata=0x37;
}
if(RxBuffer==0x46)
{
UartCompleteFlag=0;
//PC_ODR|=0x20;
//UartGetdata=0x82;
}
//UartGetdata=0x95;
return;
}
三、中断向量号
struct interrupt_vector const _vectab[] =
{
{0x82, (interrupt_handler_t)_stext}, /* reset */
{0x82, NonHandledInterrupt}, /* trap */
{0x82, NonHandledInterrupt}, /* irq0 */
{0x82, NonHandledInterrupt}, /* irq1 */
{0x82, NonHandledInterrupt}, /* irq2 */
{0x82, NonHandledInterrupt}, /* irq3 */
{0x82, NonHandledInterrupt}, /* irq4 */
{0x82, NonHandledInterrupt}, /* irq5 */
{0x82, NonHandledInterrupt}, /* irq6 */
{0x82, NonHandledInterrupt}, /* irq7 */
{0x82, NonHandledInterrupt}, /* irq8 */
{0x82, NonHandledInterrupt}, /* irq9 */
{0x82, NonHandledInterrupt}, /* irq10 */
{0x82, TIM1_Intterupt}, /* irq11 */
{0x82, NonHandledInterrupt}, /* irq12 */
{0x82, NonHandledInterrupt}, /* irq13 */
{0x82, NonHandledInterrupt}, /* irq14 */
{0x82, NonHandledInterrupt}, /* irq15 */
{0x82, NonHandledInterrupt}, /* irq16 */
{0x82, NonHandledInterrupt}, /* irq17 */
{0x82, UART1RECE_Intterupt}, /* irq18 */
{0x82, NonHandledInterrupt}, /* irq19 */
{0x82, NonHandledInterrupt}, /* irq20 */
{0x82, NonHandledInterrupt}, /* irq21 */
{0x82, NonHandledInterrupt}, /* irq22 //ADC_Intterupt},*/
{0x82, TIM4_Intterupt}, /* irq23 //TIM4_Intterupt},*/
{0x82, NonHandledInterrupt}, /* irq24 */
{0x82, NonHandledInterrupt}, /* irq25 */
{0x82, NonHandledInterrupt}, /* irq26 */
{0x82, NonHandledInterrupt}, /* irq27 */
{0x82, NonHandledInterrupt}, /* irq28 */
{0x82, NonHandledInterrupt}, /* irq29 */
};
四、时钟配置
void CLK_Init(void)
{
CLK_CKDIVR = 0x00;
//CLK_PCKENR1=0xff;
//CLK_PCKENR2=0xff;
}
以上,请大家帮忙,解解,万分感谢!
|
|