C18 LaurTec Library
2.5
Open Source C Library for PIC18 Microcontrollers
|
00001 00002 unsigned char delay_quartz_frequency_value = 20; 00003 00004 00005 //************************************************************ 00006 // delay_ms function implementation 00007 //************************************************************ 00008 00009 void delay_ms (int value_ms) { 00010 00011 unsigned int reference = 0; 00012 unsigned int mainDelay; 00013 unsigned int subDelay; 00014 00015 reference = value_ms * delay_quartz_frequency_value; 00016 00017 for (mainDelay = 0; mainDelay < reference; mainDelay++) { 00018 00019 for (subDelay = 0; subDelay < 12; subDelay++); 00020 } 00021 00022 } 00023 00024 //************************************************************ 00025 // delay_s function implementation 00026 //************************************************************ 00027 00028 void delay_s (unsigned char value_s) { 00029 00030 unsigned char repeat_loop; 00031 00032 for (repeat_loop = 0; repeat_loop < value_s; repeat_loop++) 00033 delay_ms (1000); 00034 } 00035 00036 //************************************************************ 00037 // setQuartz function implementation 00038 //************************************************************ 00039 00040 void setQuartz (unsigned char frequency) { 00041 00042 delay_quartz_frequency_value = frequency; 00043 00044 } 00045