(2) msp430f5529 general-purpose I/O port settings

Source: Internet
Author: User

Beginner, there are any mistakes or inappropriate places to correct, we exchange learning together.

Recommend a good place: TI official MSP430 Exchange Community http://www.deyisupport.com/question_answer/microcontrollers/msp430/f/55.aspx need to register. In this case, there will be TI's in-service engineers to answer your question.

In the first chapter, I am learning I/O. I/O operations are fundamental, and these registers are tightly held. MSP430 difficult in it has a large number of registers need to be set, although not each must master, but I/O control register I think it must be remembered. This is too basic, ah-_ '

We have to keep a schematic (PCB diagram), convenient to check the line and configuration Pin

first, the general I/O The simple operation (setting)

1.1 I/O the introduction

Features:① multiple multiplexing and Settings (you can control whether the input, whether the output, whether the pull-up resistor, whether to pull the resistor, whether the interruption can be accepted );

Generally,P1 and P2 are capable of interruption . interrupts introduced from the various I/O pins of the P1 and P2 interfaces can be enabled independently and set to trigger on rising or falling edges . The corresponding interrupt vector tables are p1iv and p2iv, which can only be used for word manipulation, and paiv This register does not exist at all.

                      ③P1,P2 can be combined as PA,P3,P4 can be combined PB,... PC,PD 。 So P1 is a 8 -bit BCD 0x00and PA is a three-bit BCD 0x0000 。 When a word operation is writtenPAAt the mouth, all -Bits are written to this port, and when a byte operation is used to writePALow byte of the port, the high byte remains unchanged;

④ because of 430 a lot of I/O and peripheral circuit wiring, so here are common bit operation . bit0=0x01,bit1=0x02, bit3=0x04, as defined in advance (which will be used next). bit7=0x80, then the output of P1.1,P1.3 is set to 1 , this can be done:p1out|=(bit1+bit3 ). It seems clear.

⑤ No use of I/O, to unified pull down as well . In addition, bits that are not used are considered zero when the length of the data being read is less than the port maximum.

1.2 I/O the simple configuration

The configuration of 430i/o is implemented by software, which is implemented by the corresponding configuration register. (When using an I/O , be sure to configure the I/Ofirst, otherwise error-prone)

1.2.1 I/O Direction setting register pxdir

If you set P1.1 and P1.2 as the output state, the operation is: p1dir |=(bit1+bit2) is equivalent to the PADI R |=(bit1+bit2) is also equivalent to padir_l|=(bit1+bit2.

    The pull height is set to output, and the pull-down setting is input (default).

1.2.2 I/O input setting register pxin

If the input for P1.1 and P1.2 is set to low, the operation is: p1in &=~(bit1+bit2 ).

1.2.3 I/O output setting register pxout

① when used only for simple output : such as setting P1.1 and P1.2 output High, the operation is: p1out |=(bit1+bit2).

② If the pin is normal I/O function and is currently set to the input direction, and the pull-up / pull-down resistor register is valid . Then pxout can be used to configure pull-up and pull -down resistors:

The low level is the pull-down resistor;

High-level is the pull-up resistor;

1.2.4 Pull-up / pull-down resistor enable register Pxren

Low Level This register is invalid state;

High Level This register is valid state;

1.2.5 Output drive capacity setting Register Pxds

weakening the drive can weaken EMI, and the full drive will enhance the electromagnetic interference. The default is to weaken the driver.

Low level indicates a weakened drive (default);

High-level means full drive;

1.2.6 feature selector Register Pxsel

used to declare that the port is a special function to be applied to the peripheral circuit (does not determine the input and output direction), the default is low .

Low level indicates normal I/O(default);

High level indicates that the PIN will have a special purpose of connecting the peripheral circuit;

such as: The Development Board initialization function HAL_BOARD.C has such a sentence program:

                                      p5sel |= (bit2+bit3 ) (=00001100 ) ;

This statement means that P5.2 and P5.3 will have a special purpose, actually these two I/O are connected to the external high frequency clock crystal (You can also set the input status later).

It is also important to note that once an I/O pxsel is placed high, the pin will no longer be used as the interrupt pin.

Summary, simple application of the program:

/* Implement LED the Flicker */LED located under each touch button, the specific interface please inquire schematic diagram

#include <msp430.h> The header file contains the internal 430 configuration of individual registers

void Main (void)

{

Wdtctl=wdtpw+wdthold; Turn off the watchdog

p1dir|= (BIT0+BIT1+BIT2+BIT3+BIT4+BIT5); p1.0-p1.5 direction is output,bitx is defined in msp430.h

p1out&=~ (BIT0+BIT1+BIT2+BIT3+BIT4+BIT5); Qing 0

/*p1sel=0x00;

pxds=0x00; default */

int i=0,j=0;

while (1)

{

if (i>5)

i=0;

Else

{

Switch (i)

{

Case 0:p1out=0x01;break;

Case 1:p1out=0x02;break;

Case 2:p1out=0x04;break;

Case 3:p1out=0x08;break;

Case 4:p1out=0x10;break;

Case 5:p1out=0x20;break;

}

}

i++;

For (j=20000;j>0;j--); Delay

}

}

Article excerpt from: http://blog.lehu.shu.edu.cn/879836630/A448899.html

(2) msp430f5529 general-purpose I/O port settings

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.