PSOC4 的SCB_UART中断出不来

[复制链接]
3287|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
dsll2010 发表于 2015-7-31 11:51 | 显示全部楼层
gucen12 发表于 2015-7-30 18:43
串口一直发送0x08

那就不是卡在中断没出来,而是不停的在执行中断。请检查串口的中断触发条件是否是FIFO not empty,如果是清空FIFO。因为FIFO始终没有清空,所以不停的进入中断。
heping517 发表于 2015-7-31 23:17 | 显示全部楼层
楼主为什么要用发送中断呢
 楼主| gucen12 发表于 2015-8-5 15:16 | 显示全部楼层
heping517 发表于 2015-7-31 23:17
楼主为什么要用发送中断呢

是接收中断,用发送0x08看看是否一直在中断中循环。
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 */







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

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

×
gll123 发表于 2015-8-7 10:06 | 显示全部楼层
你的中断入可函数写的有问题,你参考一下我的写~
 楼主| gucen12 发表于 2015-8-19 15:18 | 显示全部楼层
gll123 发表于 2015-8-7 10:06
你的中断入可函数写的有问题,你参考一下我的写~

谢谢了,能留个联系方式吗?以后还得向你讨教
 楼主| gucen12 发表于 2015-8-20 09:14 | 显示全部楼层
gll123 发表于 2015-8-7 10:06
你的中断入可函数写的有问题,你参考一下我的写~

谢谢已经通过测试。
gll123 发表于 2015-8-23 17:02 | 显示全部楼层
:)哈哈~测出来就好~
您需要登录后才可以回帖 登录 | 注册

本版积分规则

6

主题

17

帖子

2

粉丝
快速回复 在线客服 返回列表 返回顶部