Home

22 Debugging

image

Contents

1. Commands Ris Objects and Libraries Address Spaces Sl Warnings Setup YA 5h Output Debug Tool Eh Debugger Current Simulator m EthemetSmartCable Simulator USBSmartCable Note OK Cancel Help Emulator e Inspect variables memory clock call stack disassemble code e Very useful for debugging software algorithms and logic e Often not helpful for debugging hardware drivers On Chip Debugger displayhex ZDS Z8 Encore Family main c Edt View Project Buid Tools Window Help osag hex 0 ___ memes w 8 9 9 HO EB E Bl Rl e 0 gt id Project Files main c 1 0x11 0x11 0x11 0x11 0x11 0 1 D counter 0x0000 zsldevinitasm Ox1 0x10 0x10 0xle 0x10 0x10 0x1 NUM 0x04D0 External Dependen new wat 0x1f 0x10 0x10 0x1e 0x10 0x10 0x10 data int NUM 0x0 main int counter 0 int i 0 init_led all off Context main X while 1 display hex counter 0x0000 T i 0x0C99 for 1 0 1 lt 0 1 NUM Project gt Debugger gt Setup gt Clock 18432000 Hz IBort com1 Baudrate 57600 On Chip Debugger e Inspect variables memory clock call stack disassemble code e Useful for debugging some types of hardware drivers accessing SFRs e Not always helpful for timing depen
2. INSULIN PUMP SYSTEM Real Time Embedded Systems www atomicrhubarb cony embedded Lecture 1 jJ anuary 17 2012 Topic Section Topic Where in the books Catsoulis chapter page Simon chapter page Zilog UM197 ao zer series Flash Microcontroller Contest Kit User Manual Zilog 171 ios Developer studio 11 ZNEO User Manual Zilog PS220 series Product Specification Zilog UM188 cu core User Manual Assorted datasheets My Program doesn t work What do do now Look for bugs bug An elusive creature living in a program that makes it incorrect The activity of debugging or removing bugs from a program ends when people get tired of doing it not when the bugs are removed Datamation January 15 1984 Debugging e Embedded systems present special problems for a programmer because they usually lack keyboards screens disk drives and other helpful user interfaces and storage devices that are present on business computers Debugging In Software Emulator Simulator Debug routines e In Hardware ICE in circuit emulator OCD On circuit debugger BDM background debug module Simulator Configuration Debug gt General Debugger E Assembler Use page erase before flashing i Code Generation Z16F2811FI ZDS Default Sil Preprocessor Sh Advanced ef Linker
3. NORM OFF HOLD Volts o VOLTS VOLTS DV N POS y MAG CaL COMPONENT t i 02V DUAL ADD me Oscilloscope ru TESTER a HOI Time Volts Div Time Div 0 01 sec Don t forget the ground clip Adjustment Tool Retractable x Hook Tip FX 4 4 Protector Connector Alligator Clip Ground Lead TDS220 SAVE RECALL MEASURE Tektronix TDS 220 DIGITAL REAL TIME OSC M CSGOPE UTILITY CURSOR NI VERTICAL HORIZONTAL IC 2 POSITION A Posmo m 3 omg 4 m N 3 n CH 2 HORIZONTAL MENU MENU VOLTS DIV VOLTS DIV SEC DIV OJO O l2 c D EXT TRIG Dual Trace 2 V T plots Triggering e Determine when to start plotting V T ae EUTRE ANR RN SEN FRE ME RE Por Positive 3 fi Volts Slope Negative Slope Input Signal Triggering F Slope with the BEES EO NI Expte fe sence with the TT Level Set to 3 v gt ACQUIRE ALITOSET oO UTILITY CURSOR DISPLAY HARDCOPY RUNISTOS C mi D VE
4. mcs 2 Timer output pins 20 0 20 40 50 80 100 120 140 160 180 200 220 240 3 Function calls gt oak PAL PAZ e Using an oscilloscope to indicate where we in the code execution Your Debug Methodology e Find a Development and Debug methodology that works for you e The Ten Secrets of Embedded Debugging http www embedded cony showAr ticle j html articlelD247208538 Embedded Debugging Know your tools Find memory problems early Optimize through understanding Don t put needles in your haystack Reproduce and isolate the problem Know where you ve been Make sure your tests are complete Pursue quality to save time See understand then make it work Harness the beginner s mind Know Your Tools e Good programmers need to be proficient with a variety of tools Each has a place each has power Source Debugger Emulator Simulator Simple printf In Circuit Emulator Profilers Compiler Assembler yes that s part of the debug cycle Find Memory Problems Early Memory problems are insidious They fall into three main types leaks fragmentation and corruption The best way to combat them is to find them early malloc free Use of mallc d memory after free Not completely writing to flash or being interrupted means we need to verify Optimize through understanding e Real time is more about reliability t
5. A 20m 200mA 1 5 Resetable fuse inside ACA 20m 200mA 2 0 Overmolding rubber handle OHM 200 2k 20k 200k 2M 20MQ 1 2 safety as per IEC1010 1 11 600V Logic Hi Lo test Audible continuity amp diode test Battery 1 5Vx2 AAA Dimensions 38x208x29mm Weight 110g approx Incl battery PEN TYPE METER 582110 tt YF REF 018211D0000 Y CE UL 5 CE LVD 1 Probe 2 Rotatable Probe Socket 3 LED Indicator 4 Protection Ring 5 Transform Switch 6 DATA H Button CORANGE Button 8 MAX H Button FUNC Button Panel DLCD Display COM Jack 7 9 0 1 12 DC 1 M H D H AUTO Direct current AC or DC alternating current or direct current Diode Continuity buzzer The maximum value is being held This indicates that the display data is being held Auto range The battery is not sufficient for proper operation lt XM sil al 9 8 3 Use the alligator clip Use it carefully 94 g N P J p IUD TRAIT EU CAT New OP vo When Done Turn off Retract the probe tip Put back in case Don t loose the pieces Debugging Summary e Simulator e On chip debugger e Status LEDs e printf e Use output pins and osci
6. RTICAL 4 HORIZONTAL 2 Move trace Move trace L A POSITION Postion S caren eft right up down display 9 hi N CH 2 HORIZONTAL TRIGGER MENI Mess with VOLTS DIV VOLTE DIV SEC DIV trig ger mode ub QUO volts div Calibrate 16 Connect probe here Change secs div No hardcopy e No We don t have the optional module that captures prints a copy of the display e They are old and only support HP ink jet printers with Centronix connectors 1995 Oscilloscope e Oscilloscope Tutorial https www cs tcd ie courses baict bac jf labs scope e XYZS of Oscilloscopes http www tek cony Measurement gi bin framed pl Document Measurem App Notes XYZs index html amp Fra meSet oscilloscopes So What can we really do with an oscilloscope to help with debugging software ES Use an oscilloscope to 1 Verify input signals is the clock signal really a clock 2 Use Timer output pins to verify timers are actually working like you want see the clock and measure the time 3 Use GPIO to Indicate function calls or function execution 1 Verify input signals 6 5 6 5 6 6 5 5 5 5 FES og ss 4 r A Ras 25 2 2 0 5 0 5 0 Y 0 PS 2 keyboard clock and data lines for keypress 2 2 400 200 0 200 400 600 800 1 000 1 200 Time
7. SS int main void assert str 0 B return 0 assert define assert e if e printf Assertion failure s file s line d n FILE LINE_ exit 1 Learn C e Read Practice Examine compiler output dissassembly Read some more e Pay attention to data types and what the compiler is doing with them automatic promotion casting etc e Cis complex enough on any system Now consider that with a bad compiler ona limited resource system with additional features for hardware access and limited debugging capability More Hardware e Learn to use basic functions of an oscilloscope and logic analyzer e Use them to check your output signals to verify your are generating what you intended e Use them to check your input signals to verify that you are receiving what you think your are receiving Whats the difference bewteen a Logic Analyzer and an Oscilloscope 3 Logic Analyzer VS Oscilloscope e Oscilloscopes are most useful in the domain of analog signals including analyzing analog problems such as noise ringing even when applied to digital signals They generally have a limited number of input channels 1 2 4 e Logic analyzers capture the state of digital signals They can have a wide number of input channels 8 16 32 And frequently include timing and data analysis How do use that Oscilloscope thingy R Oscilloscope TIME OW AT
8. dent things or external hardware Software Techniques e Using an LED to indicate position in code e Using LED array to display internal values 16 bit HEX 7 16 bit binary 4x 32 bit binary e Using printf to send data to serial port Use of OCD e If timing issues are suspected Save intermediate variables Step OVER that part of function Examine variables after the fact in watch local window e Use In Circuit Emulator In Circuit Emulator e Often called an ICE is an invaluable software developers tool in embedded design e The processor or microcontroller of the target hardware will be replaced by the ICE Often a smaller part of the emulator the pod is put into the hardware while the main emulator functionality resides in a box which is connected to the pod with cables ICE e An ICE can emulate the replaced processor or uC in real time The developer loads the program into the emulator and can then run step and trace into it much like it is done on PC s e Many emulators have more advanced features like performance analysis coverage analysis a trace buffer and advanced trigger and breakpoint possibilities ICE e The Z8 ICE 3 OOO No 216 version yet ICE e Inside the ICE or usually on the pod is a processor of the kind the emulator replaces or a special bond out version of the same chip e Bond out chips have normally internal signals and o
9. han speed That said efficient code 1 critical for many embedded systems Knowing how to make your code zing is a fundamental skill that every embedded programmer must master e The hard part is knowing which code to make run fast e Know how your CPU is executing your code It s the only path to efficiency Don t put needles in your haystack Follow your good coding and design guidelines check your assumptions rethink your algorithms If nothing else put an easily found tag in a comment that this code is suspect In other words follow good programming practices Reproduce and isolate the problem the critical first step is to reliably duplicate the problem recreate it then defeat it Get a sequence any sequence that reliably shows the problem and you re halfway there e Reduce your program to the minimum that reproduces the bug problem Know where you ve been e Version Control A backwards traceable record is a great way to make sure you understand future problems e When you get your application or module working in any significant Capacity checkpoint it Later when it stops working even though nothing has changed you will have a baseline to check your assumptions Make sure your tests are complete Coverage testing should be part of every quality assurance process How many revisions and rewrites has your code gone through over the years and releases Has yo
10. lloscope e Verify input signals with oscilloscope e Verify output signals Debugging summary e Examine compiler output e Turn off optimization e Use online forums for Q amp A e Think e Assume nothing verify everything g Photo NH 96566 KN First Computer Bug 1945 4 4 LA 7 w al den 9 7 Std Q c 032 MP TIE gt 725057 0a Pro 2 15047 7 2 0 5 Cove de Lans m fe 0 2 033 LA ip Led EUR _ FF 72 Started ua E devine Sin peel 15 25 Lo al em Test 1 Relay 70 E Fa LA Ce me of bug being found Ti ISAS First actua r s o studs 1700 Lead do
11. mment your code Particularly the hardware dependent parts Watch compiler warnings Fill allocated memory with value so you can see it in the debugger Code for Debug Fill malloc d space with some value before you free it So you can see it and to invalidate the data so you will get an error early in your development cycle if you attempt to use it after it has been freed Check array bounds Check string limits Check return types for validity before USING Check pointers for validity before using Code for debug e Refactor regularly e Quick and dirty works for simple proof of concept code It will cause you nothing but grief if it gets into your production professional code Assert e The 216 API includes the assert macro e include lt assert h gt assert Puts diagnostics into programs When it is executed if expression is false that is eval uates to zero the assert macro writes information about the particular call that failed including the text of the argument the name of the source file and the source line num ber the latter are respectively the values of the preprocessing macros FILE LINE on the serial port using putch function It then loops forever Synopsis include lt assert h gt void assert int expression Returns If expression 1 true that is evaluates to nonzero the assert macro returns no value Example include lt assert h gt char str COMPA
12. nner s mind e Most debugging is the process of learning more and more about your application e The beginner s mind is a Zen concept of emptying your mind so it can be open to new solutions Last Words Verify the easy obvious first Power wires proper timing signals as expected examine data in registers calculations for size overflow improper castsing e Unfortunately the Z16 tools do not contain some important tools Like Version control Execution profiler tracer Last words 2 e If developing embedded systems professionally pick your processor after considering the quality of the available tools not j ust the instruction set cost of the processor etc 5 NEWS gt BACK gt PRINT Software Bugs Can Be Lethal NEW YORK April 29 2003 AP When his dishwasher acts up and won t stop beeping Jeff Seigle turns it off and then on just as he does when his computer crashes Same with the exercise machines at his gym and his CD player Now I think of resetting appliances not just computers says Seigle a software developer in Vienna Va Malfunctions caused by bizarre and frustrating glitches are becoming harder and harder to escape now that software controls everything from stoves to cell phones trains cars and power plants Yet computer code could be a lot more reliable if only the industry were more willing to make it so experts say And many believe it would help if soft
13. r busses bonded out to its connector This iwill allow the ICE and the developer get a more complete picture of the status of the chip e Often emulators that use bond out chips have more features then those that dont Write for test and debug e Build a hardware abstraction layer Fix hardware bugs once Allows for rapid porting to another platform Isolates hardware software problems Allows for off platform debugging of logic algorithms Write for test e Build a test scaffold Build reusable and repeatable tests for verifying the ae hardware function through Application the abstraction layer Allows you to isolate the problems in your application Hardware or with the abstraction layer Separates debugging the application from debugging the hardware drivers Abstraction Another Platform e Many times logic and algorithms can be developed on another i platform One that supports BEEN better debugging gdb or less fooling around with DET hardware Hardware Replace hardware functions with simulated hardware functions Debugging is twice as hard as writing the code in the first place Therefore if you write the code as cleverly as possible you are by definition not smart enough to debug it Brian W Kernighan Code for Debug Write clear programs Cleverness is not usually clear And often hard to figure out weeks months later Co
14. ur test suite grown with the changes Or do the tests only exercise the features that existed in version 1 0 Pursue quality to save time It costs 10 to 200 times more to fix a bug at the end of the cycle than at the beginning The cost of a small bug that makes it to the field can be astronomical Even if the bug doesn t have a significant impact on performance it can significantly affect perceived quality Average Cost per Bug Xs 15 20 40 15 10 R D C U I S P R Distribution Where 100 Bugs Are Detected Legend R D Requirements Gathering and Analysis Architectural Design C U Coding Unit Test 5 Integration and Component RAISE System Test E R Early Customer Feedback Beta Test Programs P R Post product Release Why is this Why Programs grow more complex e Fixing later requires more thought to figure out why things are e Documentation needs to be updated e Other code depends on this bug feature e Testing is now more complex See understand make it work e real time systems interact with dynamic world traditional debuggers can t reveal dynamic behavior Questions like How noisy is my sensor How fast is the queue growing When did the valve close e There simply cannot be answered by any tool that stops the execution These questions deal directly with the dynamic behavior of the real world system Harness the begi
15. ware makers were held accountable for sloppy programming A poorly programmed ground based altitude warning system was partly responsible for the 1997 Korean Air crash in Guam that killed 228 people Faulty software in anti lock brakes forced the recall of 39 000 trucks and tractors and 6 000 school buses in 2000 Of course more deaths are caused by human error than by bad software and modern society would be unthinkable without Web servers word processors and autopilot But software s usefulness means people tolerate it even when quality is not the best Last year a study commissioned by the National Institute of Standards and Technology found that software errors cost the U S economy about 59 5 billion annually or about 0 6 percent of the gross domestic product More than half the costs are borne by software users the rest by developers and vendors Most software is thrown together with insufficient testing says Peter Neumann principal scientist at SRI International s Computer Science Laboratory in Menlo Park Calif The idea that we depend on something that s inherently untrustworthy is very frightening he says How use that multi meter thingy MS8211D PEN TYPE AUTO RANGING TESTER m 3 1 2 digits LCD max reading 1999 Technical specifications Logic level test DCV 200m 2 20 200 600V 0 7 m Data hold maximum value hold ACV 200m 2 20 200 600V 0 8 m Auto manual range auto power off DC

Download Pdf Manuals

image

Related Search

Related Contents

DESKTOP V3 - Just Music  tripod evo  車速信号配線一覧表  Dossier de presse 2002 - Festival de Marseille  Hamilton Beach 42471 Coffeemaker User Manual  Diagnosi della vibrazione  Edimax EW-7101PCG  

Copyright © All rights reserved.
Failed to retrieve file