element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Ultimate RoadTest
  • Challenges & Projects
  • Design Challenges
  • Ultimate RoadTest
  • More
  • Cancel
Ultimate RoadTest
Blog Project "code name" PostScript 009
  • Blog
  • Forum
  • Documents
  • Files
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: COMPACT
  • Date Created: 13 Jul 2012 11:21 PM Date Created
  • Views 653 views
  • Likes 0 likes
  • Comments 0 comments
  • ultimate_roadtest
Related
Recommended

Project "code name" PostScript 009

COMPACT
COMPACT
13 Jul 2012

July 14th

More on the Solution to the Odd problem

The solution is working very well and hasn't failed yet.

My polled SPI drivers do not use the UCBUSY status bit at all.

All I do is poll the UCTXIFG flag on UCA1IFG prior a transmit and poll the UCRXIFG (also on UCA1IFG) flag after it.

When the UXRXIFG flag is set, the UCA1RXBUF is read irrespective of whether the value is used later or not.

 

Here's an example.

 

unsigned char sendchar1SPI(unsigned char d, unsigned char cntl_nCS) {
    unsigned char b;

 

    // Assert Chip Select if it was requested
    if (cntl_nCS != 0) {
        UCA1CTLW0 |= UCSWRST;              // Ensure clean start
        UCA1CTLW0 &= ~UCSWRST;

        nCS_POUT &= ~DEVICE_nCS;
    }

 

    // Perform SPI transaction

    while((UCA1IFG & UCTXIFG) == 0);        // Ensure transmit buffer ready

    UCA1TXBUF = d;                          // Transmit character
    while((UCA1IFG & UCRXIFG) == 0);        // Ensure transmission has completed
    b = UCA1RXBUF;

 

    // Negate Chip Select if it was requested
    if (cntl_nCS != 0)
        nCS_POUT |= DEVICE_nCS;

 

    return b;
}

 

My MSO has confirmed this produces textbook timing.

  • Sign in to reply
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube