Many of y'all are probably familiar with Ben Eater. I saw his tutorials on the 555 timer chip and thought, would it be possible to use it as a clock for the Atmega328? It would be nice since I can then single-step through my program which would make debugging way easier.
Using external clock - either 555 or some other source can be done and you can surely switch to single stepping. I think it can help in some timing sensitive tasks but I am not sure if it will help debugging much.
A 555 might not be fast enough to generate clean logic transitions(*) for a fast CMOS chip, put its output
through a 74HC14 or similar schmitt-trigger device to sharpen it up. Slow transitions on a logic input
can cause multiple clocking. I'd strongly recommend using a CMOS version of the 555, such as the 7555
to reduce power supply noise spikes.
A handy debugging technique for microcontrollers I use is to toggle an output pin in the code in key places,
so that a 'scope can observe timing - assuming you have a 'scope. With single-stepping you can use the
same trick but with LED to observe the pin.
(*) You might not realize that logic inputs generally have a minimum slew-rate specification - slow changes
in voltage can lead to undefined behaviour due to oscillation for instance, and will greatly reduce noise-immunity.
Often it is possible to enable the CKOUT fuse to monitor the timing sensitive sequences. I think it is more convenient than producing external clock.
MarkT:
(*) You might not realize that logic inputs generally have a minimum slew-rate specification - slow changes
in voltage can lead to undefined behaviour due to oscillation for instance, and will greatly reduce noise-immunity.
AVR already have Schmitt trigger on all its inputs. AFAIK minimum slew rate is not specified in the data sheet.
On an ATmega328, the ADC alone requires 25 ADC clock cycles for the first conversion and 13 cycles per subsequent conversion. How many CPU cycles that is depends on the ADC clock divider setting.
Add to that the cycles required to configure it, initiate the conversion and then read it out.
Does the ATmega328 have debug ability? I use PIC's and they can single-step debug through the IDE with the appropriate programmer/debugger device (PICKit).
MK1888:
Does the ATmega328 have debug ability? I use PIC's and they can single-step debug through the IDE with the appropriate programmer/debugger device (PICKit).