Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Delays within RTOS Task.

Status
Not open for further replies.

w_bwr

Member level 3
Member level 3
Joined
Feb 4, 2010
Messages
66
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Location
Karachi, Pakistan
Activity points
1,810
Controller: PIC 18f452 Compiler: CCS
CCS has a built in RTOS which is not pre-emptive.

I have written simple RTOS task which detects for a button and if pressed then increment the count on the lcd.
Push Button works on this basis:
check for button, if pressed then wait 100 ms, check again if still pressed, i have got a valid press.
wait 100ms after the button is pressed for a valid release.

My task executes every 100us and max runtime is 50us.
I am confused here, can delays more the max time be used in an RTOS Task?
Are there other methods to keep track of time in a RTOS Task?


Here is code:
Code:
#task (rate=100us,max=50us)
void Button_input ()
{
if (!input(PIN_A4))
{
delay_ms(100);
if (!input(PIN_A4))
{
dt_lcd_gotoxy(100,2);printf(dt_lcd_printchar,"%Lu",timer0);
timer0++;
delay_ms(100);
}
}
}

I have checked this code on a hardware and it seems to work fine.
 

You need to check your RTOS documentation. Is the delay_ms() function an OS-provided one, or something that you wrote yourself? If it is an OS provided function, then the delay() may be putting the process temporarily to sleep to allow other processes to run. If it runs on hardware as you say, then that's good. Simulations are just that - simulations, not necessarily accurate.
 

Your function delay_ms() resembles me one in GCC compiler for AVR.
Is it really OS's function?
 

Your function delay_ms() resembles me one in GCC compiler for AVR.
Is it really OS's function?

I have checked it. it's not the OS Function. Its CCS compiler function.
I don't understand why its working fine.
OS provides the function RTOS_AWAITS(Expression).
But it checks for and Expression to be true.

How can I use it for a time delay?

---------- Post added at 05:36 ---------- Previous post was at 05:30 ----------

Your function delay_ms() resembles me one in GCC compiler for AVR.
Is it really OS's function?

I have checked it. it's not the OS Function. Its CCS compiler function.
I don't understand why its working fine.
OS provides the function RTOS_AWAITS(Expression).
But it checks for and Expression to be true.

How can I use it for a time delay?
 

Dear w_bwr , as to you first question: you can use any delay in RTOS task. You can even stop it for ever)
You shouldn't use any delay functions not from RTOS service library, or else your RTOS can't function properly.
I recommend you to study the manual for your RTOS. There must be functions something like "sleep".
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top