CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

RTOS issue tasks

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Ralf2



Joined: 05 Feb 2009
Posts: 10

View user's profile Send private message

RTOS issue tasks
PostPosted: Mon Dec 01, 2014 8:29 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Dec 01, 2014 11:18 pm     Reply with quote

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: 19551

View user's profile Send private message

PostPosted: Tue Dec 02, 2014 9:00 am     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Dec 02, 2014 4:35 pm     Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group