I'm trying this TASK and I have some doubts:
Should the configuration file be placed in the same folder as the code?
Is the number of Tasks limited? 3 Task 1 LTask
This test code doesn't work if I pass N. Task
'-----------------CONFIGUREMICRO-------------------'------------------------------------------------'Funzionabenepero'nonsipossonofermareMAI'--VieneutilizzatoilTIMER0(chequindinonsipuòutilizzare)#chip 16F88, 4#config XT_OSC, WDT_OFF, PWRT_ON#option explicit'*****SETTAGGIOPORTE#define Led1 PORTA.0 ' Led1#define Led2 PORTA.1 ' Led2#define Led3 PORTA.2 ' Led3#define Puls PORTA.3 ' read_input#define Buzz PORTA.4 '#define AD4 PORTA.5 ''-------------------#define B0 PORTB.0 '#define ADR1 PORTB.1 '#define ADR2 PORTB.2 '#define B3 PORTB.3 '#define En PORTB.4 ' LCD data LCD seriale#define Rs PORTB.5 ' LCD clock#define Rxdb PORTB.6 ' RX debug (PICKIT2 tx)#define Txdb PORTB.7 ' TX debug (PICKIT2 rx)'====SETTAGGIDELLEPORTEDELPICI/Oecc.======================'--------bitabitcontrollo0=output1=inputdirPORTab'00101000''leggeimpostazioniINP/OUTdirPORTbb'01001000''delleporte'----------------TASK'sDEFINITIONS-------------------#include"time_based_task_switcher_library001.h"#define base_time 1000 ' Base time or "tick" valore in uS'---------------'--TimebasedeveessereilvaloredelTASK1quello+veloce'--Task1,2,3ecc.quelli+veloci'--LONGLTaskquellilenti#define Task1 pulsante ' chiamata SUB (Lettura pulsante)#define Task1_ms 1 ' Task attivo ogni #define Run_Task1 ' esegue con interrupt subroutine#define Task2 NTC ' chiamata SUB #define Task2_us 500 ' Task attivo ogni us#define Task3 sub2 'we will have the time delay for the LED read from ReadAD function#define Task3_ms 10#define LTask1 sub1 ' nome SUB richiamata#define LTask1_s 3 ' esegue ogni #define LTask2 sub3 ' nome SUB richiamata#define LTask2_s 1 ' esegue ogni '---------------------MAIN-----------------------'dimONF_pulsasbitdoDo_Task1'avviataskdo_Task2Do_Task3Do_LTask1Do_LTask2loop'-------------------TASK'sSUBs---------------------'------------------------------------------------SubpulsanteONF_puls=puls'setled3periodtotheADvalueEndSubSubsub1led1=!led1'toggleledonbit0EndSubSubsub2led2=!led2'toggleledonbit1EndSubsubNTCendsubsubsub3endsub
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
In the GCB example, TIMER0 is set but it refers to a different pic than mine. How should it be set in my case?
InitTimer0 Osc, TimerInitValue + TMR0_HFINTOSC , POST0_1
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
It seems to only work with Task1...Task3 and LTask1
The compiler gives an error on line 950 of "time_based_task_switcher_library001.h"
950 flag_LTask2 off
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Using the MEGA328p demo as my source ( I used this because the timer is the same config as the 16F88).
I added the following to toggle the PORTB.6 every xx ms. This worked. I added the task, the time, and to run the defined task. 'Task4', 'Task4_ms' and 'Run_Task4'
I then hooked up chip and circuit and it all worked... after I had change the .h file, see below.
Dir PORTB.6 out
#define Task4 blink4
#define Task4_ms 1000 ' Run this Task every xx mS
#define Run_Task4
Sub blink4
PORTB.6 = !PORTB.6 'Toggle portb.6
End Sub
time_based_task_switcher_library002.h
The first thing I did was add #option explicit. This made sure I knew all the variable types.
So, I had to add the following block. Note: Dimensioning variable does not allocate RAM. This only tells the compile the type of variable. Only if a variable is used is the memory allocated.
Dim time_Task1 as Word
Dim time_Task2 as Word
Dim time_Task3 as Word
Dim time_Task4 as Word
Dim time_Task5 as Word
Dim time_Task6 as Word
Dim time_Task7 as Word
Dim time_Task8 as Word
Dim time_Task9 as Word
Dim time_Task10 as Word
Dim cont_Task1 as Word
Dim cont_Task2 as Word
Dim cont_Task3 as Word
Dim cont_Task4 as Word
Dim cont_Task5 as Word
Dim cont_Task6 as Word
Dim cont_Task7 as Word
Dim cont_Task8 as Word
Dim cont_Task9 as Word
Dim cont_Task10 as Word
Dim flag_Task1 as Word
Dim flag_Task2 as Word
Dim flag_Task3 as Word
Dim flag_Task4 as Word
Dim flag_Task5 as Word
Dim flag_Task6 as Word
Dim flag_Task7 as Word
Dim flag_Task8 as Word
Dim flag_Task9 as Word
Dim flag_Task10 as Word
Dim flag_LTask1 as Word
Dim flag_LTask2 as Word
Dim flag_LTask3 as Word
Dim flag_LTask4 as Word
Dim flag_LTask5 as Word
Dim flag_LTask6 as Word
Dim flag_LTask7 as Word
Dim flag_LTask8 as Word
Dim flag_LTask9 as Word
Dim flag_LTask10 as Word
Then!!!
Then I did a compare of 001.h and 002.h
001 seems to be an early development. With 002 being the one to use.
And, search the forum confirmed 002.h is the latest.
Regarding the location of the source .h file. Same folder as your project as "" not <> is used.
I'm trying this TASK and I have some doubts:
Should the configuration file be placed in the same folder as the code?
Is the number of Tasks limited? 3 Task 1 LTask
This test code doesn't work if I pass N. Task
In the GCB example, TIMER0 is set but it refers to a different pic than mine. How should it be set in my case?
InitTimer0 Osc, TimerInitValue + TMR0_HFINTOSC , POST0_1
I have not used the Task switcher.
I know I supports 16 tasks.
What configuration file?
What is you target chip?
Configuration files: #include "time_based_task_switcher_library001.h"
I'm using 16F88
It seems to only work with Task1...Task3 and LTask1
The compiler gives an error on line 950 of "time_based_task_switcher_library001.h"
950 flag_LTask2 off
I have taken the demos and adapted.
Using the MEGA328p demo as my source ( I used this because the timer is the same config as the 16F88).
I added the following to toggle the PORTB.6 every xx ms. This worked. I added the task, the time, and to run the defined task. 'Task4', 'Task4_ms' and 'Run_Task4'
I then hooked up chip and circuit and it all worked... after I had change the .h file, see below.
time_based_task_switcher_library002.h
The first thing I did was add
#option explicit
. This made sure I knew all the variable types.So, I had to add the following block. Note: Dimensioning variable does not allocate RAM. This only tells the compile the type of variable. Only if a variable is used is the memory allocated.
Then!!!
Then I did a compare of 001.h and 002.h
001 seems to be an early development. With 002 being the one to use.
And, search the forum confirmed 002.h is the latest.
Regarding the location of the source .h file. Same folder as your project as "" not <> is used.
#include "time_based_task_switcher_library002.h"
Ignore the comment - clearly the "" is correct.
My files are attached.
Evan
Thanks Evan,
I just saw that it was giving errors and I stopped.
In the next few days I will test if everything works correctly.
Greetings and HAPPY NEW YEAR
HAPPY NEW YEAR!!