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:
- Frame head: 0x03 0xFC
- The data of waveform
- End of frame: 0xFC 0x03
For more details: Instructions of ShanWai Debugging Assistant
The following codes refer to 「顶点元」STM32使用虚拟示波器
-
Configure UART
void initUART1_IT(u32 baudrate);
-
Transmit one byte data
void usart1_send_char(uint8_t ch);
-
Transmit an array data
The length of the array represents the amount of channel.
void usart1_putbuff (uint8_t *buff, uint32_t len);
-
Transmit data to upper computer according to communication protocol
void vcan_sendware(uint8_t *wareaddr, uint32_t waresize);
-
The code of UART configuration and data transmission is the same as above
-
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);
-
Output ADC wave
warebuf[1] = (float)ADC_ConvertedValue*(3.3/4096);
For more details, please read 「Rose Island」山外多功能调试助手用作MM32虚拟示波器