New Toys!

Hello all,
Hope you’ve all been good. Been kinda busy with finals, but yippee, I’m done! Hopefully, that is.
I recently stumbled upon the PSoC 4 CY8CKIT - 049 4xxx, which is a $4 development board for Cypress PSoC hardware, specifically the PSoC 4 family (apparently there are PSoC 1, PSoc 3 and PSoc 5 families as well). If you don’t know what a PSoC is, you can find out at Wikipedia. Trust me, their explanation is pretty good.
In a nutshell, I was intrigued by the notion of a device like the PSoC, which, rather than relying on the traditional code-centric approach we’ve all come to love/hate (as the case may be), relies on a drag and drop style of development. At compile-time, the top-level design resulting from all that dragging and dropping is converted into code for the PSoC core. The interesting part is that the PSoC is really closer to a mash-up between a microcontroller and an FPGA. Thus, it’s probably more accurate to say that the top-level design is errm…synthesized into something the PSoC core (which is actually built around an ARM Cortex M0 in the case of the PSoC 4) can understand and run. These designs are based on blocks called components, and there are soooo many components in the PSoC Creator (the IDE used for these devices) catalog. Essentially, you drag a component into a design, configure it, possibly connect it to other blocks and then build the design. You DO in fact write code, but that’s mostly to glue the operation of the individual components together. The drag and drop part is meant for configuration of the individual hardware components (which can also be done in code, but hey, been there done that right?) and their interconnections. And one major cool part of this all is: there are also analog blocks! So its not just the digital stuff we’re used to. More on this in a later post, I hope. I also read that the pins on the PSoC 4 family (which the chip on this devkit belongs to) are really flexible, and that you can route any function to any pin. While I haven’t explored that personally (I just got the kit yesterday..or two days ago. can’t remember) it would certainly be awesome if that’s true. Here’s an excerpt from the PSoC Creator IDE start page:

“Unlike fixed function microcontrollers, PSoC allows you to choose the on-chip peripherals you need. Instead of settling for a part that has most of what you need and a lot of what you don't, with PSoC you simply configure the device with your chosen functionality. No more, no less.
And the configuration process couldn't be easier. You choose peripherals from a catalog of pre-defined and pre-tested components and simply drag them into your design schematic. The components range from simple gates for glue logic, through complete implementations of digital and analog peripheral functions, up to sophisticated communications and applications solutions like USB and CapSense. Then choose your clock frequencies, connect peripheral I/O to pins, and you're done. The built-in configuration tools map your design into the device and calculate the clock setup and routing automatically.
But this is not the complex hardware configuration process you've seen before. All components are parameterized so that the details of the implementation are abstracted away. You set up components in terms that are natural to their function; such as the baud rate for a UART, power and gain for an amplifier, or duty cycle of a PWM.
You are about to see that, like no other platform available today, PSoC Creator and PSoC form a uniquely flexible combination to design and build your own system-on-chip in less time than it takes you to read the competitors' data sheets!”

And another:

“An embedded device is only as good as the software controlling it. With those old-fashioned fixed function microcontrollers, that software can be really difficult to get right. There is assembler code that won't port to new architectures, memory maps that vary between devices, and peripherals with complex and confusing register sets. PSoC Creator avoids those problems by combining a C-based development flow with automatically generated software APIs for the components in your design.”

And one more for the road:

“Our APIs make controlling your on-chip peripherals simple and fast. They are consistently named so you soon get used to using them and can often work with a new component without even opening the datasheet to check the software interface. You don't need to learn esoteric register names and write ugly macros to manipulate bit-fields. The APIs reduce coding errors and ensure correct interaction with the peripheral so the whole software development is faster, easier and less error prone.”

I’ve probably murked the waters of your understanding a bit…its rather difficult to explain, so please see the Wikipedia page for more (and clearer) information. My apologies.
Now, to the object of this blog post. If you’re like me and cannot pass up really cheap devkits (I know I have a TI Launchpad around somewhere...) then you’ll probably go ahead and buy this thing. Then, you’ll need to head over to the product page and download either the 1GB ISO or one of the 600-700MB downloads. Personally, I downloaded PSoC Creator 3.0 SP2 by itself (from the website, after some looking around), installed that, then got one of the smaller (683MB) downloads (I really didn’t want the 1GB one) and then installed that. That latter step is very important, as it contains certain files needed to get up and running with this thing.
Next off, plug the thing into your computer. If you’ve run the 683MB installer, you should now have drivers for the device. Got mine off of Windows Update though, because I was online at the time. It should show up as a regular USB Serial Port.
Apparently, the bootloader utility requires that the board is assigned a COM port number below 10. Follow the steps in the user guide to change the assigned port number if necessary.
You can now fire up PSoC Creator. You’re required to register your Keil license (Keil are a company that make dev tools for embedded hardware, and they provide some software used by PSoC Creator, I think. Anyway, if you don’t register it, it stops working within 30 days so you really should do it). To do that, open the Help menu at the top of the screen, and select the Register sub-item. A submenu with “Keil…” and “PSoC Creator…” should appear. Select Keil and follow the on-screen instructions. If you get an error about not being to open some webpage, just open the link shown in the error dialog in your favorite browser and follow the on-screen instructions. Bye bye baby.
Next, return to the user guide and skip read to the section about programming the board with the bootloadable blinking LED code. I had some trouble here, which is the true object of this post.
The user guide says to open the “SCB_Bootloader” workspace (which you should have once you’ve run the installations described above), save the workspace in a suitable folder, then set the Bootloadable blinking LED project as the active project, build that and finally program the board using the Bootloader utility accessible from the Tools menu. Well, I did that, and it didn’t work. Specifically, in the output window, I got a message saying “The command ‘cyelftool.exe’ failed with exit code ‘1’”.
Fast forward to half an hour later, and I seem to have solved the problem. So here’s what I did:
1.       With the SCB_Bootloader workspace open in PSoC Creator, right-click the ‘UART_Bootloader’ project, and select “Device Selector”. A dialog appears with a list of devices. A massive list.
2.       Look closely at the chip on your particular devkit. Mine came with a CY8C4245 XI-483 chip. Depending on the variant you get/got, you could end up with the CY8C41** chip. If you ended up like me, with the CY8C4245 XI-483 chip, select the CY8C4245AXI-483 option in the dialog. I don’t know whether you need to do this for the CY8C41** chip, mostly because I don’t have one.
3.       Once that’s done, right click the project again, then select “Clean and Build UART_Bootloader”. That should complete without any errors.
4.       Right-click the Bootloadable component in the design, then select Configure. Click on the Dependencies tab, then point the HEX and ELF files to the HEX and ELF files in the folder where you saved the workspace. For example, if I saved my workspace in a folder called X, I should have a folder called SCB_Bootloader within X. Within the SCB_Bootloader folder should be a UART_Bootloader.cydsn folder. Within that, there should be a CortexM0 folder. Within that, there should be an ARM_GCC_473 folder. Within that, there should be a Debug folder. Within that, there should be a number of files, including UART_Bootloader.hex and UART_Bootloader.elf. Thus, when you are looking for the bootloader HEX and ELF files in the Dependencies tab, point to these files and not the ones that came with the software installation. See below for more information.
5.       Next, assuming you’ve set “Bootloadable Blinking LED” as the Active project, right-click it and select the CY8C4245AXI-483 device via the Device Selector option as described in step 2. Next, right-click on the project and select “Clean and Build Bootloadable Blinking LED”. That should now complete without any errors as well. You should see something in the output window about the Flash and SRAM memory used, both here and in step 3 above.
6.       Follow the rest of the user guide regarding invoking the bootloader host program from the Tools menu, getting the chip into bootloader mode and programming it.

Since I’m a bit freer these days, I definitely want to play with this some more and see what I can do with it. I don’t know that the instructions above will not lead to your computer or devkit exploding, so please use these instructions at your own risk. I hope that if you do in fact take the red pill (and follow the instructions regardless of my ominous warning), that they’ll work for you. I understand why changing the device is necessary, but I’m not sure why I needed to rebuild the UART_Bootloader HEX and ELF files to get cyelftool.exe to stop giving that pesky error. Oh well, c’est la vie.
If of course, you did not purchase one of these or do not plan to, then the bulk of this post is useless to you. So, Hi J
Enjoy!



Comments

Popular posts from this blog

Enabling SPI1 on the Raspberry Pi B+/Zero/2/3

Bitbanging SPI on the Raspberry Pi (via spi-gpio)

Getting Started with Logic Analyzers and Pulseview