Hello, I am developing my project of PIC32. I wish to know if it is possible to change the TICK count on a dynamic basis. Since my application is a Battery powered hardware I require switching the CPU frequency in 4 modes: Turbo Charged – 80MHz/40MHz , Normal – 40MHz/20MHz , Slog – 20MHz/20MHz and Sleep. Where (XXMHz/YYMHz) = <CPU Clock>/<Peripheral Clock> By default the CPU boots into the Normal – 40MHz/20MHz and then switches accordingly. Additionally I might require to optionally disable and enable the Cache feature have speed of execution in the same mode. I found that in the Demo code provided the Frequency of PBCLK and F_CPU are fixed. Kindly let me know if this is possible. Warm Regards, Abhijit Bose
In theory it is possible, but would be quite complex. When a task enters the blocked state the time at which the task should unblock is calculated in ticks (time_now + block_time = wake_time). If you change the tick frequency after a task has blocked then the wake_time will be incorrect. One way of doing this might be to have a flag that keeps track of the current frequency, then whenever the tick value is incremented the flag is checked to see what the increment should be. If 80MHz is used, increment by 1. If 40Mhz is used, increment by 2. If 20Mhz is used, increment by 4. Etc. Regards.
Hello, I have been able to make the RTOS working now for 2 Tasks. Details: Hardware: PIC32 Starter Kit Debugger: PIC32 Starter Kit Frequency: 80MHz LED: On-board PIC32 Starter Kit Tasks: Task1 – Priority IDLE Task2 – Priority IDLE+2 The code is taken from the Sample example. Link to the Code: http://sites.google.com/site/pic32site/Home/FreeRTOStest_001.zip Kindly let me know how to go about implementing the task blocking as you mentioned earlier. I have a few more clarifications: 1. Which is the Timer that FreeRTOS PIC32 port uses? Is it Core Timer interrup? This is required since I require to use nearly all the Timers for my project except the core timer. 2. How can I use the Serial Receive Interrupts in case I have a priority task of 7? Since switching would be critical. Kindly let me know. Thanking you for your support, Warm Regards, Boseji My Project: http://www.mypic32.com/web/guest/contestantsprofiles?profileID=32956
Hello, I also wish to ask if it is possible to change the Timer 1 Clock tick to the core timer. This will free up my precious Timer 1. Kindly let me know your suggestions on this. Warm Regards, Boseji My Project: http://www.mypic32.com/web/guest/contestantsprofiles?profileID=32956
Yes it is possible to use the core timer, but there is a danger in doing so as unfortunately the core timer is not ideal for periodic interrupt generation. When using the peripheral timer you can setup the timer to generate an interrupt on a compare match. Each time an interrupt is generated the timer count value is automatically reset and starts counting again from the beginning until it reaches the match value. The important thing is this happens automatically, even if your software is doing something else. The next interrupt will be pended at the right time. If you were using the core timer then there is no way of getting the timer to automatically reset – it just keeps counting. This means you have to calculate the next match value from within interrupt itself (look up table or calculation). If for some strange reason your application keeps interrupts disabled for too long, or you have lots of higher priority interrupts coming in, then it is possible that you will only write out the next match value AFTER the timer has already gone past it. This would have the effect of freezing your system until the timer had wrapped all the way around. This is an unlikely occurrence, but is more likely the faster the tick rate. You could also put in some software guards against this happening, but you will get into race conditions. It is because of these reasons I did not use the core timer, but you can are free to change this. The timer is setup in prvSetupTimerInterrupt() within port.c. Regards.
In SourceportableMPLABPIC32MXport.c you will see the function vPortIncrementTick(). This calls vTaskIncrementTick() just once. If you have the frequency, change this so vTaskIncrementTick is called twice. If you quarter the frequency, change this so it is called 4 times. Etc. [I have never actually tried this!] Regards.
Hi, Thanks for your inputs. I would post an update on this thread when I am done with this modifications. Warm Regards, Boseji My Project: http://www.mypic32.com/web/guest/contestantsprofiles?profileID=32956
Hi, As per your recommendations I would stick to Timer 1 and try to find some Semaphore based resource usage. Thanks again for your support. Warm Regards, Boseji My Project: http://www.mypic32.com/web/guest/contestantsprofiles?profileID=32956
Hello, I have been able to make the modifications to the port.c file and added an option for changing the Frequency in the FreeRTOS.h file. But I was not able to change the oscillator frequency properly on the PIC32 micro. I have writen a port for the RTOS and would like to ask if you can inspect my changes. Since if this works then it might be a good feature. Another important thing that I observed during this modification is that we can actually change the Task tick time ie speed up the RTOS switching when required. This is a good feature since at times when you are trying to receive some thing on a slow serial line and dont want to use interrupts this comes in handy. Or just want to dectect a button press fast without a change over interrupt. Kindly let me know your views. I will post the code soon. Warm Regards, Boseji My Project: http://www.mypic32.com/web/guest/contestantsprofiles?profileID=32956
Hi – I would definitely be interested in seeing your code. I had a look on your mypic32 page but could not see a way of obtaining the source. If there is a lot of it could you send it to me at r [dot] barry (at) freertos.org, then I can do a diff to find the changes. Its fine to post code in the forum but the formatting will get all screwed up. Regards.
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.