MSP430F149 serial RS485 interface

Publisher:小熊掌心Latest update time:2015-09-17 Source: eefocusKeywords:MSP430F149 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
1. Brief Introduction

    The basic principles and usage of RS485 communication are the same as RS232, with the following differences.

RS232 interface can only realize point-to-point communication, but this method cannot realize networking function, so RS485 appeared to solve this problem. RS485 uses differential signal negative logic, +2V~+6V represents "1", -6V~-2V represents "0". For dual-machine communication, only AA and BB connections are needed.

The hardware circuit generally uses RS485 level conversion chips such as SN65176. When connected to the MCU, there are three pins: DE (RE and DE are connected together), DI (receive pin), RO (send pin). When the MCU sends a frame signal, it must first enable DE=1; before receiving the signal, it must first enable DE=0 (ie RE=0).

2. Examples

2.1 Send character 8.N.1.2400

#define DRE_out P3DIR |= BIT3 //Connect the DE and RE ports of the 485 chip to the output state

#define DE P3OUT |= BIT3 //Set the 485 chip to the sending state

void Set_UART1(void)

{

    P3SEL |= 0xC0; //Select P3.6 and P3.7 as the communication port of UART1

    ME2 |= UTXE1 + URXE1; // Enable TXD and RXD of USART1

    UCTL1 |= CHAR; //Select 8-bit character

    UTCTL1 |= SSEL0; //Drive clock selection ACLK

    UBR01 = 0x0D; //Baud rate 2400

    UBR11 = 0x00;

    UMCTL1 = 0x6B; //Adjust

    UCTL1 &= ~SWRST; //Initialize UART state machine

}

main

{

    DRE_out;

    DE;

    Set_UART1();

   

    TXDATA = 0X30;

    TXBUF1 = TXDATA; //Here you can directly assign a value to transmit fixed data

while(!(IFG2 & UTXIFG1)); //Wait for sending to end

 }

2.2 Interrupt function receives character 8.N.1.2400

void Set_UART1(void)

{

    P3SEL |= 0xC0; //Select P3.6 and P3.7 as the communication port of UART1

    ME2 |= UTXE1 + URXE1; // Enable TXD and RXD of USART1

    UCTL1 |= CHAR; //Select 8-bit character

    UTCTL1 |= SSEL0; //Drive clock selection ACLK

    UBR01 = 0x0D; //Baud rate 2400

    UBR11 = 0x00;

    UMCTL1 = 0x6B; //Adjust

    UCTL1 &= ~SWRST; //Initialize UART state machine

    IE2 |= URXIE1; //Enable UART1 receive interrupt

}

#pragma vector=UART1RX_VECTOR

__interrupt void UART1_RX (void)

{

    Disp1Char(pX++,pY,RXBUF1);

    if(pX == 16)

    {

      pX = 0;

      pY^= 1;

    }

}

Keywords:MSP430F149 Reference address:MSP430F149 serial RS485 interface

Previous article:Research on Model-free Control of Switching Power Supply
Next article:MSP430F149 serial port RS232 interface

Recommended ReadingLatest update time:2024-11-15 17:52

Design of high-precision temperature control system based on MSP430F149 microcontroller
    Aiming at the problems of low precision and poor stability in the temperature box control process, this paper designs a high-precision temperature control system based on MSP430F149 single-chip microcomputer. The system uses platinum resistance temperature sensor and 12-bit A/D converter to realize accurate measur
[Microcontroller]
Design of high-precision temperature control system based on MSP430F149 microcontroller
MSP430F149 TIMER_A (I)——16-bit timing counter
    TIMER_A has four optional clock sources. For convenience, ACLK and SMCLK are generally selected. A time base is generated through a frequency divider. Its structure diagram is as follows:   TIMER_A has three timing/counting modes: (1). Incremental counting mode: Counting cycle: TAR increases from 0 to TAC
[Microcontroller]
Msp430f149 learning system clock setting
I. Overview   MSP430F149 has three clock sources: external LF (XT1 is generally 32.768K), HF (XT2 is generally 8M), internal DCO. Three clock signals can be obtained from the clock system module: MCLK, SMCLK, ACLK.    By default, the MCLK and SMCLK signals come from the DCO and the ACLK comes from the LF. According to
[Microcontroller]
Design of a new multifunctional power quality monitoring instrument based on DSP
  In recent years, my country's power industry has developed rapidly in terms of both total power generation and power grid construction, and the scale of the power system has continued to expand. However, with the development of productivity, the issue of power quality has received increasing attention, and the requir
[Microcontroller]
Design of a new multifunctional power quality monitoring instrument based on DSP
MSP430F149 serial RS485 interface
1. Brief Introduction     The basic principles and usage of RS485 communication are the same as RS232, with the following differences. RS232 interface can only realize point-to-point communication, but this method cannot realize networking function, so RS485 appeared to solve this problem. RS485 uses differential si
[Microcontroller]
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号