Академический Документы
Профессиональный Документы
Культура Документы
Review of C language
1. unsigned character: This data type can hold unsigned number of value
from 0 to 255. The memory required to store an unsigned character
variable is one byte.
2. signed character: This data type can hold signed number of value from
-127 to +128. If a variable is declared without mentioning signed or
unsigned, then it is considered as signed and therefore the maximum
value that it can hold becomes +128 (Not 255). Therefore whenever, we
donot require signed number to be stored, we must declare the variable as
signed or unsigned explicitely. it is a good practice to always explicitely
2 Review of C language
List the facilities in C language which one needs to know before studying
the RTOS source code.
These include data types, pointer, pointer to pointer, pointer data types,
structure, pointer to structure, size of structure type variable, arrays, shift left
and shift right operators, meaning of void, NULL.
It is also preferred to know about the coding styles that involves comment
block for the file and for function, indenting, readable variable names, com-
ments explaining need of a variable etc.
1.4 Questions
1. What is a pointer?
2. Why pointer has its own data type?
3. Can we change the data type of a pointer? How? If we change it, what
is its effect? Illustrate with a suitable C program.
tion can be ported to other board/platform easily. These files are under
main folder in our project.
2.4 Questions
1. Explan the purpose of platform independent code of RTOS?
2. Why there are board specific files in RTOS based application?
3. How will you identify that a particular .c file is a board specific file?
4. The hex file of RTOS based application contains the code of application
along with RTOS (T/F).
At the end of this session, the students will be able to understand the basic
code of a simple RTOS based application. The same is detailed below. The
students should be able to understand, explain/illustrate the
#define OS_MAX_TASKS 15
#define OS_TICKS_PER_SEC 10
Here, the ticks per second is set to be 10. If there are 10 ticks in a second,
then the tick time (interval between two ticks) is equal to 100mSec. So the
statement OSTimeDly(2); will result in 200mSec delay.
of the stack of each task. This is required because, the OS needs to save the
context of each task on to its own stack so as not to cause problem to other
tasks.
The stack is an area in the memory (RAM), with contiguous locations.
Therefore the stack is defined using arrays. If there are 3 tasks, there sould be
3 stacks (i.e.) 3 arrays. The Size of each array depends on the amount of data
that is pushed on to the stack. Usually it is kept to be 64 stack locations. The
size of each stack can be the same can also be different based on the need.
The data type of each element of the array is an integer. This can be viewed
clicking on the OS STK and clicking on go to definition.
Here, three functions are shown. Each of these functions creates a task. So
here we create three tasks. The actual number of tasks to be created in an
application depend on the requirements of the application. For example, an
application may require ADC task, Relay task and Display task, whereas some
other application may require Serial task, Keyboard task in addition to the
earlier tasks. Hence the number of tasks depend on the logic of the application.
We need to understand that, a task is written (in the C program) as a
C funtion. So it is written at the program development time (i.e.) body of
the task function is written during the development of the C program of the
application. Now, in an RTOS based application, it is not enough to just write
body of the task function, it is necessary to tell the RTOS, information of the
task. The reason for this is that, the task function is invoked by the RTOS
and NOT by the main() of the application. It means, there is no explicite call
to the task function from the main() program. This is because, we are using
RTOS and the RTOS is expected to schedule the execution of tasks properly.
Please note that, creating a task DOES NOT mean writing the C program
of the body of the task function. It is something different than that, which
we are going to understand. The body of the function is written while we
develop the application. It means we write it before compiling. However, the
OSTaskCreate function is executed during the execution of the application.
Hence, creating task happens at run-time and writing body of the task function
happens during development time.
Now lets understand if we have already written body of the task function,
why do we need to call the OSTaskCreate function? Lets understand this.
The primary function of the RTOS is to schedule the execution of tasks and
handove the control of CPU to appropriate task (actually the highest priority
ready task). If RTOS wants to run a task, then, the address of the task (from
ROM) needs to be loaded in PC (Program Counter) of CPU. For this, OS needs
to know the address of the task function. This address needs to be provided to
OS by the application writer. Along with the address of the task function, we
also need to provide information of stack address and priority to RTOS. For
providing this information, the OSTaskCreate function is called.
3.3 Questions
1. Explan the purpose of platform independent code of RTOS?
2. Why there are board specific files in RTOS based application?
3. How will you identify that a particular .c file is a board specific file?
4. The hex file of RTOS based application contains the code of application
along with RTOS (T/F).
Inverting Apllifier, 1
Virtual Short, 1