Hot answers tagged

22

Since the code snippet you're interested in isn't big, you could disassemble your compiled code, look at all the assembly instructions and count how many cycles they need. You can find the number of cycles for each instruction in the datasheet. If you have an oscilloscope, you can turn on a pin before the if statement and turn it off after your code snippet. ...


14

Let's do it! Say we have the code int main(void) { volatile uint8_t val = 0; while (1) { if ((PIND & (1 << PIND6)) == (1 << PIND6)) { val = 1; } else { val = 0; } } } Say we use AVR GCC with optimization flag -O1, then the disassembly of the relevant section looks like this: ...


11

I normally use the built-in simulator of Atmel Studio which has a cycle counter in the processor status window. This is a combined screenshot from stepping though the code: ] As you can see, the cycle counter is 18 before and 22 after stepping through the two statements. So according to the simulator it takes 4 cycles. You can use this to step through the ...


8

If speed is important for this code, the following is probably noteworthy: You could just write val = (PIND & (1 << PIND6)) != 0; or val = 1 & (PIND >> PIND6); I guess the last one is shorter/faster. Concerning speed/time estimation: Either let your compiler generate an assembler listing file (*.lst) or look at the disassembled ...


3

Quick solution: Use a CS2000 or CS2100 Smart PLL (requires a crystal oscillator), use a cheap micro to talk to it via I2C at power-up, set it to multiply 48kHz by 250x, output 12 MHz, done. You'll have to read the datasheet for details, but it doesn't look too complicated. Here's the product page. This is the chip XMOS uses in their eval boards to generate ...


2

Neither the 4060 nor the 4521 will get you to a 1Hz output from a 32768 Hz crystal by itself. You need a division of 2^15. The least a 4521 will divide by is 2^17. The most a 4060 will divide by is 2^14, which needs another /2 from some suitable source. You could use an HC74, or CD4013, or one stage of an HC393 or 390, there are a lot of different ICs that ...


2

As already commented, the accuracy doesn't depend on frequency. It does significantly depend on temperature. What Is ‘High Accuracy Quartz’? Most watches rocking a quartz movement are guaranteed accurate to around 15 seconds a month or so. This is still much better than even the best mechanical watches, but there’s a breed of quartz watches out there ...


2

You want to clock synchronously ADCs at different locations? Why would you want to do that? Even microphones that are a few meters apart will record same phenomenom at different sampling points. So just store the GPS timestamp data along with your recording (as far as I know, many DSLR audio recorders meant for video production do this already and there's a ...


1

In case the CDCM6208 solution feels much simpler than the following, this is TI's CDCM6208 evaluation board. Strip most of that off as unneeded and it is still "impressive". You may find that a GPS disciplined oscillator works well for you. These use GPS to 'nudge' an oscillator in the right direction. While you can spend large amounts on commercial units, ...


1

$$ \text{Frequency} = \frac{1} { \text{Clock time} } $$ or $$ \text{Clock time} = \frac{1} { \text{Frequency} } $$ $$ \text{Clock time} = \frac{1} { \text{Frequency} } = \frac{1} { 100 \text{ MHz} } $$ $$ = \frac{1}{ (1 \cdot 10^2 \cdot 10^6) \text{ Hz} } = \frac{1}{ (1 \cdot 10^8) \text{ Hz} } = 1 \cdot 10^{-8} \text{ s} = 1 \cdot 10^1 \cdot 10^{-9} s = ...


1

I looked up an old Z80 computer design from the 80ies (the mc CP/M-Computer). It also used an oscillator with 7404 gates: The capacitor used there is 10nF. So I guess values in the pF range are much too small.


1

This is just to teach you why your TTL oscillator fails in this Pierce series resonant mode, you have to see how TTL works. Fixes change 100pF to 10nF to eliminate phase shift at 3.5MHz add 2.4k input to ground to pull output >> 2.0V towards 2.4V (opt.) The impedance of 100pF is too high and = 1 k @ 3.5MHz so you get a bad 45 phase shift twice and the ...


Only top voted, non community-wiki answers of a minimum length are eligible