guoguiwu wrote on Wednesday, February 19, 2014:
I transplant FreeRTOS to the HT32 that a chip like STM32. I want use UART interrupt to receive some data, but when the routine run to the UART interrupt routine it can not jump out the interrupt routine ,it just run the interrupt routine over and over. What’s the problem?
That a part of my config in FreeRTOS.h:
#define configKERNEL_INTERRUPT_PRIORITY 255
#define configMAX_SYSCALL_INTERRUPT_PRIORITY 191
#define configUSE_MUTEXES 1
#define configUSE_COUNTING_SEMAPHORES 1
And a part of my code:
void NVIC_Configuration(void)
{
NVIC_SetVectorTable(NVIC_VECTTABLE_FLASH, 0x0);
NVIC_SetPriorityGrouping(NVIC_PRIORITY_GROUP_3);// Preemption: 4 bits / Subpriority: 0 bits
NVIC_SetPriority(USART1_IRQn, NVIC_EncodePriority(NVIC_PRIORITY_GROUP_3, 12, 0));
}
xSemaphoreHandle xhighSemaphore;
void vultrasonic_Task(void *pvParameters)
{
char i=0;
char HDATA=0;
char LDATA=0;
u16 high;
xhighSemaphore = xSemaphoreCreateCounting( 10, 0 );
while(1)
{
USART_SendData(USART1,0x55 );
xSemaphoreTake( xhighSemaphore, 500 / portTICK_RATE_MS );
if(i==0)
{
HDATA=USART_ReceiveData(USART1);
i++;
return;
}
if(i==1)
{
LDATA=USART_ReceiveData(USART1);
i–;
high=(HDATA<<8)+LDATA;
printf(“high=%d\r\n”,high);
}
vTaskDelay( 1000 / portTICK_RATE_MS );
}
}
void USART1_IRQHandler(void)
{
static portBASE_TYPE xHigherPriorityTaskWoken;
xHigherPriorityTaskWoken = pdFALSE;
xSemaphoreGiveFromISR( xhighSemaphore, &xHigherPriorityTaskWoken );
portEND_SWITCHING_ISR(xHigherPriorityTaskWoken );
}