Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT




Loading

PWM on dsPIC33

Posted by Igor R on March 30, 2013
Hello!

I'm trying to use FreeRTOS port on dsPIC33FJ128GP206 and I need to drive a lot of servos. Servos are being driven with OC1-3 channels through multiplexers, OCx are using timer2. FreeRTOS is using timer1, as in example and is running at lowest priority timer interrupt (priority 1), while timer2 is running at priority 7. When tasks are switching it causes a lag or something and servos shake during context switch.
Just to do some research on issue, I've replaced timer1 handler with some dummy code, to see if it will occur with same interrup priorities - everything is ok. As soon as I add RTOS functionality - jitter is back.
How can I get rid of this? I think I've already tried everything, but the jitter is still present. The more tasks I add, the more jitter there is - shake per task (switch)

RE: PWM on dsPIC33

Posted by Richard on March 30, 2013
Are your drives being processed from an interrupt? If so, then setting the interrupt priority above configKERNEL_INTERRUPT_PRIORITY will ensure the interrupts do not get delayed by anything the kernel is doing. It does however also mean that the interrupts cannot call FreeRTOS API function (the functions that end in FromISR are safe on a PIC24/33 only if called from interrupts that run with a priority equal to configKERNEL_INTERRUPT_PRIORITY).

Regards.

RE: PWM on dsPIC33

Posted by Igor R on March 30, 2013
Yes, I am aware of that. I am not using any FreeRTOS functions inside interrupt handler and my interrupts are running above configKERNEL_INTERRUPT_PRIORITY while this happens

RE: PWM on dsPIC33

Posted by Dave on March 31, 2013
Does that mean your drives are being processed by the interrupts? I'm not sure. Are your tasks enabling and disabling interrupts using any method other than calling taskENTER_CRITICAL and taskEXIT_CRITICAL?

RE: PWM on dsPIC33

Posted by Igor R on March 31, 2013
No, it's a very simple "Hello World" project. My only task is a simple led blinky. Just :
for(;;) {
_RD4++;
vTaskDelay(1000 / portTICK_RATE_MS);}
two lines, nothing more.
Interrupt handler is also kept as simple as possible. Clear the flag and load value from an array. Array is static. No calls to anything from ISR, no complex calculations, no nothing:
{IEC0bits.OC1IE = 0;
IFS0bits.OC1IF = 0;
if(++mux == 2) mux = 0;
OC1RS = pwm[mux];
IEC0bits.OC1IE = 1;}
Is this clear enough to see, how complex is the program I am running? Everything else is a code from freertos example. pmw[] is declared as pwm[2] = {1500,1500} and that's the only place it is being modified.


[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]




Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

FreeRTOS kernel V10 is available for immediate download. Now MIT licensed.


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

OpenRTOS and SafeRTOS