It has been a while (my apologies) but a few weeks ago I posted about how you can Magically Reduce Coding Time with PSoC Creator. The thrust of the article was, in these days where no-one has time to read and digest multi-thousand page chip reference manuals, you really need a tool that generates the device code interface for you and guides you into making good decisions with your chosen hardware. Today I want to expand on that and show you how PSoC Creator implements a radical "pins-in" approach to configuring the device.
With traditional MCUs you get, or find, (or steal!!!) some driver code for a given peripheral and toil away making it work in your board. Typically the problem you face is not with the driver itself but that you need to figure out which block to use and what pins to route signals to (a peripheral block that does not connect to pins in some fashion is, after all, a bit boring). Taking a UART as my trusty example how do I choose between the half-dozen communication blocks in the device without knowing which one(s) connect to the pins I have access to on my board? Most development tools don’t help you make those choices. You just need to know that block 7 connects to pin 3 of port 4 and that is pin 26 on your device package, which is connected to the level shifter on your board. If you have a memory for numbers like I have then you'll soon be surrounded by sticky notes and feel like you have a picture of the device tattooed on the inside of your eyelids.
The usual "solution" to this from the device vendor is a library of examples for the peripherals. Example projects are really useful - we include hundreds of them with the PSoC Creator distribution after all - but their real purpose is to show you how to the use the peripheral, not how to configure the device. The reason why examples don’t help you configure the device in a real project is that they are all simple designs. When you have nothing else to support on the device it is easy to find a block that supports the functionality and connectivity you need. Where it goes wrong is when you are using most of the pins and your choice of UART block is making it impossible to get all the ADC channels connected. As soon as that happens you enter the trial-and-error process of iterating through pin choices to find a good fit. After a while having a real tattoo applied directly on the eyeball starts sounding like a good idea.
What you really need is a tool that understands the device fully. PSoC Creator only supports Cypress devices and we expend a lot of energy making sure it makes things like device configuration as easy as possible. In PSoC Creator you do not have to choose the communication block for the UART - you just choose the Rx and Tx pins. Why? Because that is the information you most likely have to hand when you are designing! When you put a UART into your project the pin editor is automatically updated with the IO that must be assigned physical pins. You just pick the pins you want to use by drag-and-dropping into the device picture or through drop-down menus.
The PSoC Creator Pin Editor Highlights Legal Pin Choices
The Pin Editor does not let you choose a pin that cannot support the function. Even without building the design you see the "legal set" of pins for the UART and once you make a choice the tool figures out which communication block to use. When you build the project the component API uses the right block and you never get a right-block-wrong-pin problem.
With serial communication blocks you, naturally, have a pair of signals to map. Once you have made a selection for the Rx then you will have reduced the legal set for the Tx. PSoC Creator helps you out again by highlighting the choices for Tx that are compatible with the Rx pin in green. It also shows the legal alternatives in gray because, if you pick one of these, the tool will force you to move the Rx pin onto a compatible location instead. You just cannot mess it up!
Pin Editor Guides You to Compatible Pin Combinations
PSoC fans will know that the devices include a lot of flexible routing that give you a lot more choices for pin selection than is available on other MCUs. As a result you can map the UART pins virtually anywhere but, while some pins are directly connected, some require routing resources to be used. The routing is, of course, calculated by PSoC Creator and your application never needs to care about the route but you might want to save those resources for another function entirely. To help you make resource-efficient decisions the tool highlights indirectly-accessible pins in yellow. When you see yellow pins in the editor there is no warning or error condition - the tool is just saying "you can get to that pin and I will generate the routing for you, but there might be a better route that uses fewer routing resources."
Pin Editor Menus Showing Direct and Indirect Pin Choices
Because it is developed along with the devices that it supports, PSoC Creator is able to reduce your development time by avoiding all the annoying setup errors that are famous with traditional MCUs. Interested? Download it from here. It’s free. And there are lots of examples!