anonymous wrote on Monday, October 22, 2012:
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.