w_bwr
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:
I have checked this code on a hardware and it seems to work fine.
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.