Test the AD10 program of the microcontroller through the MSP430F1232 minimum system
[Copy link]
Test the MCU program, including the MCU initialization settings, clock, etc., mainly the AD module settings, and write the program through the 1232 routines on the TI official website. 1. Create an IAR project, set the project options, add TI's routine c file, and compile. If there is no problem, you can connect JTAG to burn the program into the MCU. 2. Several issues that need to be solved in the MCU program: (1) MCU clock By default, the main system clock (MCLK) and subsystem clock (SMCLK) use the 800KHz clock generated by the internal DCO (using internal resistors), and the auxiliary system clock uses the 12KHz clock generated by the ultra-low power 12KHz internal oscillator (VLOCLK) on the chip. Msp430F1232 has two clock sources, one is LFXT1CLK and the other is the internal DCOCLK. ACLK can only select LFXT1CLK. If the MCU does not have an external crystal oscillator, ACLK will use the 12KHz clock generated by the ultra-low power 12KHz internal oscillator (VLOCLK) on the chip. About the low-frequency and high-frequency modes of LFXT1CLK: (1) Low-frequency mode: Use a 32768Hz external crystal oscillator. No external components are required, that is, no capacitors are required. At the same time, the register setting XTS=0 is actually 0 by default, that is, no setting is required. (2) High-frequency mode: Supports a maximum of 8MHz crystal oscillator, requires an external capacitor, and sets the register setting XTS=1. Question: What is the appropriate frequency for the main system clock? ? ? Temporarily set it to the default clock frequency at power-on. If the internal DCO is used as the main system clock source, what is the use of the external 32768Hz? ? ? This system uses a 100K external resistor, and the default DCO frequency is about 2MHz. Set it according to the needs. If the system is required to run faster and the clock is more accurate, set it to XT2, which is generally 8MHz; if there is no special requirement, use the 1M frequency provided by the system DCO. If low power consumption or time-related clock sources are required, it is best to use a 32768Hz external crystal oscillator. ACLK is the auxiliary clock, usually a low-frequency clock, using a low-frequency oscillation of 32768Hz or a VLO of 12KHz. MCLK is the main clock, provided to the CPU. This needs to be determined according to the actual situation. It can be a DCO or HF oscillator. SMCLK is the peripheral clock, and the clock source is usually obtained from the DCO. The main system clock in this system is generated by DCO, which involves several issues. How big a resistor should be connected to the Rosc pin, and what effect does the resistor size have on the DCO frequency? Now it is connected to 100K. The external resistor can not only suppress the coefficient of the DCO, but also increase the maximum frequency that the DCO can reach. The internal 300K resistor corresponds to 5MHz. When using an external 100K resistor, the DCO can reach 10MHz. DCO defines the base frequency by internal or external resistors, and uses the DCOR bit to determine whether the base frequency refers to internal or external resistors. The three RSELx bits select one of the eight nominal frequencies for DCO. RSELx can only be set through registers when internal resistors are used. If external resistors are used, the frequency generated by DCO will naturally be different depending on the resistance value of the resistor you connect (is that right? I'm not sure). The three DCOx bits divide the selected nominal frequency into segments, that is, the eight nominal values are divided into eight values in pairs. Please refer to the data sheet for details. I don't understand the use of MODx yet... (2) ADC10 settings Set the clock source of ADC10. It can be one of MCLK, SMCLK, ACLK, and ADC10OSC. ADC10OSC is a clock source specifically used for ADC. Its frequency is about 5M. Because the sampling frequency of the pulse signal in this system is 200Hz, it is enough. 500Hz at most. More is useless. Therefore, a 32768Hz (32KHz) crystal oscillator is connected to the microcontroller, which is specifically used for ADC sampling. Obviously, the higher the crystal oscillator driving frequency of the microcontroller, the greater the power consumption. The 32768Hz frequency used here consumes much less power than the built-in ADC10OSC. SHTx is used to set the AD clock source frequency division. Sampling and conversion time: sampling time is the frequency division times of AD clock period, and conversion time is 13 times AD clock period. AD channels: 8 external channels and 4 internal channels. Reference voltage: REFON=1, enable internal reference voltage, set REF2_5=1, enable 2.5V reference voltage ADC conversion mode: single channel single, multi-channel single, single channel multiple, multi-channel multiple.69)] This system uses multi-channel single conversion and two-channel analog input. Multi-channel single conversion means that after the first sampling and conversion is completed, there is no need to give a SHI signal to trigger sampling, and the next channel can be sampled and converted directly. Register setting: CONSEQx (select several channels, here select CONSEQ1, corresponding to multiple channels) and MSC set to 1 (corresponding to multi-channel single conversion) Channel selection: Select A0 and A1 as input channels, set INCH_1 Interrupt enable: ADC10IE Conversion result register: Different from F5438, 1232 has only one conversion result register, a total of two bytes, 16 bits, you can choose the first 10 bits or the last 10 bits to store the conversion result What needs to be done next: see where the code for subsequent operation of registers to transfer data to Bluetooth is written, and understand the interrupt of AD sampling (already solved, reference: MSP430F1232 Interrupt Learning) Knowing the starting address and the end address, how to read the data from the address in between? ? ? How should the USART (Universal Synchronous Asynchronous Transmission) code be written, and how should the registers be operated? ? ?
|