时钟源部分
ADC部分
中断部分
温控中代码逻辑的初步调试
UART的初步调试
一:时钟源部分:
现在项目中,需要使用msp430单片机作为控制端,所以,要先对msp430的时钟源进行了解和分析。
msp430拥有unified clock system (统一时钟系统),
-FLL(锁频环) for frequency stablization
-VLO(内部时钟源)
-内部参考源(REFO)
-32kHZ晶振
-高达32MHz的高频时钟
The clock system is supported by the Unified Clock System (UCS) module that includes support for a 32-kHz watch crystal oscillator (或者时钟XT1低频态 XT1 LF mode), an internal very-low-power low-frequency oscillator (内部低频低功耗振荡器VLO), an internal trimmed low-frequency oscillator (内部平衡低频晶振REFO), an integrated internal digitally controlled oscillator 内部数字控制振荡器(DCO), and a high frequency crystal oscillator (高频晶振XT1 HF mode or XT2). The UCS module is designed to meet the requirements of both low system cost and low power consumption.
The UCS module features digital frequency locked loop (FLL)hardware that, in conjunction with a digital modulator, stabilizes the DCO frequency to a programmable multiple of the selected FLL reference frequency. The internal DCO provides a fast turn-on clock source and stabilizes in less than 5 μs. The UCS module provides the following clock signals:
• Auxiliary clock (ACLK), sourced from a 32-kHz watch crystal, a high-frequency crystal, the internal lowfrequency
oscillator (VLO), the trimmed low-frequency oscillator (REFO), or the internal digitally controlled
oscillator DCO.
• Main clock (MCLK), the system clock used by the CPU. MCLK can be sourced by same sources made
available to ACLK.
• Sub-Main clock (SMCLK), the subsystem clock used by the peripheral modules. SMCLK can be sourced by
same sources made available to ACLK.
• ACLK/n, the buffered output of ACLK, ACLK/2, ACLK/4, ACLK/8, ACLK/16, ACLK/32.
由于项目中需要使用到ADC模块,那么就有必要对ADC模块进行研究了。
这是msp430F5428A datasheet首页上面对于ADC的描述:
12-Bit Analog-to-Digital Converter (ADC)
– Internal Reference
– Sample-and-Hold
– Autoscan Feature
– 14 External Channels, 2 Internal Channels
ADC12_A (Link to User’s Guide)
The ADC12_A module supports fast 12-bit analog-to-digital conversions. The module implements a 12-bit SAR
core, sample select control, reference generator, and a 16-word conversion-and-control buffer. The conversionand-
control buffer allows up to 16 independent ADC samples to be converted and stored without any CPU
intervention.
也就是说ADC12_A可以同时转换16路的模拟信号。(没有cpu的介入)
把Msp430f5438A的ADC12_A的重要特点总结如下:
(1) 转换速率可以为200K/s
(2)12bit转换 无错码
(3) 由软件或计数器控制着的采样时间和保持时间
(4)内部有参考电压1.5V,2.0V及2.5V
(5)可以使用外接参考源,是否选择外部参考源由寄存器决定。
(6)有单沟道采样,重复单沟道采样,序列采样,重复序列采样4种模式可选(Single-channel, repeat-single-channel, sequence (autoscan), and repeat-sequence (repeated autoscan) conversion modes)
(7)16位转换结果存储寄存器ADC12MEMx,和ADC12转换结果存储寄存器ADC12MCTLx。
写下列程序:
void main(void)
{
WDTCTL = WDTPW+WDTHOLD; // Stop watchdog timer
ADC12CTL0 = ADC12ON+ADC12MSC+ADC12SHT0_15;// Turn on ADC12, set sampling time
ADC12CTL1 = ADC12SHP+ADC12CONSEQ_0; // Use sampling timer, single