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


Task delay

Posted by Davide on January 16, 2012
Hi at all,
I need your help to find a solution for implement 1-wire comunication on a PIC24 based platform (flyport openPicus).
On the platform I have two tasks TASK1 and TASK2 (with 1 millisecond between each). During TASK1 I want the platform execute a block of statements that commits about 480 milliseconds (max 960). After which I need TASK1 go to sleep for the rest of its time. At this point TASK2 perform its statementes. When the kernel resume TASK1 it must perform another block of statements. I hope I was clear and you can help me....


RE: Task delay

Posted by Richard Damon on January 16, 2012
Not totally sure what you mean by "another" block of statements, but it sounds like one or the other of these would do for task1

void task1(void* parm){
while(1) {

or if another bock is just repeating what was done before

void task1(void* parm){
while(1) {

Task 2 then just needs to have a lower priority and then when task 1 blocks on the vTaskDelay it will start up.

RE: Task delay

Posted by MEdwards on January 16, 2012
“I have two tasks TASK1 and TASK2 (with 1 millisecond between each)”

I don't understand that statement. Do you mean the tasks have to share a 1ms time slot? Is that every ms?

It is hard to get that kind of timing resolution in tasks. You would probably need a tick frequency of 4Khz, which is a bad idea as most of the processing will be tick interrupts and not tasks. At first I thought you might be better using software timers instead of task, but that has the same resolution problem.

Can you put all the functionality into one task? Or use two hardware timers with the work done in a hardware timer callback?

RE: Task delay

Posted by Davide on January 16, 2012
Hi at all and thanks for reply.
I try to explain better my problem.
I want to write a library for 1-wire comunication for openPicus Flyport module.
On this platform there are two default tasks (one for TCP/IP stack and one for the user code) with 1 millisecond switching time.
I need to synchronize the 1-wire comunication steps with the tasks switching.
(For example:
TASK1: reset pulse for the 1-wire device.
TASK2: TCP/IP stack
TASK1: send command to 1-wire device
TASK2: TCP/IP stack
TASK1: send another command or read the first byte of response from 1-wire device
TASK2: TCP/IP stack
TASK1: Read the second byte of response from 1-wire device
etc etc)

I hope is clear my problem...


RE: Task delay

Posted by Davide on January 16, 2012
On flyport vTaskDelay(1) is 10 milliseconds.


RE: Task delay

Posted by Dave on January 16, 2012
“I hope is clear my problem...”

Not really.

What does 1ms switching time mean if vTaskDelay( 1 ) is 10ms? If your timing resolution is 10ms, and both tasks have the same priority, then the kernel will switch between the tasks every 10ms. If the tasks have different priorities, then the kernel will only running the lower priority task when the higher priority task is blocked (if it is waiting on a semaphore for more TCP/IP data, for example).

Your sequence looks like you just want to run the TCP/IP stack at any time there is not 1 wire processing to do. If that is the case, run the 1-wire task at a higher priority, and have the 1-wire task block (allowing the TCP/IP task to run) when it is waiting for 1-wire events. The events can come from the 1-wire interrupt, and the interrupt can give the semaphore to unblock the task.

[ 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