MSP430 MCU port analysis

Publisher:Huixin8888Latest update time:2013-01-24 Source: 21IC Keywords:MSP430 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Introduction to the ports of MSP430 microcontroller

The ports of MSP430 are P1, P2, P3, P4, P5, P6, S and COM (different models have different ports, such as MSP430X11X series only have P1 and P2 ports, while MSP430X4XX series have all the above ports), which can be used directly for input/output. There are no special input/output instructions in the MSP430 system, and input/output operations are implemented by transmitting instructions. Each bit of port P1`P6 can be used independently for input/output, that is, it has bit addressing function. Common keyboard interfaces can be directly simulated with ports and controlled by query or interrupt mode. Since the port of MSP430 only has data ports, no status ports or control ports, in actual applications, such as query-type input/output transmission, one or several bits of the port can be used to transmit status information, and the status of the corresponding bit can be queried to determine whether the peripheral is in the "ready" state.

Port functions. (1) P1, P2 ports: I/O, interrupt function, other on-chip peripheral functions such as timer, comparator; (2) P3, P4P5P6 ports: I/O, other on-chip peripheral functions such as SPI, UART mode, A/D conversion, etc.; (3) S, COM port: I/O, drive LCD.

Each port of MSP430 has a rich set of control registers for users to implement corresponding operations. P1 and P2 have 7 registers, and P3~P6 have 4 registers. By setting registers, we can achieve: (1) Each I/O bit is independently programmable; (2) Any combination of input, output and interrupt; (3) All 8 bits of P1 and P2 can be used for external interrupt processing; (4) All instructions can be used to operate registers; (5) Input and output can be performed by bytes, or by bits.

The functions of ports P1 and P2 can be realized through their 7 control registers. Here, Px represents P1 or P2.

(1) PxDIR: Input/output direction register. The 8 bits are independent of each other and can define the input/output direction of the 8 pins respectively. The 8 bits are reset after PUC. When using the input/output function, the direction of the port should be defined first. When used as input, it can only be read; when used as output, it can be read and written. 0: Input mode; 1: Output mode. For example: P1DIR|=BIT4; //P1.4 output, P2DIR=0XF0; //High 4 bits output, low 4 bits input.

(2) PXIN: Input register, which is a read-only register. Users cannot write to it, and can only know the input signal of the I/O port by reading the contents of its register. Therefore, the direction of its pin should be selected as input. For example, in the keyboard scanning program, it is often necessary to read the port register value of the row line or column line to judge the case. For example: unsigned char key;

P1DIR&=~BIT4; //P1.4 input

key=P1IN&0X10; //output port P1.4 value

(3) PXOUT: Output register. This register is the output buffer register of the I/O port. When it is read again, the content of the output buffer is independent of the pin direction definition. Changing the content of the direction register will not affect the content of the output buffer. For example: PIOUT|=0X01; //P1.0 outputs 1, PIOUT&=~0X01; //P1.0 outputs 0.

(4) PXIFG: Interrupt flag register. Its 8 flag bits indicate whether the corresponding pin has an interrupt request to be processed. 0: No interrupt request, 1: Interrupt request. The interrupt flags are PXIFG.0~PXIFG.7. It should be noted that PXIFG.0~PXIFG.7 share an interrupt vector and are multi-source interrupts. When an interrupt caused by any event is processed, PXIFG.0~PXIFG.7 will not be reset automatically. The software must determine which event it is and reset the corresponding flag. In addition, the time of the external interrupt event must be kept at least 1.5 times the MCLK time to ensure that the interrupt request is accepted and the corresponding interrupt flag is set.

(5) PXIES: Interrupt trigger edge selection register. If a pin of the PX port is allowed to interrupt, the interrupt trigger mode of the pin must also be defined. 0: rising edge trigger sets the corresponding flag, 1: falling edge trigger sets the corresponding flag. For example: MOV.B #07H, &P1IES; the falling edge of the lower 3 bits of p1 triggers an interrupt.

(6) PXIE: Interrupt enable register. Each pin of the PX port has a bit to control whether the pin is allowed to interrupt. 0: Disable interrupt, 1: Enable interrupt. MOV.B #0E0H, &P2IE; The upper 3 bits of P2 enable interrupts.

(7) PXSEL: Function selection register. The two ports P1 and P2 also have other on-chip peripheral functions. These functions are connected to the outside of the chip by multiplexing the P1 and P2 pins. PXSEL is used to select the I/O port function and the peripheral module function of the pin. 0: Select the pin as an I/O port, 1: Select the pin as a peripheral module function. For example: P1SEL|=0X10; //P1.4 is a peripheral module function.

Ports P3, P4, P5, and P6 do not have interrupt capabilities, and their other functions are the same as those of PI and P2. Excluding the three registers related to interrupts of ports P1 and P2, the four registers of ports P3, P4, P5, and P6 (with the same usage as P1 and P2) are PXDIR, PXIN, PXOUT, and PXSEL for users to use.

Ports COM and S, they realize direct interface with the LCD. COM is the common terminal of the LCD, S is the segment terminal of the LCD. The output terminal of the LCD can also be configured as a digital output port by software.

Keywords:MSP430 Reference address:MSP430 MCU port analysis

Previous article:Bluetooth-based home monitoring alarm system
Next article:What are the maskable interrupts of MSP430?

Recommended ReadingLatest update time:2024-11-16 14:58

LED single light flashing experiment of PIC microcontroller under proteus+MPLAB combination
First put the circuit diagram, pay attention to the selection of capacitors on both sides of the crystal oscillator, and pay attention to the resistance value between the LED and the voltage. The program is: Note that you must include the pic.h file, you must first determine the size of _XTAL_FREQ before using the _
[Microcontroller]
LED single light flashing experiment of PIC microcontroller under proteus+MPLAB combination
[nrf51][nrf52][Three-party communication] PC/mobile phone MCU BLE communication template is for reference only
According to the principle of serial communication, the interactive communication environment between the three parties is designed and built, and data is sent and received to each other through the protocol. The module is implemented. The design realizes the interactive communication mode of the three parties, and th
[Microcontroller]
PIC MCU I/O Control
 I/O control is the most basic and core thing for a microcontroller. In fact, apart from AD DA conversion, most other things can be done by the I/O port. I/O control is simple but can be varied. What a microcontroller does in most applications is to input high and low levels and output high and low levels. It is thr
[Microcontroller]
51 single chip microcomputer working cycle and timing
Introduce the XTAL1 and XTAL2 pins: The XTAL1 and XTAL2 pins are used for the crystal oscillator and the crystal oscillator to generate the clock signal. 1. After connecting to the crystal oscillator 1. After connecting to the crystal oscillator For example, if the external crystal oscillator connected to the XTA
[Microcontroller]
51 single chip microcomputer working cycle and timing
Design of Positioning Monitoring System Based on SOC Microcontroller
This paper discusses the design of positioning monitoring system based on SOC single chip technology. The system consists of two parts: positioning terminal and monitoring center. The positioning terminal uses C8051F021 as the core microprocessor, and communicates serially with SIEMENS M-C35i GPRS module and GR-87 s
[Microcontroller]
Design of Positioning Monitoring System Based on SOC Microcontroller
An example of a program to multiply two double-byte unsigned numbers in a single-chip microcomputer
This program is suitable for Intel's 51 system microcontroller For example, multiply two double-byte unsigned numbers (R2R3) and (R6R7), and send the result to R4R5R6R7.  Using the shift and add method, the steps are as follows:  1) Clear the partial product (high 16 bits) R4R5 = 0. The number of loops is 16.  2) S
[Microcontroller]
Implementation of remote control searchlight system based on Holtek microcontroller
On stage, sometimes it is necessary to turn off all live lights except the searchlights to create a special effect. The searchlight must shine on the actor. Since the searchlight is hung high on the ceiling, when the actor moves, it is very inconvenient to rely on manual adjustment of the direction of the searchlight,
[Microcontroller]
Teach you how to use PIC microcontroller to drive relay
In modern automatic control equipment, there is a problem of interconnection between electronic circuits (weak current) and electrical circuits (strong current). On the one hand, the control signal of the electronic circuit should be able to control the actuators of the electrical circuit (such as motors, electromagne
[Microcontroller]
Teach you how to use PIC microcontroller to drive relay
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号