9S12ZVL Waterfall effect on RGB LED with other operation

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

9S12ZVL Waterfall effect on RGB LED with other operation

991 次查看
efrain_castro
Contributor II

Hello NXP community

I have been trying to run an RGB led and some WHITE leds at the same time using the timer and the delays in the S12ZVL64.
The RGB LED works as a waterfall to show different LED colors, let's say it produces an environment, while the WHITE LED is only for lighting, like turning on the light. What I'm trying to do is that the RGB is always on, while I can still turn on the WHITE leds through a button. The only problem I have is that when the RGB is running I can not turn on the WHITE leds unless I put a break; in the FOR of the RGB causing the cascade effect to disappear but at least the WHITE leds turn on.

What can I do so that the waterfall effect on the RGB led does not interfere with the WHITE leds?

void LED_Colors(void)
{ int i;

while(1){
//for(; ;)
//Red
//{
for(i=0;i<0xFF;i++)
{
BigTimerDelay(1);
PWM1DTY5+=1; //Red
PWM0DTY3=0x00; //Green
PWM0DTY7-=1; //Blue
}
//Green
for(i=0;i<0xFF;i++)
{
BigTimerDelay(1);
PWM1DTY5-=1; //Red
PWM0DTY3+=1; //Green
PWM0DTY7=0x00; //Blue
}
//Blue
for(i=0;i<0xFF;i++)
{
BigTimerDelay(1);
PWM1DTY5=0x00; //Red
PWM0DTY3-=1; //Green
PWM0DTY7+=1; //Blue
}
break;
// }
}
}

void BigTimerDelay(unsigned int ttime)
{
unsigned int i;

TIM0TSCR1 = 0x80; //enable timer
TIM0TSCR2 = 0x01; //Prescaler=1 (2nd way to control Delay size is using 0 to 7)

for(i=0;i<ttime;i++)
{

TIM0TFLG2 = 0x80; //clear the TOF flag

//while (!(TIM0TFLG2 & TIM0TFLG2_TOF_MASK)); //wait for Timer Overflow
while ((TIM0TFLG2 &0x80)==0); //you can use this line instead
}

}

标签 (1)
0 项奖励
回复
1 回复

864 次查看
dianabatrlova
NXP TechSupport
NXP TechSupport

Hello Efrain,

Unfortunately, I cannot see your interrupt routine and pin which is connected to button from your description nor from the code. So, for example, I have added the interrupt function for Port P, pin PP4 below. Do not forget to clear the interrupt flag. 

interrupt VectorNumber_Vportp void turn_on_LED_ISR(void){


PIFP |= PIFP_PIFP4_MASK;  /* Clear the PP4 interrupt flag */

}

I hope it helps you.

Best Regards,

Diana

0 项奖励
回复