Miao-T / VirtualOscilloscope

MM32 uses a virtual oscilloscope via UART

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Virtual Oscilloscope of MM32 Based on ShanWai Debugging Assistant

Introduction

The virtual oscilloscope on ShanWai Multifunctional Debugging Assistant could help us to observe the real-time change of data when we are debugging MM32 chip.

Characteristics of ShanWai Virtual Oscilloscope:

  • Support eight channels and every channel could be hidden

  • Selectable channel data type

  • Scalable and removable interface

  • Trace update data

Communication protocol of of ShanWai Virtual Oscilloscope:

  • The format of communication protocol: [CMD][~CMD][…data…][~CMD][CMD]

  • CMD = 0x03 when debugging assistant is used as virtual oscilloscope:

    [0x03][0xFC][…data…][0xFC][0x03]

  • […data…] will shown as waveform. The length of data is different according to the amount of wave channel and data type.

  • The microcontroller would transmit data in this order:

    1. Frame head: 0x03 0xFC
    2. The data of waveform
    3. End of frame: 0xFC 0x03

For more details: Instructions of ShanWai Debugging Assistant

Solution: Output Triangular Wave

The following codes refer to 「顶点元」STM32使用虚拟示波器

  1. Configure UART

    void initUART1_IT(u32 baudrate);
  2. Transmit one byte data

    void usart1_send_char(uint8_t ch);
  3. Transmit an array data

    The length of the array represents the amount of channel.

    void usart1_putbuff (uint8_t *buff, uint32_t len);
  4. Transmit data to upper computer according to communication protocol

    void vcan_sendware(uint8_t *wareaddr, uint32_t waresize);
  5. Output triangular wave image

Solution: Output ADC Wave

  1. The code of UART configuration and data transmission is the same as above

  2. Configure ADC

    void ADC_Configure_Init(ADC_TypeDef* ADCx);
    void Set_ADC_Clock(ADC_TypeDef* ADCx);
    void ADC_Function(ADC_TypeDef* ADCx);
    void ADC_RegularChannelConfigure(void);
  3. Output ADC wave

    warebuf[1] = (float)ADC_ConvertedValue*(3.3/4096);

    image

CSDN

For more details, please read 「Rose Island」山外多功能调试助手用作MM32虚拟示波器

About

MM32 uses a virtual oscilloscope via UART


Languages

Language:C 98.3%Language:C++ 1.4%Language:Batchfile 0.3%