Design and application of BSL programming tool for MSP430 microcontroller

Publisher:ChanheroLatest update time:2016-03-17 Source: 21icKeywords:MSP430 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
introduction

Texas Instruments ' MSP430 series microcontrollers are widely used in intelligent instruments, medical electronics, consumer electronics, etc. Most MSP430 series microcontrollers have non-volatile Flash memory. There are generally two ways for users to debug or update programs in Flash: JTAG and Bootstrap Loader (BSL).

The MSP430 series microcontrollers have an integrated JTAG simulation debugging module, and the parallel port converter can be used as a low-cost JTAG hardware simulation debugging tool. However, in order to protect the user program code, the fuse inside the MSP430 microcontroller must be burned after the product development is completed, which makes it impossible for the MSP430 microcontroller to access the CPU or update the user program in the Flash through the JTAG interface. If you want to access or update the user program in the Flash again, you need to use the BSL interface. The BSL interface is also the only way to upgrade the program of the MSP430 microcontroller after the fuse is burned.

The MSP430 series microcontrollers have a boot code, namely BSL, solidified in a specific memory space when they leave the factory. This boot code can be entered by adding a specific timing on a specific pin of the microcontroller. Users can then access the internal resources of the microcontroller, such as Flash, RAM, etc., through a standard asynchronous serial port (a password verification is required for read operations). This provides a convenient way to upgrade and maintain embedded applications.

A low-cost, easy-to-use, and simple-to-operate BSL programming tool is designed and implemented using a USB-to-serial port chip and VB6.0 programming language. It can erase, program, automatically download files, sound prompts, and automatically run codes for the MSP430 series microcontrollers through the serial port. The overall design block diagram of the system is shown in Figure 1.

a.jpg

1 System Hardware Design

The hardware of the BSL programming tool is designed using the USB to serial port chip PL2303, which has the advantages of easy use and low design cost. PL2303 is a USB bus conversion chip produced by Prolific, which has all modem control signals such as TXD, RXD, DTR, RTS, etc., and can realize USB to 3.3 V or 5 V full-duplex serial port TTL level.

After the PL2303 chip is connected to the PC, a virtual serial port device will be generated. Using the MSComm serial port control provided by VB6.0 for programming, TXD, RXD, DTR, and RTS can be controlled to generate the required timing signals. Although the same function can be achieved using the physical serial port of the PC, not every PC has a physical serial port. The USB-to-serial port chip eliminates the limitation of the physical serial port for this programming tool and can provide power for the MSP430 microcontroller. Therefore, PL2303 is an ideal choice for mobile systems and embedded systems, and its small package can be embedded in any connector and handheld device.

This programming tool connects the DTR and RTS pins of the PL2303 chip to the RST and TCK (or TEST) pins of the MSP430 series microcontrollers. If the MSP430 microcontroller has a TEST pin, the TCK pin should be replaced by the TEST pin. TXD and RXD are the serial port sending and receiving pins, which need to be connected to the corresponding BSL pins of the MSP430 microcontroller. The receiving and sending pins of different microcontrollers are not exactly the same. The fourth pin VDD_325 of the PL2303 chip is used to determine the logic level of the control signal. The MSP430 series microcontrollers all have a 3.3 V operating voltage. Therefore, VDD_325 should be connected to 3.3 V so that TXD, RXD, DTR and RTS can generate a 3.3 V logic level. AMS1117 is used to convert 5 V voltage to 3.3 V voltage. In addition to providing voltage to VDD_325, it can also provide 3.3 V power to the external MSP430 microcontroller. The schematic diagram of the system hardware design is shown in Figure 2.

b.jpg

2 System Software Design

The software design of BSL programming tool is realized by VB6.0. Although the software design can be realized by using VC++, Delphi and other programming tools, choosing VB6.0 has more advantages because VB is a relatively simple event-driven programming language with low requirements for beginners. VB has a graphical user interface and rapid application development system, and the software design can be completed by using the components it provides.

2.1 Introduction to BSL Timing of MSP430 MCU

To make the MSP430 microcontroller enter the BSL reset vector, a specific timing needs to be applied to the RST and TCK (or TEST) pins of the microcontroller. After the MSP430 microcontroller receives this specific timing, the CPU program pointer (PC) points to the address 0x 0C00, which is a 1 KB ROM area (0x 0C00 ~ 0x 1000).

When the BSL program starts to execute, the TCK pin has received at least two negative jumps, and when RST jumps from low to high, TCK remains at a low level. At this time, the MSP430 microcontroller enters the BSL state; if it is an MSP430 microcontroller with a TEST pin, the TCK pin should be replaced by the TEST pin, and the TEST pin receives at least two positive jumps, and when RST jumps from low to high, TEST remains at a high level. The MSP430 microcontroller BSL startup timing is shown in Figure 3.

c.jpg

2.2 BSL serial communication protocol

The MSP430 microcontroller uses an internal timer to simulate serial communication timing on specific pins. The P1.1 pin of most MSP430 microcontrollers is used as the transmitter of the BSL (ie, TXD), and the P2.2 pin is used as the receiver of the BSL (ie, RXD). Different models of microcontrollers will have different timings.

The default serial port protocol of the MSP430 microcontroller is: 9600 baud rate, half-duplex mode, 1 start bit, 8 data bits (the lowest bit first), 1 even parity bit, 1 stop bit. The handshake is carried out through a confirmation character. Before sending any command, a synchronization character with a value of 80H must be sent to the BSL, which provides the BSL system time base. After the BSL receives the synchronization character, it will send a 90H character to confirm successful reception.

The commands provided by BSL to users are mainly divided into two categories: one type of commands requires a password to be executed, such as accessing the MCU Flash, RAM, and peripherals; the other type of commands can be executed without a password, such as erasing the Flash as a whole, reading the BSL version, etc. The data frame format of some BSL commands is listed in Table 1.

d.jpg

Among them, the 8 bytes from HDR to LH are required, xx represents any data; data D1~Dn are optional; CKL is the low bit of the checksum, CKH is the high bit of the checksum, these two bytes are required; ACK confirmation byte is not required for every command.

2.3 BSL software design

In BSL software design, several key controls in VB6.0 are mainly used, such as MSComm, CommandDialog, ComboBox, Timer, TextBox, ProgressBar, CommandButton, CheckBox and other standard controls.

The program file format downloaded by the BSL programming software is the TI company's txt plain text format. It uses "@" to indicate the start of the address, and the data content to be stored starting from the address is indicated after the address. Each line after the address is 16 bytes, each byte is represented by a hexadecimal number, and each two bytes are separated by a space. Every time an "@" character is encountered, it indicates the start of a new address, and the data content to be stored starting from the address is also indicated after the address. The file ends with a lowercase "q" character plus a line break. According to the format of the TI-txt file, you must first use the CommandDialog control to open the file to be downloaded, use a certain algorithm to separate the multiple start addresses in the entire TI-txt file and the data content corresponding to each start address, and then send them to BSL step by step through the serial port and write them to the specified address segment. The processing flow of the BSL programming software for the TI-txt file is shown in Figure 4.

e.jpg

To exchange data between the host computer software and the BSL of the MSP430 microcontroller through the serial port, the most critical step is to first make the MSP430 microcontroller enter the BSL state. In order to make the MSP430 microcontroller enter the BSL state, a specific timing must be applied to the RST and TCK (or TEST) pins. The required timing can be generated by using the two properties of MSComm, DTREnable and RTSEnable. The DTREnable property determines whether the DTR (Data Terminal Ready) line is used during the communication process. If DTREnable is set to True, the DTR line is used; if it is False (default), the DTR line is disabled. The RTSEnable property is similar to the DTREnable property. The RTSEnable property is used to determine whether the RTS (Request To Send) line is used. If RTSEnable is set to True, the RTS line is used; if it is False (default), the RTS line is not used. Using these two properties of MSComm, you can use the following code in VB6.0 to make the MSP430 microcontroller enter the BSL state.

f.jpg

Among them, the two controls DTRCheck and RTSCheck are very useful. They can invert the logic levels of DTR and RTS outputs without changing the hardware. This makes the BSL host computer software suitable for both microcontrollers with TCK pins and microcontrollers with TEST pins, greatly enhancing the flexibility of the BSL software.

It is a key step to make the MSP430 MCU enter the BSL state. After opening up this key link of the underlying communication, you can write and debug other software modules step by step. The design flow chart of the MSP430 MCU BSL programming software and the BSL programming software interface are shown in Figures 5 and 6.

h.jpg

i.jpg

Conclusion

A cost-effective BSL programming tool was designed using the USB to serial port chip PL2303 and the VB6.0 programming language. The BSL programming tool has the advantages of easy use, simple operation, and low cost. Through the USB virtual serial port, it can not only perform program upgrades on the MSP430 series microcontrollers with blown fuses, but also serve as a cheap programming tool for users to learn MSP430 microcontrollers. After repeated modifications and improvements, the BSL programming tool was applied to an actual project in a machine tool factory and was used by college students in practice innovation in many universities, achieving good results.

Keywords:MSP430 Reference address:Design and application of BSL programming tool for MSP430 microcontroller

Previous article:Design of intelligent detection robot car based on STC single chip
Next article:CAN bus and MSP430 infrared detection system circuit

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号