element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • 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
Cypress Kits
  • Products
  • Dev Tools
  • Cypress Kits
  • More
  • Cancel
Cypress Kits
Forum PSoC 4 Pioneer Kit Community Project#014 – What was that value? Oh yea! LED Memory Example
  • Blog
  • Forum
  • Documents
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Cypress Kits to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • Replies 6 replies
  • Subscribers 28 subscribers
  • Views 1388 views
  • Users 0 members are here
  • 100projects
Related

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

cy.wbz
cy.wbz over 12 years ago

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

Attachments:
8507.Project Images.zip
KIT042_RGB_FlashWriteRead.cydsn.zip
  • Sign in to reply
  • Cancel

Top Replies

  • Former Member
    Former Member over 12 years ago in reply to DAB +1
    DAB, It only records the one most recent hue value, and when the button is held down, it scans through all possible hue values continuously. You could easily store 64 more hues in the array and restore…
  • jesusantoniocar
    jesusantoniocar over 12 years ago in reply to Former Member +1
    hello Matt, Max. Thanks for this example, very useful, i will use this in my project, today i test the code and work great. best regards, Jesus Antonio.
  • Former Member
    Former Member over 12 years ago

    Hey guys,

     

    I hope you enjoy this example. The LED driving library is probably more interesting than the flash write/read, but hopefully both are useful.

     

    If you stay tuned, we'll be posting a follow-up which uses custom linker flags to place the memory value in a user-selected fixed location in flash.

     

    Let me know if you have any questions.

    -Max K

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • DAB
    DAB over 12 years ago in reply to Former Member

    Hi Max,

     

    If I understand your description correctly, are you establishing preset values sort of like the old AM/FM radio presets?

     

    I like the idea, it allows users to set up their own "Mood" lighting values for use in projects.

     

    I really like this series, I hope other vendors take a similar approach to show off their latest devices.

     

    Very cool idea,

     

    DAB

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Former Member
    Former Member over 12 years ago in reply to DAB

    DAB,

     

    It only records the one most recent hue value, and when the button is held down, it scans through all possible hue values continuously. You could easily store 64 more hues in the array and restore them at startup, and then use them for your own nefarious purposes.

     

    Glad you're enjoying it!

     

    -Max

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
  • jesusantoniocar
    jesusantoniocar over 12 years ago in reply to Former Member

    hello Matt, Max.

    Thanks for this example, very useful, i will use this in my project, today i test the code and work great.

     

    best regards,

     

    Jesus Antonio.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
  • Former Member
    Former Member over 12 years ago in reply to jesusantoniocar

    Glad to hear it! Let me know if you have any questions or suggestions to improve it.

     

    -Max

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • nikeboy
    nikeboy over 7 years ago

    Hello people

     

    Pls help me. I am using PSoC4/ PRoC BLE and i have tried programming it with the above project. when i press the sw2 button the hue of the led varies and that looks great. but when i hit the reset button it is getting back to the initial position that is red color but not the previous color. why is it so?

     

    Regards

    Nike

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