CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

MPLABX and CCS led blink not as I want

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Ellest96



Joined: 15 Nov 2013
Posts: 17

View user's profile Send private message

MPLABX and CCS led blink not as I want
PostPosted: Fri Nov 15, 2013 3:58 pm     Reply with quote

I made this program...
http://pastebin.com/WSYK0DsU
what it should do:
-blink all leds from LED1 to LED6 (startup signal)
-set LED1 to 1, wait 50 ms (default value for variable K, blink frequency), set LED1 to 0; and repeat this.
-when I press BUTT1 (stays for BUTTon, non [spam]), the variable i become 1; when I press BUTT2, the variable j become 1.
-when i is 1, k=k+10; and when j is 1, k=k-50, so with those buttons I can adjust the frequency.

What it actually do:
-blink main leds (1-6) (startup sequence)
-blink LED7 forever.

why??????
gpsmikey



Joined: 16 Nov 2010
Posts: 588
Location: Kirkland, WA

View user's profile Send private message

PostPosted: Fri Nov 15, 2013 4:11 pm     Reply with quote

How is it supposed to get from your first "while(1)" block of code to the second "while(1)" block of code that flashes LED1?

mikey
_________________
mikey
-- you can't have too many gadgets or too much disk space !
old engineering saying: 1+1 = 3 for sufficiently large values of 1 or small values of 3
Ellest96



Joined: 15 Nov 2013
Posts: 17

View user's profile Send private message

PostPosted: Fri Nov 15, 2013 4:52 pm     Reply with quote

If i put all the code in one while(1) the problem is the same.

Last edited by Ellest96 on Sat Nov 16, 2013 5:43 am; edited 1 time in total
dyeatman



Joined: 06 Sep 2003
Posts: 1934
Location: Norman, OK

View user's profile Send private message

PostPosted: Fri Nov 15, 2013 6:18 pm     Reply with quote

So when are you going to fix the problem pointed out to you
by gpsmikey and show the new code that doesn't work? No one here is a
mind reader...
_________________
Google and Forum Search are some of your best tools!!!!
Ellest96



Joined: 15 Nov 2013
Posts: 17

View user's profile Send private message

PostPosted: Sat Nov 16, 2013 12:32 am     Reply with quote

By making one while with the code from the variables of the buttons to the end.
Delete lines from 64 to 68.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Nov 16, 2013 1:20 am     Reply with quote

Quote:
if (k=210) {

if (k=0) {

Read item #3 in the link below:
http://www.techgaun.com/2011/11/common-programming-mistakes-beginner.html
Ellest96



Joined: 15 Nov 2013
Posts: 17

View user's profile Send private message

PostPosted: Sat Nov 16, 2013 1:29 am     Reply with quote

Oops...
This afternoon i will test the program with that.
Ellest96



Joined: 15 Nov 2013
Posts: 17

View user's profile Send private message

PostPosted: Sat Nov 16, 2013 5:43 am     Reply with quote

so, I've modified the program...
http://pastebin.com/7ziSy40G
the problem is the same:
-6 main leds blink one time.
-LED7 blinks as he wants.
stinky



Joined: 05 Mar 2012
Posts: 99
Location: Central Illinois

View user's profile Send private message

PostPosted: Sat Nov 16, 2013 7:46 am     Reply with quote

Are your switches active high or active low?
Ellest96



Joined: 15 Nov 2013
Posts: 17

View user's profile Send private message

PostPosted: Sat Nov 16, 2013 7:49 am     Reply with quote

now all works perfectly!
http://pastebin.com/2MxXpBtd
I don't know why before I had problems.
gpsmikey



Joined: 16 Nov 2010
Posts: 588
Location: Kirkland, WA

View user's profile Send private message

PostPosted: Sat Nov 16, 2013 10:21 am     Reply with quote

PCM programmer wrote:
Quote:
if (k=210) {

if (k=0) {

Read item #3 in the link below:
http://www.techgaun.com/2011/11/common-programming-mistakes-beginner.html


Ah yes, missed those two - I've been trying to train myself to write code so the compiler will catch those. The answer is fairly simple - instead of "if ( k = 0 )" which sets K to 0 and is always true, you write it as "if (0 = k)" and the compiler will throw it out at which point, you go "duh" and change it to "if (0 == k)" and all is well. Takes a bit of retraining for these old grey cells though Rolling Eyes

mikey
_________________
mikey
-- you can't have too many gadgets or too much disk space !
old engineering saying: 1+1 = 3 for sufficiently large values of 1 or small values of 3
stinky



Joined: 05 Mar 2012
Posts: 99
Location: Central Illinois

View user's profile Send private message

PostPosted: Sat Nov 16, 2013 2:01 pm     Reply with quote

That's a great idea gps
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group