<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.element14.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>PSoC4 Smarter Life Challenge - DAS Project :Example 4 (PrISM LED Dimming)</title><link>https://community.element14.com/challenges-projects/design-challenges/smarter-life/w/documents/16724/psoc4-smarter-life-challenge---das-project-example-4-prism-led-dimming</link><description /><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>PSoC4 Smarter Life Challenge - DAS Project :Example 4 (PrISM LED Dimming)</title><link>https://community.element14.com/challenges-projects/design-challenges/smarter-life/w/documents/16724/psoc4-smarter-life-challenge---das-project-example-4-prism-led-dimming</link><pubDate>Wed, 17 Dec 2014 03:55:17 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:ae30f37d-805e-47fa-8f82-92e8857088da</guid><dc:creator>bose</dc:creator><comments>https://community.element14.com/challenges-projects/design-challenges/smarter-life/w/documents/16724/psoc4-smarter-life-challenge---das-project-example-4-prism-led-dimming#comments</comments><description>Current Revision posted to Documents by bose on 12/17/2014 3:55:17 AM&lt;br /&gt;
&lt;p style="margin:0;"&gt;This example shows how to perform the LED Dimming using the PrISM module for the Cypress PSoC 4 Pioneer kit.&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;Here is the Application Schematics:&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;span&gt;&lt;a href="https://community.element14.com/resized-image/__size/625x414/__key/communityserver-wikis-components-files/00-00-00-01-96/8308.contentimage_5F00_45821.png"&gt;&lt;img alt="image" src="https://community-storage.element14.com/communityserver-components-secureimagefileviewer/communityserver/wikis/components/files/00/00/00/01/96/8308.contentimage_45821.png-620x411.png?sv=2016-05-31&amp;amp;sr=b&amp;amp;sig=eEEofB2PWJ2RhCrFT3kWvx%2BmYl0EG9ac2XfLuq81IK0%3D&amp;amp;se=2026-08-20T23%3A59%3A59Z&amp;amp;sp=r&amp;amp;_=V8/TbHtQQIFRmZK8bz9j8g==" style="max-height: 411px;max-width: 620px;" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;span&gt;&lt;a href="https://community.element14.com/resized-image/__size/1274x704/__key/communityserver-wikis-components-files/00-00-00-01-96/7713.contentimage_5F00_45822.png"&gt;&lt;img loading="lazy" alt="image" src="https://community-storage.element14.com/communityserver-components-secureimagefileviewer/communityserver/wikis/components/files/00/00/00/01/96/7713.contentimage_45822.png-620x343.png?sv=2016-05-31&amp;amp;sr=b&amp;amp;sig=EV8FozidtgvKdqX%2BcD0nikyyTZEkFDkU90Y8ZpbIBvk%3D&amp;amp;se=2026-08-20T23%3A59%3A59Z&amp;amp;sp=r&amp;amp;_=slK2CPDXymORG6gle1yRTQ==" style="max-height: 343px;max-width: 620px;" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;"&gt;This example uses the PrISM module as the sole control of the LED output as well as the interrupt source to update the LED intensity(called Density in the program + PrISM API).&lt;/p&gt;&lt;p style="margin:0;"&gt;The internal timeout of the PrISM module is used to activate the ISR for the LED intensity update.&lt;/p&gt;&lt;p style="margin:0;"&gt;The PrISM module { &lt;strong&gt;PrISM [v2.20]&lt;/strong&gt; } Settings are as follows:&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;span&gt;&lt;a href="https://community.element14.com/resized-image/__size/515x392/__key/communityserver-wikis-components-files/00-00-00-01-96/5658.contentimage_5F00_45823.png"&gt;&lt;img loading="lazy" alt="image" src="https://community-storage.element14.com/communityserver-components-secureimagefileviewer/communityserver/wikis/components/files/00/00/00/01/96/5658.contentimage_45823.png-515x392.png?sv=2016-05-31&amp;amp;sr=b&amp;amp;sig=U%2FmBAzUDB1OqSJMhiWleYoyvQVSY7VBq0U0Gltin0lQ%3D&amp;amp;se=2026-08-20T23%3A59%3A59Z&amp;amp;sp=r&amp;amp;_=5W5VaVLASlDgGvISZzTImg==" style="max-height: 392px;max-width: 515px;" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;"&gt;In the code the LED intensity (Density factor) is stored and incremented to reach a specified high value. Then the operation flag is change and decrement is performed till it reaches near low value.&lt;/p&gt;&lt;p style="margin:0;"&gt;This cycle continues to give the breathing led effect like in the &lt;a class="jive-link-external-small" href="/challenges-projects/design-challenges/smarter-life/w/documents/16749/psoc4-smarter-life-challenge---das-project-example-3-led-dimming-pwm-based" target="_blank"&gt;previous example&lt;/a&gt;.&lt;/p&gt;&lt;p style="margin:0;"&gt;Here is the code for this example:&lt;/p&gt;&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#include &amp;lt;project.h&amp;gt;
uint8 val = 0; // Used as a counter to store the LED Density value
uint8 dir = 0; // Used as a flag to determine increment-1 or decrement-0 operation
CY_ISR(Dimmer)
{
    if((val == 0x00u) || (val == 0xFFu)) //Check for Maximum or Minimum value
    {
        dir ^= 1; // Perform a Flag operation Flip using XOR
       //- First time Increment will be automatically set as value of counter is 0
    }
    if(dir&amp;amp;1) //Increment if the Direction is 1
    {
        val++;
    }
    else // Decrement if the Direction is 1
    {
        val--;
    }
    // Apply the calculated LED intensity value as a PrISM duty cycle value.
    PrISM_1_WritePulse0(val);
}

int main()
{
     // Configure PrISM module
     PrISM_1_Start();
     // Enable the ISR on PrISM overflow to perform the Dimming
     isr_Mod_StartEx(Dimmer);
     // Enable Interrupts
     CyGlobalIntEnable;
     while(1) ;
}&lt;/pre&gt;&lt;/p&gt;&lt;div style="display:none;"&gt;&lt;/div&gt;&lt;p style="margin:0;"&gt;After Building and loading this code the Green Color in the RGB LED would show the breathing effect.&lt;/p&gt;&lt;p style="margin:0;"&gt;This time one can clearly notice the smoothness in the effect rather than the&lt;a class="jive-link-external-small" href="/challenges-projects/design-challenges/smarter-life/w/documents/16749/psoc4-smarter-life-challenge---das-project-example-3-led-dimming-pwm-based" target="_blank"&gt; PWM based&lt;/a&gt; approach.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;

&lt;div style="font-size: 90%;"&gt;Tags: psoc4, examples, smarter, das_project, smarter_life&lt;/div&gt;
</description></item></channel></rss>