element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • 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
Internet of Things
  • Technologies
  • More
Internet of Things
Blog Need 2 Serial Ports but Only Have 1?
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Internet of Things requires membership for participation - click to join
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: txbeech
  • Date Created: 31 Jul 2015 2:11 PM Date Created
  • Views 1111 views
  • Likes 4 likes
  • Comments 2 comments
  • peripherals
  • element14
  • microcontrollers
  • internet_of_things
  • iot
  • communication
Related
Recommended

Need 2 Serial Ports but Only Have 1?

txbeech
txbeech
31 Jul 2015

It is common to have resource conflicts when designing with microcontrollers. It could be memory, I/O ports or any other constrained resources which often leads to having to choose a more expensive device with a larger package. I faced a similar situation using the EFM8 SB1 STK. The EFM8 STK is a starter kit platform with a Silicon Labs 8-bit MCU and is a nice platform for reference design because it has the EXP header for creating solutions. It also has some useful hardware like the Memory LCD to display data and a joystick for more user input.

 

My problem is that I needed the 3-wire SPI port for the expansion header or EXP, but it was being used on different ports for the memory LCD. If I were to design the board from scratch I could have used a chip select to share the SPI port with other peripherals. However, I don’t have that luxury because I am using off the shelf hardware so my ports are hardwired and there is no changing them. My added peripheral is a wireless transceiver that I will use to communicate with another MCU which also has a transceiver. I would also like to use the screen as a way of selecting what I want to send. Since the SPI port was already in use and the radio’s interface is through SPI I had to come up with a unique solution. After some head scratching and documentation reading, I learned that it’s quite easy and useful to reconfigure the pins of the SB1 MCU in real time making it possible to quickly switch which peripheral you wish to communicate with.


The Sleepy Bee 1 starter kit and the Si446x radio

imageimage

image

image

image

Si446x specs:

  • IEEE 802.15.4g
  • Frequency range = 119–1050 MHz
  • Receive sensitivity = –133 dBm
  • Max output power up to +20 dBm
  • PA support for +27 dBm or to +30 dBm
  • Data rate = 0.1 kbps to 1Mbps
  • Power supply = 1.8 to 3.8 V



 

The tool that comes free from Silicon Labs is Simplicity Studio. I will post a link to where you can download this if you wish. The tool is used on most of the Silicon Labs MCUs. Simplicity Studio is very similar to other IDEs and from it you can manage your projects, write code and debug. For each project you can make a configurator file like the one below.

image

In the configurator you can set certain states almost like a Mealy/Moore state machine. Once the states are created you can alter the pin configuration for each state. The two states that I will use are the SPI_Config_1 and SPI_Config_2. The image below compares the pins for SPI_Config_1, on the left, and SPI_Config_2 on the right. As you can see for the LCD which is SPI_Config_1, I have it hooked up to port 0 pins 6 and 7 as well as port 1 pins 0 and 1. For the radio I have port 0 pins 2, 3, 4 and 5 routed.

image

Each pin has many options for how it can be configured including its drive strength and type of input/output. All of these are altered and selected by a drop down menu in Simplicity Studio and are easy to configure. In the case of slave select on port 1 pin 1, I configured the drive strength as high and set it to be a digital push pull output, the rest are left as default.

image

Once you set up the pin configuration and save the project, Simplicity Studio will automatically generate code to enable those pins as you specified. The code is in a file called InitDevice.c in the form of functions that move from state to state.

In my project one of the functions is PORTS_0_enter_SPI_Config_2_from_DefaultMode(). This function configures the port 0 pins for SPI_Config_2 coming from DefaultMode by turning off and on pins as well as configuring them to the specifications in SPI_Config_2.

You can connect any states with one or two way transitions. For each transition and port, the configurator will automatically generate these functions. All you have to do from there is call these functions whenever you want to alter the configurations. The way my code flow works is to:

 

• Load something onto the LCD while in the SPI_Config_1 state

• Call the transition function to go back to DefaultMode

• Call the function to go to SPI_Config_2.

• Send a command to the radio

• Go back to SPI_Config_1 and repeat

 

I could most likely do this without the use of the default state but for educational purposes this approach worked. Simplicity Studio will not generate any redundant code, so if you keep some pin functionality constant between states, it will not reconfigure them again to the same thing. Below is an example of the generated code which sets bits in the registers to configure the pins.

  image

This application is a very simple example but you can imagine the usefulness and power of this real time reconfiguration. I could communicate with a number of peripherals: the only limit would be speed as the more devices hooked up the more switching there is and the longer a complete cycle of communication will be. While re-configuring might not be as efficient as each peripheral being on the same 3-wire SPI with individual selects it still allows a lot of freedom in designing the supporting hardware. This would be very useful for replacing old MCUs because a board redesign wouldn't be needed, in other words, switching to this part would only require a firmware change and not a surround hardware or board change.


Below are links for all the components and tools that I used.

EFM8 kits

  • Newark Part No.: 41Y1984


Wireless Transceivers

  • Newark Part No.: 49X9786


Simplicity Studio download

Simplicity Studio | Silicon Labs

 

  • Sign in to reply
Parents
  • michaelkellett
    michaelkellett over 9 years ago

    Most micros have multi function pins but only a few allow complete re-mapping of any function to any pin. It's a nice feature of some of the Silabs 8051 based parts but you would only use that architecture with some reluctance on a new design now.

    Do they offer it on any of their ARM Cortex based parts ?

     

    Some of the NXP Cortex M0 parts do offer comprehensive pin re-mapping and it can be very useful on low pinout devices.

     

    Of course FPGAs  offer the same for nearly every pin (but timing issues may restrict your choices).

     

    No one offers a high pin count micro with totally re-mappable pins - that would be really nice !

     

    MK

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • txbeech
    txbeech over 9 years ago in reply to michaelkellett

    Pin re-mapping is a feature that we will definitely keep in our mind moving forward with our 32 bit ARM based MCUs.  As the functionality and complexity of MCUs is increasing pin re-mapping will become even more useful.  The interest in our 8 bit MCUs is still strong and with IoT taking off, with its demand for low power, low cost and high quality analog peripherals, the interest in our 8 bits will increase!

     

    Beech

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
Comment
  • txbeech
    txbeech over 9 years ago in reply to michaelkellett

    Pin re-mapping is a feature that we will definitely keep in our mind moving forward with our 32 bit ARM based MCUs.  As the functionality and complexity of MCUs is increasing pin re-mapping will become even more useful.  The interest in our 8 bit MCUs is still strong and with IoT taking off, with its demand for low power, low cost and high quality analog peripherals, the interest in our 8 bits will increase!

     

    Beech

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
Children
No Data
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