Main function
{
Disable watchdog
Setting the system clock
Initialize peripheral devices such as display
Initialization settings of internal resources such as timers
Enable global interrupt
Enter low power
}
Interrupt function 1
{};
Interrupt function 2
{}
File organization
main.c
/***************************Header file reference***********************************/ #include "msp430f149.h" Device file 1 Header file (e.g. #include "ILI9325_Driver.h") Device file 2 header file (e.g. #include "Disp_Lib.h") /*************************Macro definition and data definition****************************************/ #define YEAR TimeBuff[0] unsigned char TimeBuff[7]={11,6,27,8,35,0,7}; /************************************************************* Function name: Sys_Init Function: Set the system clock, internal resources and peripheral initialization. (For example, complete TFT initialization Display, timer A initialized) Parameters: None Return value: None *************************************************************/ int main(void) { Sys_Init(); _EINT(); //Enable global interrupt LPM3; //Enter sleep mode and wait to be woken up } #pragma vector = TIMERA0_VECTOR //CCR0 interrupt service __interrupt void ta0_isr(void) {};
Device file 1 (e.g. ILI9325_Drive.c)
/*************************Header file reference****************************************/ #include "msp430f149.h" #include "ILI9325_Driver.h" #include "Disp_Lib.h" /*************************Define interface information************************************/ #define ILI9325_CTRL_DIR P4DIR #define ILI9325_CTRL_SEL P4SEL Function1() {}; Function 2() {};
Device file 1 header file (for example ILI9325_Drive.h)
#ifndef _ILI9325_DRIVER_H_ prevents repeated calls #define _ILI9325_DRIVER_H_ /*************************Macro definition************************************/ #define CYAN 0x7FFF//Blue #define YELLOW 0xFFE0 #define TEST 0xFF55 /*************************Function declaration************************************/ extern void LCD_DispOnePixel(unsigned int xAddr,unsigned int yAddr,unsigned long color); extern void LCD_ClearScreen(unsigned long bColor); #endif
2. Cycle + Low Power + Wake-up from Interrupt
Main function { Disable watchdog Setting the system clock Initialize peripheral devices such as display Initialization settings of internal resources such as timers Enable global interrupt While(1) { Enter low power function; } } Interrupt function 1 { Interrupt service function; Exit low power mode; };
3. Menu button interaction mode
while(1) { Scan buttons; Key value processing function; } Key value processing function { switch(key value) case …… Display Refresh }
Previous article:MSP430F149 IO port
Next article:Internal functions of MSP430
Recommended ReadingLatest update time:2024-11-15 21:39
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- 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
- Streamlining mobile phone system design
- Questions about analog switch time parameters
- What? Intel is sued for infringing the Chinese Academy of Sciences' FinFET patent
- EEWORLD University - High-Speed Transimpedence Amplifier Design Process
- PCB
- It seems that a problem with gcc compiling threadx has been discovered
- Recommended MCU with larger on-chip RAM
- ART-Pi Evaluation RTE Environment Build RTOS Project
- Newcomer report!
- At the age of thirty, I am penniless and have nothing to lose. I have to start all over again!!!