Home > other >  Use UCOSIII STM32F4, counting semaphores cannot arouse the task STR has for the zero
Use UCOSIII STM32F4, counting semaphores cannot arouse the task STR has for the zero

Time:09-15

Use UCOSIII STM32F4, STR counting semaphores cannot arouse the task has been to 0

The process cannot access the task//RS485 communication task function
Void RS485_task (void * pdata)
{
OS_ERR err;
//CPU_SR_ALLOC ();
Pdata=https://bbs.csdn.net/topics/pdata;

While (1)
{
OSSemPend (& amp; OS_OPT_PEND_BLOCKING sem_RS485, 0, 0, & amp; Err);//request semaphore
Slave_Service ();//485 receive data processing
OSTimeDlyHMSM (0,0,0,5 OS_OPT_TIME_HMSM_STRICT, & amp; Err);//delay 2 ms
}
}

//send a semaphore
1//timer interrupt service routine
//TIM1_Init,84 (200-1-1)//20 ms interrupt
Void TIM3_IRQHandler (void)
{
If (TIM_GetITStatus (TIM3, TIM_IT_Update)==SET)//overflow interrupt
{
TIM_ClearITPendingBit (TIM3, TIM_IT_Update);//remove the interrupt flag bit

//TIM3_COUNT + +;
//if (TIM3_COUNT & gt;=10)//if more than 100 ms, complete receiving
{
RS485_RX_STA=1;//receive complete
OSSemPost (& amp; Sem_RS485 OS_OPT_POST_1, & amp; Err);//send a semaphore
//TIM3_COUNT=0;//data count reset
TIM_Cmd (TIM3, DISABLE);//off timer interrupt
}
}
}



  • Related