TimeScope
Version 19 (Anthony Rowe, 08/24/2007 11:46 pm)
| 1 | 3 | Anthony Rowe | [[Image(timescope-board.png)]] |
|---|---|---|---|
| 2 | 1 | Anthony Rowe | = FireFly TimeScope = |
| 3 | 1 | Anthony Rowe | |
| 4 | 17 | Anthony Rowe | Have you ever wanted to throb a GPIO pin or hook an o-scope up to an LED for timing information? FireFly TimeScope is a utility built into all FireFly programmers that allows logic analyzer style debugging without interfering with serial output or bogging down the microcontroller with the large blocking times required for serial, SPI or I2C data transfers. Developers can assert and clear four different debugging gpio pins on the FireFly board that are captured by the programmer board and can be used to generate timing waveforms. At the most basic level, this can be used to time various section of code. APIs on the FireFly node can also use this interface to send 4 bits of high speed debugging data back to your computer to track state transitions. The connections from the FireFly debugging board can even be linked to external logic devices that you wish to probe. TimeScope will give you in the worst case a 258 microsecond sampling peroid (3.875KHz) due to the time it takes to send the three bytes of payload over the UART. If signals do not occur back-to-back, then the factor limiting the resolution is the timestamping period of 36 microseconds (27.7KHz). |
| 5 | 6 | Anthony Rowe | |
| 6 | 1 | Anthony Rowe | |
| 7 | 11 | Anthony Rowe | |
| 8 | 11 | Anthony Rowe | == How It Works == |
| 9 | 11 | Anthony Rowe | |
| 10 | 11 | Anthony Rowe | |
| 11 | 9 | Anthony Rowe | The USB FireFly programmer loads as two virtual serial port interfaces. Normally, one serial port is used for debugging input and output while the second serial port can be used to download code to the FireFly board. The code downloading is achieved using a dedicated processor on the programming board that translates serial commands into the AVR ISP flashing protocol. The FireFly programming interface also connects various other GPIO pins from the main FireFly processor to the programming boards processor. While not downloading, this second processor can monitor when pin changes occur on FireFly board and report these back to your PC over the second serial port. We have a simple 3 byte serial protocol that sends the pin states along with a time stamp from the internal clock running on the programmer board. The first byte can always be synchronized off of since it is the only byte with a 1 in the MSB. |
| 12 | 9 | Anthony Rowe | |
| 13 | 9 | Anthony Rowe | [[Image(packet.png)]] |
| 14 | 9 | Anthony Rowe | |
| 15 | 1 | Anthony Rowe | C3, C2, C1, and C0 stand for the different channels coming in and map to the NRK_DEBUG_0, NRK_DEBUG_1, NRK_DEBUG_2, and NRK_DEBUG_3 pins. Mn is the nth bit of the most significant byte of the time stamp, while Ln refers to the nth bit of the least significant byte. Whenever the there is a pin change or a timer overflow, a packet is transfered to the PC. |
| 16 | 1 | Anthony Rowe | |
| 17 | 11 | Anthony Rowe | |
| 18 | 14 | Anthony Rowe | == How You Use It == |
| 19 | 11 | Anthony Rowe | |
| 20 | 12 | Anthony Rowe | * '''Add debugging statements into your code''' |
| 21 | 11 | Anthony Rowe | * On the FireFly version 2.2 boards there are four debugging pins defined: |
| 22 | 11 | Anthony Rowe | * NRK_DEBUG_0, NRK_DEBUG_1, NRK_DEBUG_2 and NRK_DEBUG_3 |
| 23 | 11 | Anthony Rowe | * They can be toggled as follows: |
| 24 | 11 | Anthony Rowe | {{{ |
| 25 | 11 | Anthony Rowe | #!c |
| 26 | 11 | Anthony Rowe | // toggle the pin state |
| 27 | 11 | Anthony Rowe | nrk_gpio_toggle(NRK_DEBUG_3); |
| 28 | 11 | Anthony Rowe | // set the pin |
| 29 | 11 | Anthony Rowe | nrk_gpio_set(NRK_DEBUG_0); |
| 30 | 11 | Anthony Rowe | // clr the pin |
| 31 | 11 | Anthony Rowe | nrk_gpio_clr(NRK_DEBUG_2); |
| 32 | 11 | Anthony Rowe | }}} |
| 33 | 1 | Anthony Rowe | |
| 34 | 19 | Anthony Rowe | * '''Download and run some code''' |
| 35 | 12 | Anthony Rowe | * As an example, try running the basic_tasks project |
| 36 | 12 | Anthony Rowe | * You will see here that not only do LEDs get toggled, but so do the NRK_DEBUG_x pins |
| 37 | 19 | Anthony Rowe | * '''Complile and Run TimeScope''' |
| 38 | 12 | Anthony Rowe | * You may wish to hold the FireFly board in reset before you run TimeScope so that you know that starting point of the waveform |
| 39 | 12 | Anthony Rowe | * Try running TimeScope as follows to generate a Decsim ascii waveform file: |
| 40 | 12 | Anthony Rowe | {{{ |
| 41 | 12 | Anthony Rowe | > cd nano-RK/tools/TimeScope |
| 42 | 12 | Anthony Rowe | > make |
| 43 | 12 | Anthony Rowe | gcc -c -o main.o main.c -I. |
| 44 | 12 | Anthony Rowe | gcc -o TimeScope main.o -I. |
| 45 | 12 | Anthony Rowe | > ./TimeScope /dev/ttyUSB1 -DECSIM log.tra |
| 46 | 1 | Anthony Rowe | |
| 47 | 12 | Anthony Rowe | }}} |
| 48 | 12 | Anthony Rowe | * In this example /dev/ttyUSB1 is the port that you normally program with and log.tra is the tracefile it will save |
| 49 | 12 | Anthony Rowe | * Be sure to close this when programming (press ctrl-c to kill it) |
| 50 | 13 | Anthony Rowe | * Below is a screenshot of it running with the normal terminal debugging on the right |
| 51 | 16 | Anthony Rowe | [[Image(terminals.png,640)]] |
| 52 | 18 | Anthony Rowe | * '''View the data (Show You, Show Me)''' |
| 53 | 13 | Anthony Rowe | * TimeScope will generate two different data formats |
| 54 | 13 | Anthony Rowe | * Decsim ASCII as well as a raw ASCII format |
| 55 | 13 | Anthony Rowe | * Programs like [http://www.veripool.com/dinotrace/ DinoTrace] can be used to view the output |
| 56 | 13 | Anthony Rowe | * Below is a screenshot of dinotrace reading the waveform file from basic_task |
| 57 | 10 | Anthony Rowe | [[Image(dinotrace.png,500)]] |