Infringement complaint

430io port settings


The ports of MSP430 are P1, P2, P3, P4, P5, P6, S, and COM (different models include not only the same ports. For example, the MSP430X11X series has only P1 and P2 ports, while the MSP430X4XX series includes all the above ports), they are Both can be used directly for input / output. There is no special input / output instruction in the MSP430 system, and the input / output operation is realized by transmitting instructions. Each bit of port P1`P6 can be used for input / output independently, that is, it has bit addressing function. The common keyboard interface can be directly simulated by the port, and controlled by query or interrupt mode. Since the MSP430 port has only a data port and no status port or control port, in practical applications, such as query-type input / output transmission, you can use one or more bits of the port to transmit status information. State to determine if the peripheral is in a "ready" state.

Function of the port. (1) P1, P2 ports: I / O, interrupt function, other on-chip peripheral functions such as timers, comparators;

(2) P3, P4P5P6 ports: I / O, other on-chip peripheral functions such as SPI, UART mode, A / D conversion, etc .; (3) S, COM ports: I / O, driving LCD.

Each port of MSP430 has rich control registers for users to realize corresponding operations. Among them, P1 and P2 have 7 registers, and P3 ~ P6 have 4 registers. By setting the register we can achieve: (1) each I / O bit is independently programmed;

(2) Any combination of input, output and interrupt; (3) All 8 bits of P1 and P2 can be used as external interrupt processing; (4) All instructions can be used to operate on the register; (5) Input and output can be performed by byte , Can also be operated bit by bit.

The functions of ports P1 and P2 can be realized through their seven control registers. Here, Px stands for P1 or P2.

(1) PxDIR: input / output direction register. The 8 bits are independent of each other and can define the input / output directions of the 8 pins respectively. All 8 bits are reset after PUC. When using the input / output function, the direction of the port should be defined first. It can only be read as input, and readable and writable as output. 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: The input register is a read-only register. The user cannot write to it, and only know the input signal of the I / O port by reading the contents of its register. So the direction of its pins should be selected as input. For example, in the keyboard keyboard scan program, the port register value of the row line or the column line is often read to judge the case. For example: unsigned char key;

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

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

(3) PXOUT: output register. This register is the output buffer register of the I / O port. The content of the output buffer when read again has nothing to do with the pin direction definition. Changing the contents of the direction register does not affect the contents of the output buffer. For example: PIOUT | = 0X01; //P1.0 outputs 1 and PIOUT & = ~ 0X01; //P1.0 outputs 0.

(4) PXIFG: interrupt flag register. His eight flags indicate whether an interrupt request is pending for the corresponding pin. 0: No interrupt request, 1: Interrupt request. The break flags are PXIFG.0 ~ PXIFG.7. It should be noted that: PXIFG.0 ~ PXIFG.7 share an interrupt vector, which is a multi-source interrupt. When an interrupt caused by any event is processed, PXIFG.0 ~ PXIFG.7 will not be reset automatically. Software must determine which event it is and reset the corresponding flag.

Page 1Next

free download Word document free download: 430io port settings

(Download 1-2 pages, total 2 pages)

you may also like

Back to top