DOC PREVIEW
VANDERBILT EECE 276 - Timer functions

This preview shows page 1-2 out of 6 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 6 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 6 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 6 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

EECE 276 – Embedded Systems1EECE 276Embedded SystemsTimer functions and eventsEECE 276 – Embedded Systems2Timer functionsO Real-time systems often must synchronize their activities to the passage of time » “Turn power off if nothing happens for 1 mins”» Dial a digit: 100msec tone+100msec pause» “If temp and press is too high continuously for 3 minutes, then shut down reactor”O Common technique: » delay(int units) – delays task for a “units”» delay_call(int units,(void)(*func)(void*),void* arg) –call “func” with “arg” after “units”EECE 276 – Embedded Systems3Timer example codevoid phone_dial_task() {char phNum[MAX_PH_NUM]; // 0-terminated phone number str.char *phNumP;while(1) {msgq_recv(queue,&phNum,MAX_PH_NUM); // Get numbersphNumP = phNum;while(*phNumP) {delay(100); // delay for 100 mSecdialToneOn(*phNumP – ‘0’); // start tonedelay(100); // delay for 100 msecdialToneOff(); // stop tonephNumP++; // next digit}}}EECE 276 – Embedded Systems4Issues with timersO The delay(int) may not precisely delay“tick”delay ends at tickdelay(3) -> 2.9 ticksdelay(3) -> 2.3 ticksdelay(3) -> 2.9 ticksO No standard “tick” (read RTOS manual)O More accurate timing: use hardware timersEECE 276 – Embedded Systems5Events: Synchronization devicesO “event”: boolean flag O Multiple tasks can set it/wait for itO A task can wait for multiple events» AND and OR synchronizationO uCOS: Event flag groups» See App NoteEECE 276 – Embedded Systems6Comparison of task synchronization toolsO Semaphores:» Fast and simple» “Unstructured”» Limited information is carriedO Events:» Slightly more complex than semaphores» Multiple tasks for one event» One task for multiple eventsO Queues:» Pass “large” amounts of data» Enqueuing/dequeuing data is


View Full Document

VANDERBILT EECE 276 - Timer functions

Download Timer functions
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Timer functions and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Timer functions 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?