Cost-effective MSP430 application system structure design
[Copy link]
As an MCU with excellent performance, the MSP430 series of microcontrollers has been widely used in the mainland. MSP430 has a great advantage over other MCUs in terms of high integration and high performance. The price of this series of chips is also relatively reasonable. The MAP430F44X series, which has the best integration, integrates 60K bytes of program storage (can record data), 2K bytes of on-chip RAM, 6 I/O ports (P1 and P2 can interrupt), 160-segment LCD driver, two serial ports, 4 timers (TB with 7 capture/comparators, including watchdog), analog comparator, hardware multiplier, 8-channel 12-bit A/D converter, frequency adjustment circuit FLL+, system reset SVS module, etc. The more basic MSP430F1101 and MSP430C1101 only have 1K bytes of program storage, 128 bytes of on-chip RAM, analog comparator, two timers, etc. Their performance comparison can be referred to Figures 1, 2 and 3. Figure 1 MSP430F11XX series structure diagram
Figure 2 MSP430F41XX series structure diagram
Figure 3 MSP430F44X series structure block diagram
From Figure 1, Figure 2 and Figure 3, it can be seen that there are great differences between MSP44X and MSP11X in hardware structure and system integration; the difference between MSP41X and MSP11X is not very large. However, the prices of these three series of chips range from 49 cents to 7 US dollars, so how do we choose our system chip?
2. Design schemes of commonly used MSP430 application systems
Figure 4 is a commonly used MSP430 application system. In this system, there are analog quantity acquisition, pulse digital quantity acquisition, calendar clock, LCD display, keyboard for operation, a large number of calculations, etc. In this system, the following schemes can be used to select MSP430. The following also gives a comparison of them.
1 Use the MSP430F44X series
In this selection scheme, the design is the simplest, because the current MSP430F44X series chip is the most fully integrated. Any model in this series can do the job (generally the program will not be larger than 32K bytes).
Figure 4 Commonly used MSP430 application system
2 Using the MSP430F41X series
, if the program is within the range of 8K bytes, this is undoubtedly a better solution. The MSP41X series is just short of being unable to directly A/D convert, and the system price is moderate.
3 Using the MSP430F11XX series
In this solution, the MSP430 cannot directly drive the LCD, the program volume is small, and there is no direct A/D conversion capability. This is an obvious deficiency compared with the first two solutions, but its price is the best.
Among these three solutions, it can be seen that if the hardware cost is not taken into account, the first solution is the best; if the hardware cost must be considered (such as mass-produced civilian products), the third solution is the best and has the highest cost-effectiveness. If the MSP430C1101 is used, the official price is 49 cents, which is quite cheap and suitable for large-scale, cost-sensitive products, and can obtain the highest performance-price ratio. However, there are many problems to be solved in the third solution.
3. Cost-effective MSP430 application system solution
Figure 4 is a classic MSP430 application system block diagram. If the most economical MSP430 series device MSP430F11XX series is used, five problems need to be solved: analog-to-digital conversion problem, LCD display problem, small program size problem, calendar clock programming, and serial communication problem.
1. Analog-to-digital conversion (A/D) problem solution
The MSP430X11XX series microcontroller has an analog comparator Comparator_A and a powerful timer Time_A on the chip, which can form a slope A/D conversion to realize the conversion from analog to digital. The specific principle is (here the conversion from resistance to digital is taken as an example).
Figure 5 Slope A/D conversion principle diagram In Figure 5, R1 and R2 are the standard reference resistor (R1) and the resistor to be measured (R2), respectively, and the capacitor C1 plays a charging and discharging role. The output CAOUT of the comparator is used to drive the timer capture. The analog comparator inside the MSP430 can generate analog voltages for comparison (power supply VCC, 1/2VCC, 1/4VCC, diode voltage drop). The negative end of the comparator selects 1/2VCC. First, the standard resistor charges the capacitor C1 to VCC, and then discharges it through the reference resistor R1, while recording the timer value T1; when the capacitor is discharged to 1/2VCC, the comparator generates an output, CAOUT triggers the timer to generate a capture action, and reads the timer value T2; secondly, the measured resistor R2 is used to charge the capacitor to VCC, and then discharges it through R2, while reading the timer value T3; when the capacitor is discharged to 1/2VCC, the comparator output signal captures the timer data T4 again. Then the resistance value of the measured resistor can be obtained in the linear region of capacitor discharge: R2 = (T2 - T1) * R1 / (T4 - T3). Similar methods can be used for the measurement of other physical quantities.
2 Solutions to LCD display problems
MSP30X11XX does not have LCD driving capability and must be expanded externally. If you can use an external LCD driver chip that costs less than 2 yuan (such as HT1621 or others), why use the MSP430F43X and MSP430F44X series with built-in LCD driver for about 40-70 yuan?
Here, the cheap HT1621 is used as an example to illustrate the interface between the LCD driver chip and the MSP430 series. HT1621 has 128-segment LCD driving capability. There are 4 common terminals and 32 segment outputs, which can realize static, 2MUX, 3MUX, 4MUX and other LCD driving methods. It requires 3 or 4 lines to interface with the microcontroller. It can output signals to drive the microcontroller at a fixed time (very useful when the microcontroller works intermittently), and it can also output signals to drive the buzzer. The interface with the MSP430 microcontroller is shown in Figure 6. If the display content does not need to be read, the read signal can be omitted, and only 3 lines are needed to drive the LCD display. This can be used when the port line is tight.
Figure 6 Interface between HT1621 and MCU
HT1621 has 32*8 bit static display memory inside the chip, the content of which is directly mapped to the LCD driver and can be directly accessed using read and write commands. LCD display is achieved by operating the content of the display memory. Figure 7 is the timing diagram of the operation of MSP430 MCU on 1621.
Figure 7 Operation sequence of 1621 3 程序量小的解决方案
MSP430F11XX系列单片机最大的程序容量只有4K字节,对于大多数的用途基本够用,但对相对复杂的应用,就显得程序空间较小。对于MSP430系列单片机有个巧妙的解决办法:利用MSP430单片机的存储器是线性统一编址的特点,单片机运行的程序可以在除了片内外围模块空间而外的任何存储空间,这里将RAM用来做程序存储器使用。由于RAM内容可变,故可将程序存放在外部存储器中,在需要的时候调到RAM中,再执行RAM中的程序。而外部存储器选用串行24C系列EEPROM,可使系统体积减小,同时可使程序空间增加32K字节乃至128K字节!而系统成本增加很少。24C系列EEPROM与MSP430单片机的接口,这里不多说了,只需要两根I/O口线与两个上拉电阻。
首先,需要将存放在EEPROM中的应用程序划分为较小的模块。这里针对MSP430F1121将每个模块的大小限定在128字节内。MSP430F1121片内RAM有256字节,拿一半用于程序处理中的数据存储,而另一半用于程序调度的程序暂存。
其次,MSP430F1121/1111/1101的片内存储器用于存放对串行24C系列EEPROM存储器的读写操作程序,以及最常用的处理程序,各种中断服务程序等等。
然后,将各个小模块的应用程序存放在EEPROM中,同时,每个小模块的应用程序在EEPROM中的起始位置与模块长度在MSP430的程序存储器中用数据表格的形式存放。每当要调用在EEPROM中的小模块时,就在此表格中查找。使用EEPROM读程序,在EEPROM中读出全部的该小模块程序数据到MSP430的RAM后128字节。
最后,将程序计数器(PC指针)压栈,再改变PC内容为280H(RAM的后128字节开始位置),程序将由此开始运行。当该模块运行完毕,最后一句是RET,则将刚压栈的PC指针恢复。程序继续430FLASH中的主程序运行。 4 日历时钟的程序化解决方案
由于MSP430系列单片机的超低功耗特性,使用其内部定时器模块的比较模式实现日历时钟,时钟源使用32768Hz产生的ACLK信号。将定时器模块设置为1秒中断一次,在中断服务程序中编写日历程序。在程序编写时要注意闰年与闰月以及月大与月小的情况,详细方法这里不用多说。在中断程序完毕则进入低功耗LMP3,这时系统耗电在1uA左右,比常用的专门日历时钟芯片的耗电还要少。在MSP430系列单片机中,将日历时钟程序化从各方面讲(功耗、成本、体积、可靠性等)都是很好的解决方案。
5 串行通讯的解决方案
MSP430F11XX系列单片机片内没有串行通讯模块,不能直接用于异步串行通讯,但由于定时器TIME A的捕获与比较以及特殊的结构,利用定时器实现异步串行通讯的位定时(波特率产生)以及起始位检测等功能,可方便实现串行通讯。
串行发送相对简单一点:设置TIME A为比较模式,比较的数据体现每一位的发送时间,使用中断,每当时间到则发送下一位,全部发送则发送完毕。
串行接收相对复杂一点:首先设置TIME A为捕获模式,要捕获到串行通讯的起始位。捕获到起始位之后,则要将TIME A 设置为比较模式,同时第一位与后面的其他位定时时间不一样,第一位的定时时间是其他位的1.5倍。当所有数据接收完毕则结束。在硬件上使用232或485都可以。
小结
在充分掌握MSP430各个片内模块的性能与特性基础上,使用最简单、最便宜、最常规的器件,设计高性能价格比的应用系统是非常可行的。同时随着产量的增加,经济效益也会显著增加。
|