Quality RTOS & Embedded Software

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


PWM on dsPIC33

Posted by Igor R on March 30, 2013

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).


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(;;) {
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) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.

Free TCP/IP and file system demos for the RTOS

Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑

FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

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

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

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

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists