Specifications

Chapter 6 - Samples
If we use the oscillator (resonator) of 4MHz, for prescaler values 0, 1, and 7 that divide the basic
clock of the oscillator, the interval followed by an overflow of timer TMR0 will be 0.512, 1.02 and
65.3 mS. Practically, that means that the biggest delay would be 256x65.3mS which is equal to
16.72 seconds.
In order to use macros in the main program it is necessary do declare variables wcycle and
prescWAIT as will be done in examples which follow in this chapter.
Macro WAIT has one argument. The standard value assigned to prescaler of this macro is 1
(1.02mS), and it can not be changed.
WAIT timeconst_1
timeconst_1 is number from 0 to 255. By multiplying that number with the overflow time period
we get the total amount of the delay: TIME=timeconst_1 x 1.02mS.
Example: WAIT .100
Example shows how to make a delay of 100x1.02mS, or total of 102mS.
Unlike macro WAIT, macro WAITX has one more argument that can assign prescaler value. Macro
WAITX has two arguments:
Timeconst_2 is number from 0 to 255. By multiplying that number with the overflow time period
we get the total amount of the delay:
TIME=timeconst_1 x 1.02mS x PRESCext
PRESCext is number from 0 to 7 which sets up the relationship between a clock and timer TMR0.
Example: WAITX .100,7
Example shows how to make a delay of 100x65.3 mS, or total of 653mS.
Macro PRINT
Macro PRINT is found in Print.inc file. It makes it easy to show a string of data on one of the
output devices such as : LCD, RS232, matrix printer...etc. The easiest way to form a series is by
using a dt (define table) directive. This instruction stores a series of data into program memory as
a group of retlw instructions whose operand is data from the string.
http://www.mikroelektronika.co.yu/english/product/books/PICbook/6_02Poglavlje.htm (2 of 4) [4/2/2003 16:18:43]