4 Replies Latest reply on Jul 26, 2013 2:07 PM by DAB

    PSoC 4 Pioneer Kit Community Project#059 – But Wait There’s More! Single PWM with 3 Outputs




      Today’s example plays like one of those late night TV infomercials. First we showed you how to use a PWM with the PSoC 4. We then had an example that showed you how to create two PWM outputs using one PWM. Like in those late night infomercials we say “But wait there’s more”! In today’s example we present a custom component that takes one PWM and creates three outputs.


      In this example we create a custom PWM component that performs a triple compare, implements an 8-bit PWM with three separate outputs, and independently configurable values. This custom component uses one Universal Digital Block (UDB) resource to implement the triple output. The component uses one datapath and three macrocells resources. This is very useful since the PSoC 4 device only has four UDB resources and four TCPWM modules. Implementing this PWM will allow the user to save resource space and add more value to their system.


      001 - Schematic Design.png


      Forum Post Attachments:


      At the bottom of this post we are including the following items:

      • Example Project Zip File
      • Zip File of Images
        • Project Schematic
        • Component Configurations


      Components Used:


      The user can download the example project at the bottom of this post. The project uses the following list of Creator Components:

      • PWM
      • CyClock
      • CyPin


      The components are configured by right clicking on the component in your Top Design schematic view and selecting Configure. Please enable the following selections in the Configuration windows for the listed components above.


      Firmware Description:


      The main.c firmware is included in the example project. Please review the commented sections for more details.


      In this example we dive deeper into the guts of what makes a PSoC so unique and useful for engineers. As described earlier we show you the progression of a single output PWM, dual output PWM, and now a triple output PWM. As we increase in complexity we dive deeper into the programmable peripherals of the PSoC.


      This custom component allows users to connect three outputs to a single PWM. This is extremely useful when trying to maximize on-chip resources. In our previous examples such as LED Memory and Paint The Night we used three PWM components to drive the RGB LED on the Pioneer kit. This is very wasteful of the UDB and TCPWM resources on the PSoC 4 device. Custom components like the triple PWM will allow users the ability to better manage chip resources and still design the system to meet the design expectations.


      The triple PWM component supports the following set of APIs to control the PWM capabilities:

      • PWM_3CMP_Start()
      • PWM_3CMP_ReadPeriod()
      • PWM_3CMP_WritePeriod(uint8 value)
      • PWM_3CMP_ReadComparex()
      • PWM_3CMP_Write_RGB(uint32 color)
      • PWM_3CMP_WriteComparex(uint8 value)
      • PWM_3CMP_WriteIntensityx(uint8 value)


      (Where ‘x’ is 0,1, or 2).


      In a later post we will discuss more with Antonio about how this component was developed and how that knowledge can help you re-think how you approach to embedded designs.


      Hardware Connections:


      There are no hardware connections in this example. Simply map out the PWM outputs to three pins, select your PWM output and connect the output to the RGB LED or connect it to an Oscope to test the ranges of outputs.


      Test Your Project:


      Program the Pioneer kit with the example and connect the PWM outputs to the RGB LED or to an Oscope to test the PWM capabilities.


      I hope this example can help you in your design.