6. freertos_tn
TRANSCRIPT
-
7/31/2019 6. freeRTOS_TN
1/29
SVTH: VnQucDng
L Quang V
-
7/31/2019 6. freeRTOS_TN
2/29
CONTENT
Tng quan1
Task v Co-routine2
Inter-task Communication3
Soft-timer4
Support Architecture5
-
7/31/2019 6. freeRTOS_TN
3/29
TNG QUAN
FreeRTOSTMhtrchnh thc27 kin trc(PIC32, AVR32,)
Portable, open source, mini Real TimeKernel
C thsdng trong cc ngdngthngmi? -> GPL (General Public License)
http://www.freertos.org/open-source-software.htmlhttp://www.freertos.org/open-source-software.htmlhttp://www.freertos.org/open-source-software.htmlhttp://www.freertos.org/open-source-software.htmlhttp://www.freertos.org/open-source-software.htmlhttp://www.freertos.org/open-source-software.htmlhttp://www.freertos.org/open-source-software.htmlhttp://www.freertos.org/open-source-software.htmlhttp://www.freertos.org/open-source-software.htmlhttp://www.freertos.org/open-source-software.html -
7/31/2019 6. freeRTOS_TN
4/29
TNG QUAN
OpenRTOSTM : fully featured professionalgrade USB, file system and TCP/IPcomponents
SafeRTOSTM : sdng trong safety criticalapplications
-
7/31/2019 6. freeRTOS_TN
5/29
TNG QUAN
Thitknhgn, dsdng. (4K to 9Kbytes).
Ngn nglp trnh C.Sdngtasks and co-routines.
http://www.freertos.org/taskandcr.htmlhttp://www.freertos.org/taskandcr.htmlhttp://www.freertos.org/taskandcr.htmlhttp://www.freertos.org/taskandcr.htmlhttp://www.freertos.org/taskandcr.htmlhttp://www.freertos.org/taskandcr.html -
7/31/2019 6. freeRTOS_TN
6/29
TNG QUAN
Queues, binary semaphores, countingsemaphores, recursive semaphores andmutexes cho giao tip v ngbgia cc
task,v gia cc task v interrupt.Mutexesvipriority inheritance.Htrsoftware timers.
http://www.freertos.org/Inter-Task-Communication.htmlhttp://www.freertos.org/Inter-Task-Communication.htmlhttp://www.freertos.org/Inter-Task-Communication.htmlhttp://www.freertos.org/Inter-Task-Communication.htmlhttp://www.freertos.org/RTOS-software-timer.htmlhttp://www.freertos.org/RTOS-software-timer.htmlhttp://www.freertos.org/Inter-Task-Communication.htmlhttp://www.freertos.org/Inter-Task-Communication.htmlhttp://www.freertos.org/Inter-Task-Communication.htmlhttp://www.freertos.org/Inter-Task-Communication.html -
7/31/2019 6. freeRTOS_TN
7/29
TASK V CO-ROUTINE
Task: Ready
Running
Block
Suspended
-
7/31/2019 6. freeRTOS_TN
8/29
TASK V CO-ROUTINE
Task: Multitaskingwith full preemption
Fully prioritised
Each task maintains its own stack
Priority: 0 -> configMAX_PRIORITIES1
Low -> High
= 0 : idle task
-
7/31/2019 6. freeRTOS_TN
9/29
TASK V CO-ROUTINE
Implement task:void vATaskFunction( void *pvParameters )
{
for( ;; )
{
-- Task application code here.
}
}
Create: xTaskCreate()Delete : vTaskDelete()
-
7/31/2019 6. freeRTOS_TN
10/29
TASK V CO-ROUTINE
Idle task: created automatically when the scheduler
is started
free memory allocated which will execute only when there are
no other tasks able to do
Other tasks can share the idle taskpriority
-
7/31/2019 6. freeRTOS_TN
11/29
TASK V CO-ROUTINE
Idle task:
-
7/31/2019 6. freeRTOS_TN
12/29
TASK V CO-ROUTINE
Share a single stackCo-routine:
Running
Ready
Block
Priority: 0 -> configMAX_CO_ROUTINE_PRIORITIES - 1
-
7/31/2019 6. freeRTOS_TN
13/29
TASK V CO-ROUTINE
Implement co-routine:void vACoRoutineFunction( xCoRoutineHandle
xHandle, unsigned portBASE_TYPE uxIndex )
{crSTART( xHandle );
for( ;; ) {
-- Co-routine application code here.
}
crEND();
}
-
7/31/2019 6. freeRTOS_TN
14/29
TASK V CO-ROUTINE
Scheduling co-routine: scheduled by repeated calls to
vCoRoutineSchedule()
tasks and co-routines to be easily mixed withinthe same application
execute when there are no tasks of priority higher
than the idle task
-
7/31/2019 6. freeRTOS_TN
15/29
INTER-TASKCOMMUNICATION
Queues
Binary SemaphoresCounting Semaphores
Mutexes, and
Recursive Mutexes.
-
7/31/2019 6. freeRTOS_TN
16/29
INTER-TASKCOMMUNICATION
Queues
L dng chnh trong inter-taskcommunication.
Taskstasks, tasksinterrupts.
Thng c dng dng FIFO.
Phn t trong queue c kch thc c nh: c
th dng con tr nu cn thit. C 3 trng thi trng, y v bnh thng.
Ticks.
-
7/31/2019 6. freeRTOS_TN
17/29
INTER-TASKCOMMUNICATION
-
7/31/2019 6. freeRTOS_TN
18/29
INTER-TASKCOMMUNICATION
Binary Semaphores
Ch yu dng vi mc ch ng b.
-
7/31/2019 6. freeRTOS_TN
19/29
INTER-TASKCOMMUNICATION
Counting Semaphores
m s kin Semaphoes khi to l 0.
Khi c s kin Semaphore tng . Khi task nhn s kin Semaphore gim.
Qun l ti nguyn Semaphoes khi to l s lng ti nguyn.
Khi task ly ti nguyn th Semaphore gim.
Khi task tr ti nguyn th Semaphore tng.
-
7/31/2019 6. freeRTOS_TN
20/29
INTER-TASKCOMMUNICATION
Mutexes ('MUT'ual 'EX'clusion) Dng gii quyt ng .
Thay i priority cho ph hp.
-
7/31/2019 6. freeRTOS_TN
21/29
INTER-TASKCOMMUNICATION
Recursive Mutexes
-
7/31/2019 6. freeRTOS_TN
22/29
SOFTWARE TIMERS
In a nutshellOne-Shot and Auto-reload
Resetting a Timer
-
7/31/2019 6. freeRTOS_TN
23/29
SOFTWARE TIMERS
In a nutshell Gi hm ti mt thi im xc nh trong
tng lai.
NOTE: Software timers phi c khi totrc khi s dng.
-
7/31/2019 6. freeRTOS_TN
24/29
SOFTWARE TIMERS
One-Shot and Auto-reload
-
7/31/2019 6. freeRTOS_TN
25/29
SOFTWARE TIMERS
Resetting a Timer
-
7/31/2019 6. freeRTOS_TN
26/29
SUPPORT ARCHITECTUREAlteraAtmelCortusCypressEnergy MicroFreescale
FujitsuLuminary MicroMicrochipNECMicrosemi (formally Actel)NXPRenesasSilicon LabsST MicroelectronicsTexas InstrumentsXilinxx86 (real mode)x86 / Windows Simulator
-
7/31/2019 6. freeRTOS_TN
27/29
SUPPORT ARCHITECTURE
the PIC32, a MIPS based 32bit microcontroller offerings from Microchip
-
7/31/2019 6. freeRTOS_TN
28/29
SUPPORT ARCHITECTURE
he TCP/IP demo uses the lwIP TCP/IP stack and includes a basicweb and TFTP server implementation
-
7/31/2019 6. freeRTOS_TN
29/29