system
(system)
June 7, 2017, 2:46am
1
ramawidi wrote on Wednesday, June 07, 2017 :
Hi, I want to combine the interrupt timer on STM32F4 Discovery with FreeRTOS task. But unfortunatelly the task is not executed, but when I disable my interrupt timer the task is works well. Does anyone know why this is happend?
Regards
Rama
htibosch
(Hein Tibosch)
June 7, 2017, 9:39am
2
heinbali01 wrote on Wednesday, June 07, 2017 :
Would you mind to show some of the source code? Both of the “interrupt timer”, as well as the task that doesn’t run
system
(system)
June 8, 2017, 6:04am
3
ramawidi wrote on Thursday, June 08, 2017 :
Hi there, here is the code for my Interrupt Timer
void TIM2_Config(){
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
RCC_PCLK1Config(RCC_HCLK_Div16);
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2,ENABLE);
TIM_TimeBaseStructure.TIM_Prescaler = 42000-1;
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
TIM_TimeBaseStructure.TIM_Period = 200-1;
TIM_TimeBaseStructure.TIM_ClockDivision = TIM_CKD_DIV1;
TIM_TimeBaseStructure.TIM_RepetitionCounter = 0;
TIM_TimeBaseInit(TIM2,&TIM_TimeBaseStructure);
TIM_Cmd(TIM2,ENABLE);
}
void TIM_IT_Enable(){
TIM_ITConfig(TIM2,TIM_IT_Update, ENABLE);
}
void NVIC_Config(){
NVIC_InitTypeDef NVIC_InitStrurture;
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_0);
NVIC_InitStrurture.NVIC_IRQChannel = TIM2_IRQn;
NVIC_InitStrurture.NVIC_IRQChannelPreemptionPriority = 0x00;
NVIC_InitStrurture.NVIC_IRQChannelSubPriority = 0x00;
NVIC_InitStrurture.NVIC_IRQChannelCmd =ENABLE;
NVIC_Init(&NVIC_InitStrurture);
}
int nInterrupt=0,counter;
char buffer[32];
char buf_tmp[32];
void TIM2_IRQHandler(){
if(TIM_GetITStatus(TIM2,TIM_IT_Update)!=RESET){
TIM_ClearITPendingBit(TIM2,TIM_IT_Update);
//counter=TIM_GetCounter(TIM6);
nInterrupt++;
//sprintf(buffer,"\rke-%3d\n",nInterrupt);
//USART_puts(buffer);
sprintf(buf_tmp,"%d\n",tmp);
USART_puts(buf_tmp);
tamp = 0;
}
}
And I have 2 Task, 1 task for simple print and 1 task for networking (using LwIP)
void test_print(void)
{
TickType_t wake_time,tamp1,tamp2;
const uint32_t period = 100;
char buff[32];
wake_time = xTaskGetTickCount();
while(1)
{
USART_puts("aaaaaaaaaaa ");
//vTaskDelay(1000);
delay_dw(500);
tamp2 = xTaskGetTickCount();
sprintf(buff,"Tick2 = %u\n",tamp2);
USART_puts(buff);
vTaskDelayUntil(&wake_time,period);
}
}
void echo_tcp()
{
int c1,c2;
char clock[32];
tamp = 0;
while(1)
{
if(ETH_CheckFrameReceived())
{
cycle_start();
c1 = getCycles();
LwIP_Pkt_Handle();
c2 = getCycles();
cycle_stop();
tamp+= c2 - c1;
GPIO_SetBits(GPIOD,GPIO_Pin_12);
}
else
{
GPIO_ResetBits(GPIOD,GPIO_Pin_12);
LwIP_Periodic_Handle(LocalTime);
}
}
}