1 // Copyright (C) 2009 Ubixum, Inc.
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, see <http://www.gnu.org/licenses/>.
17 * Functions for causing delays.
29 void delay(WORD millis);
33 * some registers (r/w) require syncdelay after
35 * up to the programmer to determine which sync is needed.
36 * for standard 48mhz clock w/ 48mhz IFCONFIG 3 nops is sufficient.
38 * slower clock and faster ifclock require more delay
40 * min delay = roof ( 1.5 x (ifclock/clkout + 1) )
42 * Minimum IFCLOCK is 5mhz but you have to use an
43 * external clock source to go below 30mhz
45 * IFCLKSRC 1 = internal, 0=external
46 * 3048mhz 0 = 30mhz, 1 = 48mzh
48 * Figure your own sync delay out if IFCLKSRC=0.
51 #define NOP __asm nop __endasm
54 * SYNCDELAY2 can work for the following clock speeds
59 * ceil(1.5 * (20.8 / 83.3 + 1)) = 2
64 #define SYNCDELAY2 NOP; NOP
67 * SYNCDELAY3 can work for the following clock speeds
77 #define SYNCDELAY3 NOP; NOP; NOP
80 * SYNCDELAY4 should be used for the following speeds
87 #define SYNCDELAY4 NOP; NOP; NOP; NOP