Design and implementation of memory data drawing for single chip microcomputer

Publisher:painterLatest update time:2014-11-06 Source: 21icKeywords:MCU Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

  This paper proposes a method to export data from the memory and use MATLAB to perform data conversion and drawing. The drawn graphics can well reproduce the analog signal source signal, which is helpful for microcontroller debugging and analysis.

  1 Theoretical Analysis

  The A/D converter is a bridge connecting analog signals and digital signals. Existing single-chip microcomputer chips usually have built-in ADC modules, and A/D sampling values ​​are usually stored in the on-chip memory in the form of bytes. To draw the A/D sampling data in RAM or Flash, set a breakpoint at the end of the storage during debugging, then export the stored data to the PC in the form of a notepad, design MATLAB software to convert the hexadecimal data in the notepad into decimal data, and finally draw the graph. Compare the drawn graph with the oscilloscope test simulation source graph to verify whether the drawn graph can accurately reproduce the original signal.

  2 System Hardware Design

  The system structure block diagram is shown in Figure 1. The entire system is designed with the MSP430 microcontroller as the core. This method is universal for other 16-bit microcontrollers. The system samples the data using the on-chip A/D converter and stores it in the RAM area. Then, the debugging breakpoint is set. With the help of the IAR debugging platform, the data is stored in the form of bytes to the PC. After conversion to decimal data by MATLAB, the data is plotted and analyzed, and compared with the waveform of the analog signal source measured by the oscilloscope.

  System structure diagram

  Figure 1 System structure diagram

  This system uses TI's single-chip microcomputer MSP430F5438 as the core of this system, and its features are as follows:

  ◆Reduced instruction set CPU core.

  ◆12-bit on-chip SAR ADC with programmable conversion rate up to 200 kbps.

  ◆16 KB internal data RAM and 256 KB Flash memory.

  ◆Three 16-bit counters with compare capture function, SPI and four general serial communication interfaces.

  ◆Low power consumption, down to 165μA@8 MHz in active mode, with multiple power-saving sleep and shutdown modes.

  3 System Software Design

  3.1 A/D sampling storage program

  This system uses the A/D module to set the query working mode, the sampling rate is configured to 4 ksps, the conversion resolution is 12 bits, and the internal reference voltage is 2.5 V. Due to the harsh industrial field environment, the collected signals cannot be used directly without processing. Therefore, the collected A/D values ​​are averaged and filtered to prevent the sampled values ​​from jittering. The sampled values ​​are averaged every 16 values ​​and stored in the area with the starting address of 3000H in the RAM area. 157 numbers are stored, and after the data is stored, other digital signal processing processes are transferred. The A/D sampling and storage program flow is shown in Figure 2.

  A/D sampling storage program flow

  Figure 2 A/D sampling storage program flow

  Run the program through the IAR debugging platform, set breakpoints, and save the data stored in RAM to the PC in a notepad file. The data format is shown in Figure 3. The data is stored in word format, that is, two bytes are one A/D conversion value, with the low byte first and the high byte last.

  A/D sampling value format and drawing graph

  Figure 4: Graph drawn after A/D sampling value format conversion

  This paper proposes a method to export data from the memory and use MATLAB to perform data conversion and drawing. The drawn graphics can well reproduce the analog signal source signal, which is helpful for microcontroller debugging and analysis.

  1 Theoretical Analysis

  The A/D converter is a bridge connecting analog signals and digital signals. Existing single-chip microcomputer chips usually have built-in ADC modules, and A/D sampling values ​​are usually stored in the on-chip memory in the form of bytes. To draw the A/D sampling data in RAM or Flash, set a breakpoint at the end of the storage during debugging, then export the stored data to the PC in the form of a notepad, design MATLAB software to convert the hexadecimal data in the notepad into decimal data, and finally draw the graph. Compare the drawn graph with the oscilloscope test simulation source graph to verify whether the drawn graph can accurately reproduce the original signal.

  2 System Hardware Design

  The system structure block diagram is shown in Figure 1. The entire system is designed with the MSP430 microcontroller as the core. This method is universal to other 16-bit microcontrollers. The system samples the data using the on-chip A/D converter and stores it in the RAM area. Then, the debugging breakpoint is set. With the help of the IAR debugging platform, the data is stored in the form of bytes to the PC. After conversion to decimal data through MATLAB, the data is plotted and analyzed, and compared with the waveform of the analog signal source measured by the oscilloscope. [page]

  System structure diagram

  Figure 1 System structure diagram

  This system uses TI's single-chip microcomputer MSP430F5438 as the core of this system, and its features are as follows:

  ◆Reduced instruction set CPU core.

  ◆12-bit on-chip SAR ADC with programmable conversion rate up to 200 kbps.

  ◆16 KB internal data RAM and 256 KB Flash memory.

  ◆Three 16-bit counters with compare capture function, SPI and four general serial communication interfaces.

  ◆Low power consumption, down to 165μA@8 MHz in active mode, with multiple power-saving sleep and shutdown modes.

  3 System Software Design

  3.1 A/D sampling storage program

  This system uses the A/D module to set the query working mode, the sampling rate is configured to 4 ksps, the conversion resolution is 12 bits, and the internal reference voltage is 2.5 V. Due to the harsh industrial field environment, the collected signals cannot be used directly without processing. Therefore, the collected A/D values ​​are averaged and filtered to prevent the sampled values ​​from jittering. The sampled values ​​are averaged every 16 values ​​and stored in the area with the starting address of 3000H in the RAM area. 157 numbers are stored, and after the data is stored, other digital signal processing processes are transferred. The A/D sampling and storage program flow is shown in Figure 2.

  A/D sampling storage program flow

  Figure 2 A/D sampling storage program flow

  Run the program through the IAR debugging platform, set breakpoints, and save the data stored in RAM to the PC in a notepad file. The data format is shown in Figure 3. The data is stored in word format, that is, two bytes are one A/D conversion value, with the low byte first and the high byte last.

  A/D sampling value format and drawing graph

  Figure 4: Graph drawn after A/D sampling value format conversion

  3.2 A/D sampling value data format conversion drawing program

  The data format is converted and plotted using MATLAB software, and the plotted graph is shown in Figure 4. The oscilloscope screenshot of the direct measurement of the analog signal source is shown in Figure 5.

  Oscilloscopes for direct measurement of analog signal sources

  Figure 5 Oscilloscope directly measuring analog signal source

  By comparing Figure 4 and Figure 5, it can be found that the value converted by A/D sampling data can correctly reproduce the original analog signal. This design method not only makes up for the deficiency that the microcontroller debugging platform cannot directly draw the data in the memory, but also shortens the debugging cycle of the microcontroller system, laying the foundation for subsequent digital signal processing.

  Conclusion

  This paper discusses the technology of drawing the A/D sampling data stored in RAM or Flash during the debugging process of the single-chip microcomputer, which makes up for the deficiency that the data in the storage area of ​​the single-chip microcomputer debugging platform cannot be directly drawn. The MSP430 single-chip microcomputer was tested as an example. The test results show that the design method is feasible in engineering practice and has high practical value.

Keywords:MCU Reference address:Design and implementation of memory data drawing for single chip microcomputer

Previous article:Design of a low power medical data recorder
Next article:SD storage and applications based on S3C2410

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号