oPossum 1,083 Posted August 28, 2011 Share Posted August 28, 2011 You forgot the break; statements in the delay() switch/case. The easy way to do it... void delay_ms(unsigned ms) { do __delay_cycles(100000); while(--ms); } Quote Link to post Share on other sites
nuetron 64 Posted August 28, 2011 Share Posted August 28, 2011 Why break;? I'm still learning. Quote Link to post Share on other sites
Theshadowwalker91 0 Posted August 28, 2011 Author Share Posted August 28, 2011 Thanks for the help. But will this code work on ccs. I am not use IAR. And i am also not useing rgb leds. But i dont think that matters. I am actually using two sets of red blue and green leds. Each set on a different pin so i can have half red and half green. I aready figured out the code for that. It is just the sequence at the end i am haveing truble with. Thanks alot. -Dan Quote Link to post Share on other sites
oPossum 1,083 Posted August 28, 2011 Share Posted August 28, 2011 Why break;? I'm still learning. A break is required to end a case block. switch(n) { case 1: // do something if n == 1 break; case 2: // do something if n == 2 break; } switch(n) { case 1: // do something if n == 1 case 2: // do something if n == 1 or n == 2 case 3: // do something if n == 1 or n == 2 or n == 3 break; } You could do this, but it is rather inefficient... void delay_ms(unsigned ms) { switch(ms) { case 10: __delay_cycles(100000); case 9: __delay_cycles(100000); case 8: __delay_cycles(100000); case 7: __delay_cycles(100000); case 6: __delay_cycles(100000); case 5: __delay_cycles(100000); case 4: __delay_cycles(100000); case 3: __delay_cycles(100000); case 2: __delay_cycles(100000); case 1: __delay_cycles(100000); } } nuetron 1 Quote Link to post Share on other sites
Theshadowwalker91 0 Posted August 29, 2011 Author Share Posted August 29, 2011 So will these examples work with ccs. As i am not useing IAR kickstart. Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.