uC chip interface arduino  0.9.0
A interface for async and neuromrphic IC testing
Loading...
Searching...
No Matches
misc_functions.cpp
Go to the documentation of this file.
1/*
2 This file is part of the Firmware project to interface with small Async or Neuromorphic chips
3 Copyright (C) 2022 Matteo Cartiglia - University of Zurich
4 Copyright (C) 2022-2023 Ole Richter - University of Groningen
5
6 This program is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <https://www.gnu.org/licenses/>.
18*/
19
20#include "misc_functions.h"
21
31void delay20ns( uint8_t clocks )
32{
33 #if (F_CPU<=50000000)
34 clocks = 1 + clocks >> 3;
35 #elif (F_CPU<=100000000)
36 clocks = 1 + clocks >> 2;
37 #elif (F_CPU<=200000000)
38 clocks = 1 + clocks >> 1;
39 #endif
40 do
41 {
42 __asm( "nop" );
43 #if (F_CPU>400000000)
44 __asm( "nop" );
45 #endif
46 #if (F_CPU>450000000)
47 __asm( "nop" );
48 #endif
49 #if (F_CPU>500000000)
50 __asm( "nop" );
51 #endif
52 #if (F_CPU>550000000)
53 __asm( "nop" );
54 #endif
55 #if (F_CPU>600000000)
56 __asm( "nop" );
57 #endif
58 #if (F_CPU>650000000)
59 __asm( "nop" );
60 #endif
61 #if (F_CPU>700000000)
62 __asm( "nop" );
63 #endif
64 #if (F_CPU>750000000)
65 __asm( "nop" );
66 #endif
67 #if (F_CPU>800000000)
68 __asm( "nop" );
69 #endif
70 #if (F_CPU>850000000)
71 __asm( "nop" );
72 #endif
73 #if (F_CPU>900000000)
74 __asm( "nop" );
75 #endif
76 #if (F_CPU>950000000)
77 __asm( "nop" );
78 #endif
79 #if (F_CPU>1000000000)
80 __asm( "nop" );
81 #endif
82 #if (F_CPU>1100000000)
83 __asm( "nop" );
84 __asm( "nop" );
85 #endif
86 #if (F_CPU>1200000000)
87 __asm( "nop" );
88 __asm( "nop" );
89 #endif
90 #if (F_CPU>1300000000)
91 __asm( "nop" );
92 __asm( "nop" );
93 #endif
94 #if (F_CPU>1400000000)
95 __asm( "nop" );
96 __asm( "nop" );
97 #endif
98 #if (F_CPU>1500000000)
99 __asm( "nop" );
100 __asm( "nop" );
101 #endif
102 #if (F_CPU>1600000000)
103 __asm( "nop" );
104 __asm( "nop" );
105 #endif
106 #if (F_CPU>1700000000)
107 __asm( "nop" );
108 __asm( "nop" );
109 #endif
110 #if (F_CPU>1800000000)
111 __asm( "nop" );
112 __asm( "nop" );
113 #endif
114 #if (F_CPU>1900000000)
115 __asm( "nop" );
116 __asm( "nop" );
117 #endif
118 #if (F_CPU>2000000000)
119 __asm( "nop" );
120 __asm( "nop" );
121 #endif
122 #if (F_CPU>2100000000)
123 #error what uC are you running? function delay20ns only works till 2GHz
124 #endif
125 }
126 while ( --clocks );
127}
128
129
130
void delay20ns(uint8_t clocks)
kinda accurate for CPU ferquencies from 400MHz-2GHz, below the resolution becomes more coarse as it m...