/***************************************************** AD9834 Waveform Generation Program *****************************************************/ #include#define FSYNCL P2OUT &= ~BIT5 #define FSYNCH P2OUT |= BIT5 #define SCLKL P2OUT &= ~BIT6 #define SCLKH P2OUT |= BIT6 #define SDATAL P2OUT &= ~BIT7 #define SDATAH P2OUT |= BIT7 double data=1000 ; #define FCLK 50 #define uchar unsigned char #define uint unsigned int #define long unsigned long int x; /************************** Send control word **************************/ void Send_Con(uint Con_word) { flying i; FSYNCL; for(i=0;i<16;i++) { if ((Con_word&0x8000)==0x8000) {SDATAH;} else SDATAL ; Con_word<<=1; SCLKL; SCLKH; } FSYNCH; } /**************************************************** Initialization function: ------------------------------------------------------------------- Function: software bit control, IOUT sine wave, SIGNBITOUT square wave, write FREQREG0, write PHASE0 Send_Con(0x2038) write FREQREG0 once Send_Con(0x0038) rewrites the LSB of FREQREG0 alone Send_Con(0x1038) rewrites the MSB of FREQREG0 alone ------------------------------------------------------------------- Function: Software bit control, IOUT triangle wave write FREQREG0, write PHASE0 Send_Con(0x2002) write FREQREG0 once Send_Con(0x0002) rewrites the LSB of FREQREG0 alone Send_Con(0x1008) rewrite the MSB of FREQREG0 alone****************************/ /**************************** Send frequency word ****************************/ void Send_Freq(uint Freq_word) { flying i; FSYNCL; for(i=0;i<16;i++) { if ((Freq_word&0x8000)==0x8000) {SDATAH;} else SDATAL ; Freq_word<<=1; SCLKL; SCLKH; } FSYNCH; } /***************************** q Send phase word Note: According to the situation, you can set the input parameters and phase *****************************/ void Send_Phase() { Send_Con(0xC000); //Set the initial phase to 0 } /******************************************************* Set the frequency value Freq_value(value)=Freq_data(data)*FCLK/2^28 2^28=268435456=0x10000000 *******************************************************/ void zhengxianbo(ulong Freq_value ) { head value1,value2; uint LSB_D,MSB_D; SCLKH; FSYNCH; value1= Freq_value; value2= Freq_value; LSB_D=(value1%0x4000)+0x4000; //write LSB of FREQ0 REG MSB_D=(value2/0x4000)+0x4000; //Write the MSB of FREQ0 REG Send_Con(0x2038);
//DDS initialization settings, IOUT sine wave, SIGNBITOUT square wave, one-time write FREQREG0 Send_Freq(LSB_D); Send_Freq(MSB_D); void Send_Phase(); } void main() {uint n; static ulong x=0; static ulong Freq_value; WDTCTL=WDTPW+WDTHOLD; P2DIR=0Xff; while(1) { for(x=0;x<10;x++) { if(x==9) data=1000; else data=data+1000*x; Freq_value=(ulong)(data*5.3687); zhengxianbo(Freq_value); for(n=0;n<20000;n++); } } }
Previous article:Application and design of SPCE061A in sensor test system
Next article:Application of MSP430 in frequency measurement system
Recommended ReadingLatest update time:2024-11-16 16:43
- Popular Resources
- Popular amplifiers
- MSP430 series single chip microcomputer system engineering design and practice
- oled multi-chip calling program
- Microcontroller Principles and Applications Tutorial (2nd Edition) (Zhang Yuanliang)
- Getting Started and Improving MSP430 Microcontrollers - National Undergraduate Electronic Design Competition Training Course
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- 【TI mmWave Radar Evaluation】SDK and Example Download
- Electromagnetic wave characteristics
- [Free] Raspberry Pi 400 | Faster CPU, better heat dissipation
- Tips for getting STM32 code running time
- Release an operating system source code package that runs on NXP LPC1768.
- EEWORLD University Hall----Live Replay: SimpleLink? Latest Software and Hardware Solutions for Wireless Platform
- Thank you-Brothers of EE Water Army
- nF capacitor and 1M resistor in parallel between the metal case and GND
- Do you know about Allegro's latest solution for vehicle electrification and emission control 48V system?
- 【CH579M-R1】+ Bluetooth function key preliminary test