打印

PSOC4 的SCB_UART中断出不来

[复制链接]
2850|11
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
gucen12|  楼主 | 2015-7-29 23:34 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式
CY_ISR(UART_SCB_IRQ_Interrupt)
{
    /*  Place your Interrupt code here. */
    /* `#START UART_SCB_IRQ_Interrupt` */


    UART_ClearRxInterruptSource(UART_INTR_RX_FULL);
   
    uint8 ch;
    ch = UART_SpiUartGetRxBufferSize();
    if(ch>0)
    {
        SP485_EN_Write(1);
        UART_UartPutChar(0x08);
    }

    /* `#END` */
}

这是中断函数的代码,进入中断的时候一直出不来。不知道是为什么,求大神指点一二。
沙发
gucen12|  楼主 | 2015-7-30 09:19 | 只看该作者
还没有大神帮忙吗:(

使用特权

评论回复
板凳
dsll2010| | 2015-7-30 17:07 | 只看该作者
你怎么判断程序卡在中断之中?

使用特权

评论回复
地板
gucen12|  楼主 | 2015-7-30 18:43 | 只看该作者
dsll2010 发表于 2015-7-30 17:07
你怎么判断程序卡在中断之中?

串口一直发送0x08

使用特权

评论回复
5
dsll2010| | 2015-7-31 11:51 | 只看该作者
gucen12 发表于 2015-7-30 18:43
串口一直发送0x08

那就不是卡在中断没出来,而是不停的在执行中断。请检查串口的中断触发条件是否是FIFO not empty,如果是清空FIFO。因为FIFO始终没有清空,所以不停的进入中断。

使用特权

评论回复
6
heping517| | 2015-7-31 23:17 | 只看该作者
楼主为什么要用发送中断呢

使用特权

评论回复
7
gucen12|  楼主 | 2015-8-5 15:16 | 只看该作者
heping517 发表于 2015-7-31 23:17
楼主为什么要用发送中断呢

是接收中断,用发送0x08看看是否一直在中断中循环。

使用特权

评论回复
8
gll123| | 2015-8-7 10:00 | 只看该作者
/* ========================================

*

* Copyright YOUR COMPANY, THE YEAR

* All Rights Reserved

* UNPUBLISHED, LICENSED SOFTWARE.

*

* CONFIDENTIAL AND PROPRIETARY INFORMATION

* WHICH IS THE PROPERTY OF your company.

*

* ========================================

*/



#include <project.h>

#include <stdio.h>

#if defined (__GNUC__)

        /* Add an explicit reference to the floating point printf library to allow




        the usage of floating point conversion specifier. */



        asm (".global _printf_float");

        /* For GCC compiler revise _write() function for printf functionality */

        int _write(int file, char *ptr, int len)



        {


                int i;

                for (i = 0; i < len; i++)



                {


                UART_UartPutChar(*ptr++);



                }


                return(len);



        }


#elif defined(__ARMCC_VERSION)




        /* For MDK/RVDS compiler revise fputc() function for printf functionality */

        struct __FILE

        {

                int handle;

        };

        enum

        {

                STDIN_HANDLE,

                STDOUT_HANDLE,

                STDERR_HANDLE

        };

        FILE __stdin = {STDIN_HANDLE};

        FILE __stdout = {STDOUT_HANDLE};

        FILE __stderr = {STDERR_HANDLE};

        int fputc(int ch, FILE *file)

        {

                int ret = EOF;

                switch(file->handle)

                {

                        case STDOUT_HANDLE:

                        SCB_UartPutChar(ch);

                        ret = ch;

                        break;

                        Document Number: 001-92486 Rev. *A Page 143 of 171

                        case STDERR_HANDLE:

                        ret = ch;

                        break;

                        default:

                        file = file;

                        break;

                }

                return(ret);

        }

#elif defined (__ICCARM__)

        /* For IAR compiler revise __write() function for printf functionality */

        size_t __write(int handle, const unsigned char * buffer, size_t size)

        {

                size_t nChars = 0;

                for (/* Empty */; size != 0; --size)

                {

                        SCB_UartPutChar(*buffer++);

                        ++nChars;

                }

                return (nChars);

        }



#endif /* (__GNUC__) */

CY_ISR(UART_SCB_IRQ_Interrupt)



{


    if(UART_GetRxInterruptSourceMasked() & UART_INTR_RX_NOT_EMPTY)



    {


        UART_UartPutString("Wel \r\n");



    }



    UART_SpiUartClearRxBuffer();


    UART_ClearRxInterruptSource(UART_INTR_RX_NOT_EMPTY);



}




//void MyIntHandler()

//{

//    UART_ClearRxInterruptSource(UART_INTR_RX_NOT_EMPTY);

//    //UART_ClearPendingInt();

//    UART_UartPutString("Wel\r\n");

//

//}




int main()



{


        uint32 i = 444444444;

        float f = 55.555f;

    char *s;

    //UART_SetCustomInterruptHandler(&MyIntHandler);





    isr_StartEx(UART_SCB_IRQ_Interrupt);


        UART_Start(); /* Start communication component */

        CyGlobalIntEnable; /* Enable interrupts */






        /* Use printf() function which will send formatted data through




        * UART (SCB mode) */






        UART_UartPutString("Welcome\r\n");

    sprintf(s, "%10.3f", 3.1415626);






    printf("Test printf function. long: %ld, float: %s \n",i,s);

        for(;;)



        {

        }

}








/* [] END OF FILE */







我给你的这个,是我自己测试过的,你拿过去测试一下,然后分析一下。

uart sch.jpg (549.94 KB )

uart sch.jpg

使用特权

评论回复
9
gll123| | 2015-8-7 10:06 | 只看该作者
你的中断入可函数写的有问题,你参考一下我的写~

使用特权

评论回复
10
gucen12|  楼主 | 2015-8-19 15:18 | 只看该作者
gll123 发表于 2015-8-7 10:06
你的中断入可函数写的有问题,你参考一下我的写~

谢谢了,能留个联系方式吗?以后还得向你讨教

使用特权

评论回复
11
gucen12|  楼主 | 2015-8-20 09:14 | 只看该作者
gll123 发表于 2015-8-7 10:06
你的中断入可函数写的有问题,你参考一下我的写~

谢谢已经通过测试。

使用特权

评论回复
12
gll123| | 2015-8-23 17:02 | 只看该作者
:)哈哈~测出来就好~

使用特权

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

本版积分规则

6

主题

17

帖子

2

粉丝