6 Replies Latest reply on Oct 5, 2017 2:28 AM by nikeboy

    PSoC 4 Pioneer Kit Community Project#014 – What was that value? Oh yea! LED Memory Example

    cy.wbz

      Hello!

       

      This example demonstrates to users how to store a value in flash so that when the device or kit is power cycled that the value is remembered. In this example we use the input button to select a color on the RGB LED. We can then cycle power or reset the device and the LED will return to that value (color) immediately.

       

      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.

       

      The example project accepts a user’s input from a push button to drive a series of colors onto the RGB LED. By holding down the button the output to the RBG LED cycles through a number of colors. Once the user lifts off of the push button the color is set.

       

      The value of the color selection, which is stored in SRAM, is then moved into Flash using a flash write API.

       

      When you cycle power on the device the value stored in flash is then loaded into the SRAM location and the color is reset on the RBG LED.

       

      Another feature of this example is the use of a driver file. Here a custom LED RGB driver file (.c and .h files) have been added to the project. This driver module is included as part of this project and is in the Header and Source files of the Workspace Explorer. These driver files were created specifically for the CY8CKIT-042 to target the RGB LED. This LED RGB driver file requires that three 16 or 8 bit PWMs be added to the user’s project. The LED RGB file supports the following APIs:

       

      void LED_RGB_Start(void);

      void LED_RGB_Stop(void);

      void LED_RGB_DCWrite(uint8 LED_Color, uint16 LED_NewDutyCycle);

      void LED_RGB_SetColorRGB(uint16 redIntensity, uint16 greenIntensity, uint16 blueIntensity);

      void LED_RGB_SetColorCircle(uint16 hue);

      void LED_RGB_SetColorCircleHSV(uint16 hue, uint16 saturation, uint16 value);

       

      Feel free to reuse this driver file in your designs with the Pioneer Kit.

       

      Hardware Connections:

       

      There are no hardware connections for this example as the project uses the existing hardware connections on the kit.

       

      Test Your Project:

       

      Once the kit is programmed begin pushing down on SW2 push button until a desired color is displayed on the RGB LED. Then Cycle power or push the Reset button on the Kit. You will see that that when you power up the kit, or the device returns from being Reset, that the LED displays the selected color.

       

      I hope this example can help you out in your design.

       

      Best,

      Matt