Lpc2387 RS485 communication

Source: Internet
Author: User

Recently, a product based on the lpc2387 solution needs RS485 communication. After checking datasheet, The uart of the lpc2387 does not have the built-in RS485 function, so it can only adopt level conversion. Finally, the um3085 of maxcompute and is selected. Both chip pins are compatible and can be converted to TTL and RS485.

Because half-duplex communication is used, a gpio port can be used to control both de and RE. A single moment can only be used to receive or send data. Txd1 and rxd1 of lpc2387 are connected to Di and Ro of 485 respectively.

 

 

 

// RS-485 sending and receiving control code, and compared with ordinary serial communication, more than 485 chip sending/receiving enable settings # define rs485_de_re (0x01 <9) // gpio ipv9 controls de, re /************************************** *********************** * ********************/void enable_rs485_tx () {fio0dir | = rs485_de_re; // gpio dir out fio0set = rs485_de_re; // level 9 output, where de is 1, re is 0 }/*********************************** ******************** * ***********************/void enable_rs485_rx () {fio0dir | = rs485_de_re; // gpio dir out fio0clr = rs485_de_re; // when 9 outputs a low level, de is 0, and RE is 1}

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.