This section is to offer tips and tricks to help the engineers and students who are developing their embedded circuits -- hopefully using Maramil products!
If anyone wants to submit their own embedded development and debugging tips and tricks, please do and we will give you full credit by publishing your name, company, email address and URL (unless you don't want it published) with your tip(s) or trick(s). Please include the words 'Embedded Tips & Tricks' at the top of your contact with us.
If you submit, please try to keep it generic, i.e., ideas that can be used in a wide variety of scenarios not to a specific part or family of parts. Note that the submitted tip or trick may be edited for clarity and format.
Development -- High Frequency Signals and Clocks Routing
When routing a signal or clock line of over 1 MHz more than a few inches in a breadboarded circuit consider using a coaxial cable with the shielding braid attached to the circuit ground. Typical RG 59 mini-coax or something similar should work nicely. Oscilloscope use coaxial cables to get very high frequency signals into the scope for measurement, so coaxial cable should route those high frequency signals and clocks in the breadboarded circuit just fine.
In a pinch, we have used a shielded audio cable -- didn't have any coax available -- to successfully route a 6 MHz clock signal about 12 inches [30.5 cm]. To prove that it worked, we used regular unshielded wire and the circuit would not work, but when we used the shielded audio cable, it did! In our case, we made sure that the bare ground wire in the audio cable was attached to circuit ground. Poor man's coax :)
Why do we need to do this? Because today's digital electronics wants to see relatively square edges on its digital signals. At the MHz frequencies, unshielded wires are basically LC circuits that act as filters and remove the higher frequency components from the signal, i.e., they round the edges of the square signal. -- Maramil Staff, www.maramil.com
Debugging -- Measuring Microcontroller Routine Execution Times with an Oscilloscope
How long does it take a subroutine or section of code to execute? You could manually count clock cycles from the program listing and figure it out but since microcontrollers operate mainly in an interrupt environment, is that going to be accurate? Are there higher priority interrupts choking the routine's time slice?
To find the execution time, in the very first line of the subroutine or code section, set a spare data line to high. At the very end of the subroutine or code section, set that same data line to low. Toggling a data line is a usually a very fast operation, so it adds very little overhead. Attach a scope probe to that data line and measure it. The time that the data line is asserted is how approximately long the routine has taken to execute. Modern digital scopes can sample aperiodic signals better than analog scopes. When using an analog scope, this approach works better when the subroutine or code section is called in a periodic manner like through a timer interrupt.
-- Maramil Staff, www.maramil.com
More to Come...
|