Tutorial 9 : delay_blocking library - sudeshmoreyos/Morey_os-demo-1.0 GitHub Wiki

Home <<Prev 9 Next>>

As discussed before, it is not recommended to give delay less than 50 milli-second using DELAY_SEC Macros. So what if we wish to give delay less than 50 milli seconds?

We can use delay_blocking utility library. Blocking here means this delay actually blocks CPU for any other tasks for specified time. Hence it is recommended to give maximum blocking delay of 50 milli seconds only. To include delay_blocking header file in your code, you need to add following lines in your code :

#include "util/delay_blocking.h"

You can find header file for delay_blocking library here delay_blocking utility Library. Source file is platform dependent can be found in arch directory.

This library has two functions :

1. delay_ms_blocking

This function gives delay in milli seconds. This function has only one input which must be a positive integer. Please note only constant value can be passed as input to this function. Typical usage for 10 milli second delay is as follows :

delay_ms_blocking(10);

2. delay_us_blocking

This function gives delay in micro seconds. This function has only one input which must be a positive integer. Please note only constant value can be passed as input to this function. Typical usage for 10 micro second delay is as follows :

delay_us_blocking(10);

Home <<Prev 9 Next>>