打印
[STM8]

STM8S005K6无法进入串口中断?

[复制链接]
1436|3
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
MeiJor|  楼主 | 2014-10-14 11:20 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
如题,我的代码是调用STM提供的固件库,可不止为何进不了中断?
void main()
{
        CLK_Config();        //CLK 16MHz
        UART_Config();
//        motorInit();
//        initI2C();
//        initAFD();

//        LensInitial();
//        delayMs(100);

/* Enable general interrupts */
        enableInterrupts();   

while (1) {
//                hs_test();
        }
}

void UART_Config(void)
{
  /* Deinitializes the UART1 and UART3 peripheral */
    UART2_DeInit();
    /* UART1 and UART3 configuration -------------------------------------------------*/
    /* UART1 and UART3 configured as follow:
          - BaudRate = 9600 baud  
          - Word Length = 8 Bits
          - One Stop Bit
          - No parity
          - Receive and transmit enabled
          - UART1 Clock disabled
     */
    /* Configure the UART1 */
    UART2_Init((uint32_t)115200, UART2_WORDLENGTH_8D, UART2_STOPBITS_1, UART2_PARITY_NO,
                UART2_SYNCMODE_CLOCK_DISABLE, UART2_MODE_TXRX_ENABLE);

    /* Enable UART1 Transmit interrupt*/
//    UART2_ITConfig(UART2_IT_TXE, ENABLE);

                /* Enable UART1 Receive interrupt */
                UART2_ITConfig(UART2_IT_RXNE_OR, ENABLE);
               
                UART2_Cmd(ENABLE);
}

@far @interrupt void UART2_RX_IRQHandler(void)
{
    /* Read one byte from the receive data register */
    RxBuffer1[IncrementVar_RxCounter1()] = UART2_ReceiveData8();
                UART2_SendData8(IncrementVar_RxCounter1());

    if (GetVar_RxCounter1() == RxBufferSize1)
    {
                        /* Disable the UART1 Receive interrupt */
                        //UART2_ITConfig(UART2_IT_RXNE_OR, DISABLE);
                        clearReceBuf();
    }
}
INTERRUPT_HANDLER(UART2_RX_IRQHandler,21);

extern void _stext();     /* startup routine */

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, NonHandledInterrupt}, /* irq11 */
        {0x82, NonHandledInterrupt}, /* irq12 */
        {0x82, NonHandledInterrupt}, /* irq13 */
        {0x82, NonHandledInterrupt}, /* irq14 */
        {0x82, NonHandledInterrupt}, /* irq15 */
        {0x82, NonHandledInterrupt}, /* irq16 */
        {0x82, NonHandledInterrupt}, /* irq17 */
        {0x82, NonHandledInterrupt}, /* irq18 */
        {0x82, I2C_IRQHandler},                  /* irq19 */
        {0x82, NonHandledInterrupt}, /* irq20 */
        {0x82, UART2_RX_IRQHandler}, /* irq21 */
        {0x82, NonHandledInterrupt}, /* irq22 */
        {0x82, NonHandledInterrupt}, /* irq23 */
        {0x82, NonHandledInterrupt}, /* irq24 */
        {0x82, NonHandledInterrupt}, /* irq25 */
        {0x82, NonHandledInterrupt}, /* irq26 */
        {0x82, NonHandledInterrupt}, /* irq27 */
        {0x82, NonHandledInterrupt}, /* irq28 */
        {0x82, NonHandledInterrupt}, /* irq29 */
};


各位有遇到此种问题吗?麻烦指点啦,谢谢!

沙发
MeiJor|  楼主 | 2014-10-14 15:50 | 只看该作者
哎呀!!!
没人回答,估计是硬件问题了。

使用特权

评论回复
板凳
mmuuss586| | 2014-10-14 20:13 | 只看该作者
用示波器看下接收脚有无数据;
中断程序,判断下是什么中断;

使用特权

评论回复
地板
MeiJor|  楼主 | 2014-10-17 09:34 | 只看该作者
谢谢楼主回复!!!
原因是ARM的串口连接到STM8的串口,此时用PC端的串口发送数据给STM8,这时ARM串口做出相应从而导致STM8串口无法进入中断。也就是这三个串口不能同时互联操作。

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

2

主题

6

帖子

0

粉丝