• Join
  • Sign In with my.TI Login
Texas Instruments
  • Products
  • Applications
  • Tools & Software
  • Support & Community
  • Sample & Buy
  • About TI
Sample & Purchase Cart Sample & Purchase Cart
  • Search
  • Advanced
TI E2E™ Community
  • Support Forums
  • Blogs
  • Groups
  • Videos
  • 简体中文
  • More ...
TI Home » TI E2E Community » Support Forums » Microcontrollers » MSP430™ Microcontrollers » MSP430 Ultra-Low Power 16-bit Microcontroller Forum » RS232 and SPI
Share
MSP430™ Microcontrollers
  • Forum
  • Announcements
  • E2E Wiki
Options
  • Subscribe via RSS
MSP430 Resources
  • MSP430 Product Folder
  • MSP-EXP430G2 - MSP430 LaunchPad Value Line Development kit
  • MSP430 Getting Started Guide
  • MSP430 Microcontroller Projects
  • More Resources >
  • RS232 and SPI

    RS232 and SPI

    This question is answered
    Michael Hansen
    Posted by Michael Hansen
    on Aug 10 2012 14:12 PM
    Prodigy160 points

    Hey

    On a msp430f2272 is it possible to use rs232 and spi at the same time??

    How do I in code disable spi ? I use IAR compiler.

    Thanks

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    All Replies
    • Mark Green
      Posted by Mark Green
      on Aug 10 2012 14:45 PM
      Verified Answer
      Verified by Michael Hansen
      Intellectual640 points

      Its possible to have both a UART and SPI on a 2272

      UCA0 = UART, MCU pins: P3.4, P3.5

      UCB0 = SPI, MCU pins: P3.0, P3.1, P3.2, P3.3

      But you would need a external chip to take your UART signal  to RS232 levels.

      When you say you want to disable the SPI what do you mean exactly? Power it down? Release the pins for GPIO?

      Mark.

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Michael Hansen
      Posted by Michael Hansen
      on Aug 11 2012 14:02 PM
      Prodigy160 points

      Release the pins for GPIO

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Mark Green
      Posted by Mark Green
      on Aug 12 2012 04:21 AM
      Verified Answer
      Verified by Michael Hansen
      Intellectual640 points

      Michael Hansen
      How do I in code disable spi ? I use IAR compiler.

      Not sure what IAR use but it will be something like this:

      If you are using UCA0 (P3.0 3.3, 3.4, 3.5):

      UCA0CTL1.SWRST = 1;                     // set UCSWRST bit to disable interrupts from SPI

      P3SEL &= ~(bit0 + bit3 + bit4 + bit5);  // clear PSEL bits to release pins from SPI module (i.e. put back to GPIO)

      // set PxDIR, PxOUT as you need for the released pins

      --

      If you are using UCB0: (P3.0, 3.1, 3.2, 3.3):

      UCB0CTL1.SWRST = 1;                     // set UCSWRST bit to disable interrupts from SPI

      P3SEL &= ~(bit0 + bit1 + bit2 + bit3);  // clear PSEL bits to release pins from SPI module (i.e. put back to GPIO)

      // set PxDIR, PxOUT as you need for the released pins

      --

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Jens-Michael Gross
      Posted by Jens-Michael Gross
      on Aug 13 2012 13:06 PM
      Guru141810 points

      Mark Green
      UCA0CTL1.SWRST = 1;  

      Use of bitfields for hardware registers is deprecated. While some PC-coders seem to be unable to live without them, they are ineffective on hardware registers (which are volatile) and may obfuscate side-effects.

      UCA0CTL1 |= SWRST; is to be preferred. (or UCA0CTL1&=~SWRST; for clearing the bit).

      _____________________________________
      Before posting bug reports or ask for help, do at least quick scan over this article. It applies to any kind of problem reporting. On any forum. And/or look here.
      If you cannot discuss your problem in the public, feel free to start a private conversation: click on my name and then 'start conversation'. But please do so only if you really cannot do it in a public thread, as I usually read all threads. And I prefer to answer where others can profit from it (or contribute to it) too.

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Mark Green
      Posted by Mark Green
      on Aug 13 2012 16:42 PM
      Intellectual640 points

      Jens-Michael Gross
      Use of bitfields for hardware registers is deprecated.

      Hi Jens,

      Bit puzzled by this one. I thought it was the other way round i.e. use of bit flags is depreciated?

      Either way I wouldnt have thought it really mattered since the assembly for:

      Reg.bit0 = 1;

      comes out the same as

      Reg |= 0x01;

      Might make for an interesting discussion in another thread maybe?

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Jens-Michael Gross
      Posted by Jens-Michael Gross
      on Aug 14 2012 06:19 AM
      Guru141810 points

      Mark Green
      Reg.bit0 = 1;
      comes out the same as
      Reg |= 0x01;


      Yes, this is identical. However, the "Reg.bit0=1;" obfuscates the fact that all other bits of Reg are read and written to, which may or may not cause side-effects.

      Also,

      Reg |= BIT1|BIT2|BIT5; is a single RMW isntruction, while doing the same with a bitfield results in three separate RMW operations. Since Reg is volatile, the compiler is forced to do exactly as many accesses as the code has. And with bitfields, this are three separate ones.

      This is why I said it is deprecated, not disallowed. :)

      Also, newer header files don't carry the bitfield definitions anymore.

      For self-defined bitfields, which are on normal memory and not volatils (not intended to be used inside ISRs), the compiler can perform optimization and group all accesses into one.

      _____________________________________
      Before posting bug reports or ask for help, do at least quick scan over this article. It applies to any kind of problem reporting. On any forum. And/or look here.
      If you cannot discuss your problem in the public, feel free to start a private conversation: click on my name and then 'start conversation'. But please do so only if you really cannot do it in a public thread, as I usually read all threads. And I prefer to answer where others can profit from it (or contribute to it) too.

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    TI E2E™ Community
    • Support Forums
    • Blogs
    • Videos
    • Groups
    • Site Support & Feedback
    • Settings
    TI E2E™ Community Groups
    • TI University Program
    • Make the Switch
    • Microcontroller Projects
    • Motor Drive & Control
    Other Communities
    • Deyisupport
    • Designsomething.org
    • beagleboard.org
    • TI on Element 14
    • TI on TechXchangeSM
    Other Technical & Support Resources
    • WEBENCH® Design Center
    • Product Information Centers
    • Technical Documents
    • TI Design Network
    • TI Technical Articles
    • TI Training

    All content and materials on this site are provided "as is". TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with regard to these materials, including but not limited to all implied warranties and conditions of merchantability, fitness for a particular purpose, title and non-infringement of any third party intellectual property right. TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with respect to these materials. No license, either express or implied, by estoppel or otherwise, is granted by TI. Use of the information on this site may require a license from a third party, or a license from TI.

    Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Terms of Use of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Terms of Use of this site. TI, its suppliers and providers of content reserve the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.

    Follow Us Texas Instruments on Facebook Texas Instruments on Twitter Texas Instruments on LinkedIn Texas Instruments on Google+
    TI Worldwide | Contact Us | my.TI Login | Site Map | Corporate Citizenship | mobile m.ti.com (Mobile Version)

    TI is a global semiconductor design and manufacturing company. Innovate with 100,000+ analog ICs and
    embedded processors, along with software, tools and the industry’s largest sales/support staff.

    © Copyright 1995-2013 Texas Instruments Incorporated. All rights reserved.
    Trademarks | Privacy Policy | Terms of Use