TI中文支持网
TI专业的中文技术问题搜集分享网站

cc3200串口接收中断无法触发

TI的工程师,你们好

我使用了freertos,然后我期望串口中断的优先级是最高的,不会因为freertos而导致串口中断不被触发

我的做法是,

1、配置中断分组为3,也就是全部使用8个抢占优先级

2、配置串口中断为优先级0,也就是最高优先级

3、配置FREE RTOS最高可以使用的优先级为1,也就是0不属于FREE RTOS的管理范围,确保不会影响

但是在实际测试中发现,串口中断还是不能保证每次都触发,有时可以正常触发,但是经常性不能触发,有可能是什么原因呢?

代码片断如下

1、注册配置串口中断

UARTFIFODisable(UARTA0_BASE); IntPrioritySet(INT_UARTA0 , INT_PRIORITY_LVL_0); UARTIntStatus(UARTA0_BASE, false); UARTIntClear(UARTA0_BASE,UART_INT_RX); UARTIntRegister(UARTA0_BASE,uart_handle); UARTIntEnable(UARTA0_BASE,UART_INT_RX);

2FREE RTOS配置

#ifdef __NVIC_PRIO_BITS #define configPRIO_BITS __NVIC_PRIO_BITS #else #define configPRIO_BITS 3 /* 8 priority levels */ #endif /* The lowest interrupt priority that can be used in a call to a "set priority" function. */ #define configLIBRARY_LOWEST_INTERRUPT_PRIORITY 0x07 /* The highest interrupt priority that can be used by any interrupt service routine that makes calls to interrupt safe FreeRTOS API functions. DO NOT CALL INTERRUPT SAFE FREERTOS API FUNCTIONS FROM ANY INTERRUPT THAT HAS A HIGHER PRIORITY THAN THIS! (higher priorities are lower numeric values. */ #define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY 1 /* Interrupt priorities used by the kernel port layer itself. These are generic to all Cortex-M ports, and do not rely on any particular library functions. */ #define configKERNEL_INTERRUPT_PRIORITY ( configLIBRARY_LOWEST_INTERRUPT_PRIORITY << (8 – configPRIO_BITS) ) /* !!!! configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to zero !!!! See www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */ #define configMAX_SYSCALL_INTERRUPT_PRIORITY ( configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 – configPRIO_BITS) )

Alvin Chen:

直接在uart_demo那个例程上修改,试试看//*****************************************************************************
//
// Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
//
//
//Redistribution and use in source and binary forms, with or without
//modification, are permitted provided that the following conditions
//are met:
//
//Redistributions of source code must retain the above copyright
//notice, this list of conditions and the following disclaimer.
//
//Redistributions in binary form must reproduce the above copyright
//notice, this list of conditions and the following disclaimer in the
//documentation and/or other materials provided with the
//distribution.
//
//Neither the name of Texas Instruments Incorporated nor the names of
//its contributors may be used to endorse or promote products derived
//from this software without specific prior written permission.
//
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
//A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
//OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
//SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
//LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
//DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
//THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
//(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
//OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
//*****************************************************************************//*****************************************************************************
//
// Application Name- UART Demo
// Application Overview - The objective of this application is to showcase the
//use of UART. The use case includes getting input from
//the user and display information on the terminal. This
//example take a string as input and display the same
//when enter is received.
//
//*****************************************************************************//*****************************************************************************
//
//! \addtogroup uart_demo
// author: Alvin Chen
//! @{
//
//*****************************************************************************// Driverlib includes
#include "rom.h"
#include "rom_map.h"
#include "hw_memmap.h"
#include "hw_common_reg.h"
#include "hw_types.h"
#include "hw_ints.h"
#include "uart.h"
#include "interrupt.h"
#include "pinmux.h"
#include "utils.h"
#include "prcm.h"// Common interface include
#include "uart_if.h"//*****************************************************************************
//MACROS
//*****************************************************************************
#define APPLICATION_VERSION"1.4.0"
#define APP_NAME"UART Echo"
#define CONSOLEUARTA0_BASE
#define UartGetChar()MAP_UARTCharGet(CONSOLE)
#define UartPutChar(c)MAP_UARTCharPut(CONSOLE,c)
#define MAX_STRING_LENGTH80
unsigned char uartRxBuff[128];
unsigned int uartRxLength = 0;void Uart1IntHandler(void)
{unsigned long intStatus = MAP_UARTIntStatus(UARTA0_BASE, true);if((intStatus & UART_INT_RX) && MAP_UARTCharsAvail(UARTA0_BASE)){uartRxLength++;uartRxBuff[uartRxLength] = (unsigned char)MAP_UARTCharGetNonBlocking(UARTA0_BASE);MAP_UARTCharPut(UARTA0_BASE,uartRxBuff[uartRxLength]);}else if(intStatus & UART_INT_RT){uartRxBuff[0] = uartRxLength;uartRxLength = 0;}MAP_UARTIntClear(UARTA0_BASE, intStatus);
}//*****************************************************************************
//GLOBAL VARIABLES -- Start
//*****************************************************************************
volatile int g_iCounter = 0;#if defined(ccs)
extern void (* const g_pfnVectors[])(void);
#endif
#if defined(ewarm)
extern uVectorEntry __vector_table;
#endif
//*****************************************************************************
//GLOBAL VARIABLES -- End
//*****************************************************************************//*****************************************************************************
//LOCAL DEFINITION
//*****************************************************************************//*****************************************************************************
//
//! Application startup display on UART
//!
//! \paramnone
//!
//! \return none
//!
//*****************************************************************************
static void
DisplayBanner(char * AppName)
{Report("\n\n\n\r");Report("\t\t *************************************************\n\r");Report("\t\tCC3200 %s Application\n\r", AppName);Report("\t\t *************************************************\n\r");Report("\n\n\n\r");
}//*****************************************************************************
//
//! Board Initialization & Configuration
//!
//! \paramNone
//!
//! \return None
//
//*****************************************************************************
static void
BoardInit(void)
{
/* In case of TI-RTOS vector table is initialize by OS itself */
#ifndef USE_TIRTOS//// Set vector table base//
#if defined(ccs)MAP_IntVTableBaseSet((unsigned long)&g_pfnVectors[0]);
#endif
#if defined(ewarm)MAP_IntVTableBaseSet((unsigned long)&__vector_table);
#endif
#endif//// Enable Processor//MAP_IntMasterEnable();MAP_IntEnable(FAULT_SYSTICK);PRCMCC3200MCUInit();
}//*****************************************************************************
//
//! Main function handling the uart echo. It takes the input string from the
//! terminal while displaying each character of string. whenever enter command
//! is received it will echo the string(display). if the input the maximum input
//! can be of 80 characters, after that the characters will be treated as a part
//! of next string.
//!
//! \paramNone
//!
//! \return None
//!
//*****************************************************************************
void main()
{//// Initailizing the board//BoardInit();//// Muxing for Enabling UART_TX and UART_RX.//PinMuxConfig();//// Initialising the Terminal.//InitTerm();//// Clearing the Terminal.//ClearTerm();DisplayBanner(APP_NAME);MAP_UARTFlowControlSet(UARTA0_BASE, UART_FLOWCONTROL_NONE);MAP_UARTFIFODisable(UARTA0_BASE);MAP_UARTIntRegister(UARTA0_BASE, Uart1IntHandler);MAP_UARTIntEnable(UARTA0_BASE, UART_INT_RX|UART_INT_RT);MAP_IntPriorityGroupingSet(1);MAP_IntPrioritySet(INT_UARTA0,INT_PRIORITY_LVL_0);Message("\t\t****************************************************\n\r");Message("\t\t\tCC3200 UART Echo Usage\n\r");Message("\t\t Type in a string of alphanumeric characters and\n\r");Message("\t\t pressenter, the string will be echoed. \n\r") ;Message("\t\t Note: if string length reaches 80 character it will \n\r");Message("\t\t echo the string without waiting for enter command \n\r");Message("\t\t ****************************************************\n\r");Message("\n\n\n\r");Message("cmd#");while(1){}
}//*****************************************************************************
//
// Close the Doxygen group.
//! @}
//
//*****************************************************************************

user3676850:

回复 Alvin Chen:

我试了一下,把DOME的配置加进去后,跟我的代码现象一样
我发现似乎只有所有任务都阻塞的时候才能响应串口中断,当有任务占用CPU的时候就不响应了

Alvin Chen:

回复 user3676850:

我读了一下Free RTos论坛的帖子如下,感觉是需要设置ISR以及最高优先级任务为死锁的的。
www.freertos.org/…/freertos_High_priority_task_totally_blocks_lower_priority_one_even_with_taskYield_in_place_f2f1c4a6j.html

gaoyang9992006:

blog.csdn.net/…/80018288
参考这个思路试试

赞(0)
未经允许不得转载:TI中文支持网 » cc3200串口接收中断无法触发
分享到: 更多 (0)