Announcements

Help us improve the Power & Sensing Selection Guide. Share feedback

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

I just want to change color on the RGB LED, I modify the PrISM example code.

   

here is the CODE:

   

void sleep(int s)
{
    int x;
    while(x<s)
        x++;
}

   

int main()
{

   

    /* Start PrISM */
    PrISM_1_Start();

   

    /* Enable Global Interrupts */
    CyGlobalIntEnable;
    
    /* No work has to be done in main loop */
    while(1u){
            PrISM_1_WritePulse0(255);
            PrISM_1_WritePulse1(0);
            sleep(1);
            PrISM_1_WritePulse0(255);
            PrISM_1_WritePulse1(255);
            sleep(1);
    }
    
}

   

 

   

but it only change two times, after that, it  is no longer to change

0 Likes
1 Solution
Anonymous
Not applicable

SOLVED.

   

In FindMe Profile example code,I added two PrISM in schematic.

   

But I found that StackEventHandler() executed following on startup:

   

        case CYBLE_EVT_GAP_DEVICE_DISCONNECTED:
            /* Start BLE advertisement for 30 seconds and update link
             * status on LEDs */
            CyBle_GappStartAdvertisement(CYBLE_ADVERTISING_FAST);

   

            PrISM_1_WritePulse0(RGB_LED_ON);
            PrISM_1_WritePulse1(RGB_LED_OFF);
            PrISM_2_WritePulse0(RGB_LED_OFF);
            RED_SetDriveMode(RED_DM_DIG_HIZ);
            GREEN_SetDriveMode(RED_DM_STRONG);
            BLUE_SetDriveMode(RED_DM_DIG_HIZ);

   

            alertLevel = NO_ALERT;
        break;

   

After this, the RGB LED will always turn on all the pulse density value (0), so that RGB LED is always WHITE!

   

And I can't to control it with new pulse density value, it seems blocks by something...

   

How could I to handle this? Thanks a lot!

View solution in original post

0 Likes
4 Replies
Anonymous
Not applicable

void sleep(int s)
{
    int x=0;
    while(x<s*1000000)
        x++;
}

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Welcome in the forum, Mop.

   

/* No work has to be done in main loop */

   

Take that comment literally! What you are doing is to change the PrISM parameters at a frequency which you cannot observe with the naked eye. Your first sleep() just needs less than 1µs to return. Better (easier, but more complex) would be to use a timer that changes every second your PrISM. To have something you can rely on use CyDelay(number of ms) description in "System Reference Guide"

   

It is always easier for us when you post your complete project, so that we all can have a look at all of your settings. To do so, use
Creator->File->Create Workspace Bundle (minimal)
and attach the resulting file. And do not forget to mention which kit you actually use.

   

 

   

Bob

0 Likes
Anonymous
Not applicable

SOLVED.

   

In FindMe Profile example code,I added two PrISM in schematic.

   

But I found that StackEventHandler() executed following on startup:

   

        case CYBLE_EVT_GAP_DEVICE_DISCONNECTED:
            /* Start BLE advertisement for 30 seconds and update link
             * status on LEDs */
            CyBle_GappStartAdvertisement(CYBLE_ADVERTISING_FAST);

   

            PrISM_1_WritePulse0(RGB_LED_ON);
            PrISM_1_WritePulse1(RGB_LED_OFF);
            PrISM_2_WritePulse0(RGB_LED_OFF);
            RED_SetDriveMode(RED_DM_DIG_HIZ);
            GREEN_SetDriveMode(RED_DM_STRONG);
            BLUE_SetDriveMode(RED_DM_DIG_HIZ);

   

            alertLevel = NO_ALERT;
        break;

   

After this, the RGB LED will always turn on all the pulse density value (0), so that RGB LED is always WHITE!

   

And I can't to control it with new pulse density value, it seems blocks by something...

   

How could I to handle this? Thanks a lot!

0 Likes
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

OK, I upload my combined project, just let RGB LED control by IAS

   

The first problem was solved, I remove the Time ISR,so I just coding in while loop, please to check out the FindMe project,I use PSOC BLE kit

   

Thanks a lot!

0 Likes