MSP430 common program architecture

Publisher:HeavenlyJoy444Latest update time:2015-09-17 Source: eefocusKeywords:MSP430 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
1. Low power consumption + interruption

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

}

Keywords:MSP430 Reference address:MSP430 common program architecture

Previous article:MSP430F149 IO port
Next article:Internal functions of MSP430

Recommended ReadingLatest update time:2024-11-15 21:39

Design of portable ultrasonic underwater sound pressure meter based on single chip microcomputer
  With the development of underwater ultrasonic technology, the need to test its sound intensity has been raised in many application areas. We use CS-3 hydrophone to design a portable ultrasonic sound pressure meter.   System Design   Design goal requirements: To achieve the measurement of 15-45kHz ultrasonic soun
[Microcontroller]
MSP430 MCU read and write FLASH program example
// Parameter: wAddr is address, range 0x1000~0xFFFF void ReadFlash(U16 wAddr,U8 *bBuf,U8 bLen)  {     while (bLen--)       *bBuf++=*(U8 *)wAddr++;     return;  }  void WriteFlash(U16 wAddr,U8 *bBuf,U8 bLen)  {      U8 reg1,reg2;      reg1=_BIC_SR(GIE);     reg2=IE1;IE1=0; // Protect the original inte
[Microcontroller]
MSP430 Register Chinese Notes---Watchdog and Timer
/**************************************************************** * Watchdog timer register definition ************************************************************/ #define WDTCTL_ 0x0120 sfrw WDTCTL = WDTCTL_; #define WDTIS0 0x0001 /*Select one of the four output terminals of WDTCNT*/ #define WDTIS1 0x0002 /
[Microcontroller]
MSP430G2553 test program (serial port program, timer mode)
//    // //                             MSP430G2xx3 //                       ----------------- //               /||                           XIN|- //                 | |                                 | //                 --|RST                   XOUT|- //                     |                                 
[Microcontroller]
MSP430F5438 Study Notes UART SMCLK 115200-8-N-1
The setting values ​​of UCBR0, UCBR1 and UCBRF in MSP430 can be obtained by calculation or by table lookup. I personally prefer the table lookup method. For details, please refer to the following two charts. By default, ACLK is 32768MHZ and SMCLK is 1048576. When ACLK is selected, the maximum baud rate is 9600. When i
[Microcontroller]
MSP430F5438 Study Notes UART SMCLK 115200-8-N-1
A multi-channel ADC sampling board system circuit design
  The design of ADC board can be divided into single-channel ADC board and multi-channel ADC board from the perspective of channels. In addition to some basic parameters such as effective number of bits, dynamic range, maximum sampling rate and input bandwidth, multi-channel ADC board often needs to measure the amplit
[Power Management]
A multi-channel ADC sampling board system circuit design
MSP430 LCD SED1335 controller program
//------------------------------------------------------------  // MSP 430 subroutine (LCD controller subroutine)   // Statement: Please keep the above information for reprinting. For commercial use, please contact the author  //------------------------------------------------------------  // Control SED1335  // Funct
[Microcontroller]
Design of frequency conversion servo system based on MSP430F149
In recent years, the development of servo systems has always been based on stability, responsiveness and precision, which are also the factors that users value most during use. In machine tool servo systems, robot control systems, radar antenna control systems and other occasions, DC servo motors and DC servo controlle
[Analog Electronics]
Design of frequency conversion servo system based on MSP430F149
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号