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

Problem with crash

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



Joined: 04 May 2008
Posts: 260

View user's profile Send private message

Problem with crash
PostPosted: Fri Jul 31, 2009 2:25 pm     Reply with quote

Hi

I make a program for controller lights of my car but it crash many times, and I need turn off power for it restart...

This is my circuit:


This is my program:
Code:

#include <12F683.h>
#use delay(clock=4000000)
#fuses NOWDT,INTRC_IO, NOCPD, NOPROTECT, MCLR, NOPUT, BROWNOUT, IESO, FCMEN

#define LEDS PIN_A4
#define ALARMON PIN_A1
#define ALARMOFF PIN_A0
#define DOORS PIN_A2
#define IGN PIN_A5

void main()
{
int16 i;
int8 aux=0;
output_low(LEDS);

while(TRUE)
   {
   
   if (input(ALARMON)==0) output_low(LEDS);
   if (input(ALARMOFF)==0) output_low(LEDS);
   if (input(DOORS)==1) output_low(LEDS);
   
   if ((input(ALARMON)==1) && (input(IGN)==0))
   {
      output_high(LEDS);
      for (i=0;i<=40;i++)
         {
         delay_ms(500);
         if (input(IGN)==1) break;
         if (input(ALARMOFF)==1) break;
         }
   }
   
   if (input(DOORS)==0)
   {
      output_high(LEDS);
      while(DOORS!=1);
      for (i=0;i<=40;i++)
         {
         delay_ms(500);
         if (input(IGN)==1) break;
         if (input(ALARMOFF)==1) break;
         }
         }
   }
}

Someone have an idea how make this crashes?

kind regards
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Jul 31, 2009 3:06 pm     Reply with quote

Quote:
#define DOORS PIN_A2


if (input(DOORS)==0)
{
output_high(LEDS);
while(DOORS!=1);
for (i=0;i<=40;i++)
{
delay_ms(500);
if (input(IGN)==1) break;
if (input(ALARMOFF)==1) break;
}
}
}

The line in bold is wrong. Can you see the error ?
filjoa



Joined: 04 May 2008
Posts: 260

View user's profile Send private message

PostPosted: Fri Jul 31, 2009 5:03 pm     Reply with quote

Hi

why this line is wrong?

on PIN "DOORS" it stay at 5V when I close the doors and go to 0V when I open.

on PIN "Signal Doors Open" I have one pulse of 12V for central loock

on PIN "Signal Doors Close" I have one pulse of 12V for central loock

on PIN "IGN" I have 12V when I put key ON

is possible I need put pull-down on "Signal Doors Open", "Signal Doors Close" and "IGN"?

You think which program stay wrong? Confused
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Jul 31, 2009 5:18 pm     Reply with quote

Look at it closely. Compare that line to all the other lines that have
'DOORS' in them. What is missing ? There is one thing.
filjoa



Joined: 04 May 2008
Posts: 260

View user's profile Send private message

PostPosted: Fri Jul 31, 2009 6:14 pm     Reply with quote

Hi

I write "while(DOORS!=1); " for program wait there at I close the doors...

don't stay correct my thought? Confused
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Jul 31, 2009 6:43 pm     Reply with quote

What is 'DOORS' ? It's this:
Quote:
#define DOORS PIN_A2


What is 'PIN_A2' ? Look in 12F683.h to find this:
Code:
#define PIN_A2  42


So 'DOORS' is the number 42.


With that knowledge, look at your test:
Quote:
while(DOORS!=1);

Then substitute the value for 'DOORS' in that statement:
Code:
while(42 != 1);

That's your code. That's what it's doing. I ask you, is that correct ?
What should you do to fix it ? Look at your other statements that use
the 'DOORS' value.
filjoa



Joined: 04 May 2008
Posts: 260

View user's profile Send private message

PostPosted: Sat Aug 01, 2009 8:17 am     Reply with quote

Hi

I don't see the bug... problem is because I need have

while(input(DOORS)!=1);

I can see that when post my problem.. thanks for help
Ttelmah
Guest







PostPosted: Sat Aug 01, 2009 2:02 pm     Reply with quote

The point is that 'DOORS', is not the value of the input pin. It is a numeric value, which allows specific functions to access the pin. Your test, does not use these functions....

Best Wishes
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