Attach to I2C. Make a simple logic analyzer

    Hello. I want to show a simple USB logic analyzer that can be assembled on any debug board with an STM32F042 microcontroller, for example, the NUCLEO-F042K6 from ST. And yet, on the links you will find the source code and easily remake it on any other of this family. This design has 8 channels. Under them in the microcontroller involved ports PA0-PA7. The maximum sampling rate is 8 MHz. The maximum frequency of the input signal is 2 MHz. The maximum number of samples per channel is 4096.

    Here it should be noted that the logic analyzer is hardware & software for capturing a signal and its subsequent research, measurement, and analysis of interfaces.



    The shell for the PC allows, after acquisition, to analyze the signals on all 8 channels, as well as
    measure the frequency of the signals, the period and the duration of the pulses. Calculate the number of fronts in the selected area, the duration of this area.

    And if you stick to the serial I2C interface and activate the analyzer, all I2C components will be automatically tinted and labeled in an easy-to-analyze form.

    The operation of the logic analyzer begins with clicking on the “Start capture” button. Then the following happens:

    1) The capture parameters are transferred to the device.
    2.a) If the trigger is not set, the capture of the signal begins immediately after receiving the capture parameters.
    2.b) If the trigger is set, the device analyzes the input signal without performing a capture. The signal capture begins after the detection of conditions set by the trigger.
    3) The capture buffer is filled in accordance with the specified number of samples.
    4) The device transmits data to the PC.
    5) The software processes and displays the data received.

    The trigger can be installed on one or several channels. If the triggers are set for several channels, the signal capture begins when all the conditions specified by the set triggers, i.e. between triggers operates a logical connection "And".
    You can change the name and color of each channel. The signal display area can be scrolled or scaled.

    Using the tool "Measurement" you can measure the duration of the selected area, period, frequency, pulse duration, count the number of fronts.

    The Ruler tool draws a vertical line covering the signals of all channels in the specified location with the time indicated. The “ruler” is convenient when evaluating the location of the fronts of different channels relative to each other and relative to the zero time mark.

    In this video on a simple example, you can see how it all works:



    In conclusion, I want to add that the shell is written in Visual Studio, the software for the microcontroller in IAR. In the near future I will present a 16+ channel logic analyzer with I2C, SPI, UART, I2S. Two microcontrollers are considered for construction: stm32f730, stm32f446.

    Thank you all, use on health!

    Download instructions, firmware and sketch.
    Download IAR project
    Download Visual Studio project

    Also popular now: