View previous topic :: View next topic |
Author |
Message |
Ralf2
Joined: 05 Feb 2009 Posts: 10
|
RTOS issue tasks |
Posted: Mon Dec 01, 2014 8:29 pm |
|
|
Hi.
This program not work, if minor_cycle >= 430ms???
Code: | #include <18F26K80.h>
#device adc=12
#FUSES VREGSLEEP //Ultra low-power regulator is disabled
#FUSES INTRC_LP //LF-INTOSC in Low-Power mode during Sleep
#FUSES NOWDT //No Watch Dog Timer
#FUSES NOXINST //Extended set extension and Indexed Addressing mode disabled (Legacy mode)
#FUSES PLLEN //PLL habilitado, multiplica por 4 el cristal externo
#FUSES HSM //High speed Osc, medium power 4MHz-16MHz, solo para cristal externo
#FUSES SOSC_DIG //Digital mode, I/O port functionality of RC0 and RC1
#FUSES PUT //Power Up Timer
#FUSES NOBROWNOUT //No brownout reset
#FUSES WDT_NOSLEEP //Watch Dog Timer, disabled during SLEEP
#use delay(clock= 32000000)
#define led_red pin_b0
#define led_green pin_b1
#use RTOS(timer=0, [b]minor_cycle=430ms[/b])
#task (rate=860ms, max=20ms)
void LED_R();
#task (rate=1720ms, max=20ms)
void LED_V();
void main()
{
output_low(led_red);
output_low(led_green);
rtos_run();
}
void led_R()
{
output_toggle(led_red);
}
Void led_V()
{
output_toggle(led_green);
}
|
If minor_cycle < 430ms, work! Why??? |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Dec 01, 2014 11:18 pm |
|
|
The CCS Rtos manual says:
Quote: |
The programmer must specify the minor cycle using the #use RTOS()
preprocessor directive. The parameters that this directive takes are the
timer to be used, the minor cycle, and statistics. The first parameter,
timer, is the desired timer to be used in timing the minor cycle. Some
timers may not have the resolution to accommodate certain
minor cycles and it is therefore the programmer's responsibility
to choose the appropriate timer.
|
Try using Timer1 instead of Timer0. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19535
|
|
Posted: Tue Dec 02, 2014 9:00 am |
|
|
The problem is the word 'multiple'. The task times, must be a 'multiple' of the timer tick. Here 'multiple', does not include '1'. It'll only run correctly if the task rates are a number of ticks each. Also remember it 'budgets' some time for each task. If your tick is just half the task time, it cannot make things fit.... |
|
|
Ralf2
Joined: 05 Feb 2009 Posts: 10
|
|
Posted: Tue Dec 02, 2014 4:35 pm |
|
|
Hi.
I see the problem apparently is the allocation made by the ccs to pre scaler timer 0 or 1,
because if minor_cycle = 430ms, the pre-scaler timer0 or 1 = 2(timer0) and the program does not work. And if the minor_cycle = 420 for example, pre scaler(timer0) = 64 work fine, why???
Of course adjusting the values of rate in both tasks.
Could verify this please?
Regards |
|
|
|