I have gone through the FreeRTOS material for ARM Cortex-M3 & working with stm32.
In my firmware i have 6 interrupts:
1. Timer2 : NVIC_IRQChannelPreemptionPriority = 10;
2. USB : NVIC_IRQChannelPreemptionPriority = 11;
3. USART2 : NVIC_IRQChannelPreemptionPriority = 12;
EXTI15_10 ISR is used for 3 Buttons:
4. Button1: NVIC_IRQChannelPreemptionPriority = 13;
5. Button2: NVIC_IRQChannelPreemptionPriority = 14;
6. Button3: NVIC_IRQChannelPreemptionPriority = 15;
If i understood correctly, **Button3** has lower logical priority & **Timer2** has highest priority. In order to use these interrupts, I have changed the following FreeRTOSConfig.h
**configMAX_SYSCALL_INTERRUPT_PRIORITY 159;** The top 4 bits are 1001(binary), which equals 9(decimal). With this modification, I can use the numbers between 9 and 15 inclusive. Which means 10,11,12,13,14,15.
Also, **configTICK_RATE_HZ ( ( portTickType ) 200 )**
**configMAX_PRIORITIES 5 **
With the above settings, My firmware has to do the following( assume 2 tasks):
1. Create two tasks when the board is powered.
2. One of the task( Data Task) should be running at 100Hz (using Timer ISR).
3. The other task(Command Task) should respond for a data coming from USB or USART & then process the data(commands) placed in queue’s.
At present If I **start** the Timer2 when I send a command to board via USB or USART (established communication by opening virtual com ports), Timer2 starts & its ISR triggers Data Task by giving semaphore at 100Hz, that will be received by Data Task, then it executes some code.
Now,Again, if I send a command to board via already communicated path, It **stops** Timer2.
This approach has no problems with the above six interrupt priorities & their order. My firmware works fine.
**But I want to start running the Data Task at 100Hz without sending the command to start Timer2 ISR as soon as the board is powered, then communicate with board.**
With this approach i need to remove **start** & **stop** timer commands.
If I start timer2 by creating another task & delete it by itself after starting timer2, I’m getting problems. I tried placing “timer2 start” code in the “Data Task” & “Command Task”, but no use.
**Problem:** Some times, I’m unable to open virtual COM port though it appears. This seems to be priorities assigned problem. I tried reversing the first three interrupt priorities, no use.
How & where should i place code to start Timer2 ?
**Note:** Some of the content of this post appeared already in other post of mine and its got deviated from the actual problem. But I’m explaining the problem here is to make it clear.
Download link to My code: https://dl.dropbox.com/u/14046521/mycode.c
Thank you.
TASK in BLOCKED state while communicating
TASK in BLOCKED state while communicating
**But I want to start running the Data Task at 100Hz without sending the command to start Timer2 ISR as soon as the board is powered, then communicate with board.**If the timer interrupt is using a FreeRTOS function, which you indicate that it is, you cannot start it when the board powers. You can however start it as soon as the scheduler has started. To do that, place the code that starts the timer at the top of the first task that runs – before the task enters its infinite loop. Alternatively, before starting the scheduler, ensure interrupts are disabled (they should be anyway if you have called FreeRTOS API functions to create tasks), then start the timer. As interrupts are disabled the interrupts generated by the timer will not execute. Interrupts will be enabled automatically when the first task starts running, at which time the timer interrupts will start to be processed safely.
With this approach i need to remove **start** & **stop** timer commands.
**Problem:** Some times, I’m unable to open virtual COM port though it appears. This seems to be priorities assigned problem. I tried reversing the first three interrupt priorities, no use.I’m afraid I can only comment on FreeRTOS issues, and the virtual com port is not part of FreeRTOS. Regards.
TASK in BLOCKED state while communicating
Thank you Richard.
1. My intention is to say, after hardware initialized & as soon as the Data task and Command Task are running ( scheduler vTaskStartScheduler(); started). Only thing is that I need to remove Start & Stop Timer commands, this should not become a problem to communicate( USB & USART interrupts are enabled) with the board.
2. Problem: Some times, I’m unable to open virtual COM port though it appears. I wrote this because i should state the problem symptoms. This only happens since the timer is already running ( Data Task running), so, when i try to open virtual COM port, I doubt it is not allowing other interrupts to wake up. If i use timer start code in either of the Tasks before it enters into infinite loop, most of the times Virtual COM port not initialized properly when rest or board is powered( Unknown device found message pops up in windows7). To achieve my method, i think i should change the way I coded my FreeRTOS tasks because with working version of my firmware that is timer starts & stops when a command sent to board after opening virtual COM port, note that timer is not running before i open Virtual com port. This is the reason why my firmware works fine.
But in the new approach which I’m trying to do, the timer is already running( data task running), I guess the critical sections
inside this task disable interrupts( Command task stays in BLOCKED state while Data task running), so i could not be able to open virtual com port. With the above observations, it is better to write code which always allow us to communicate with board while the timer is running. How about increasing the configTICK_RATE_HZ ( at present 200Hz) ?
Is the problem happening due to priority order of interrupts ? Thank you
1. My intention is to say, after hardware initialized & as soon as the Data task and Command Task are running ( scheduler vTaskStartScheduler(); started). Only thing is that I need to remove Start & Stop Timer commands, this should not become a problem to communicate( USB & USART interrupts are enabled) with the board.
2. Problem: Some times, I’m unable to open virtual COM port though it appears. I wrote this because i should state the problem symptoms. This only happens since the timer is already running ( Data Task running), so, when i try to open virtual COM port, I doubt it is not allowing other interrupts to wake up. If i use timer start code in either of the Tasks before it enters into infinite loop, most of the times Virtual COM port not initialized properly when rest or board is powered( Unknown device found message pops up in windows7). To achieve my method, i think i should change the way I coded my FreeRTOS tasks because with working version of my firmware that is timer starts & stops when a command sent to board after opening virtual COM port, note that timer is not running before i open Virtual com port. This is the reason why my firmware works fine.
But in the new approach which I’m trying to do, the timer is already running( data task running), I guess the critical sections
inside this task disable interrupts( Command task stays in BLOCKED state while Data task running), so i could not be able to open virtual com port. With the above observations, it is better to write code which always allow us to communicate with board while the timer is running. How about increasing the configTICK_RATE_HZ ( at present 200Hz) ?
Is the problem happening due to priority order of interrupts ? Thank you
TASK in BLOCKED state while communicating
You can either just try changing the tick frequency and interrupt priorities to see what happens, or use the trace tool to see what is actually happening.
TASK in BLOCKED state while communicating
Problem is same when
1. configTICK_RATE_HZ 1000
2. Even after changing priority order of interrupts.
3. location of start timer placed in data or command task before entering infinite loop.
1. configTICK_RATE_HZ 1000
2. Even after changing priority order of interrupts.
3. location of start timer placed in data or command task before entering infinite loop.