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, write to the Free Software
15 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 * Functions for causing delays.
30 void delay(WORD millis
);
34 * some registers (r/w) require syncdelay after
36 * up to the programmer to determine which sync is needed.
37 * for standard 48mhz clock w/ 48mhz IFCONFIG 3 nops is sufficient.
39 * slower clock and faster ifclock require more delay
41 * min delay = roof ( 1.5 x (ifclock/clkout + 1) )
43 * Minimum IFCLOCK is 5mhz but you have to use an
44 * external clock source to go below 30mhz
46 * IFCLKSRC 1 = internal, 0=external
47 * 3048mhz 0 = 30mhz, 1 = 48mzh
49 * Figure your own sync delay out if IFCLKSRC=0.
52 #define NOP __asm nop __endasm
55 * SYNCDELAY2 can work for the following clock speeds
60 * ceil(1.5 * (20.8 / 83.3 + 1)) = 2
65 #define SYNCDELAY2 NOP; NOP
68 * SYNCDELAY3 can work for the following clock speeds
78 #define SYNCDELAY3 NOP; NOP; NOP
81 * SYNCDELAY4 should be used for the following speeds
88 #define SYNCDELAY4 NOP; NOP; NOP; NOP
91 * All the SYNCDELAYs you could possibly want for other speeds
95 #define SYNCDELAY5 NOP; NOP; NOP; NOP; NOP
96 #define SYNCDELAY6 NOP; NOP; NOP; NOP; NOP; NOP
97 #define SYNCDELAY7 NOP; NOP; NOP; NOP; NOP; NOP; NOP
98 #define SYNCDELAY8 NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP
99 #define SYNCDELAY9 NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP
100 #define SYNCDELAY10 NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP
101 #define SYNCDELAY11 NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP
102 #define SYNCDELAY12 NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP
103 #define SYNCDELAY13 NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP
104 #define SYNCDELAY14 NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP
105 #define SYNCDELAY15 NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP
106 #define SYNCDELAY16 NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP