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

Interrupts problem

 
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

Interrupts problem
PostPosted: Fri Nov 07, 2008 7:52 am     Reply with quote

Hi

I try make one project for controller part of car alarm, but stay with some problems because need use interrupts but I dont know how Crying or Very sad

this program work:
1º-wait for ignition from the car, after start program

2º-after ignition ON, need in "x"(distance from ABS) impulses which "sens" stay TRUE.

3º-if sens=TRUE, stay all ok and car run normally, if sens=FALSE it jump for function stop();

4º-in function stop() it start cut for 1 second injection after wait 20 seconds for driver put sens=TRUE and repeat this 3 times. After this 3 times sens continue FALSE go to function off(); and stop car.

5º- in function run(); it wait for doors open or ignition off, if some of them happen, it restart program (I don't know how).


This is my program and problem stay in comment:
Quote:

#include <18F252.h>
#fuses EC_IO,NOWDT,NOPROTECT,NOLVP
#use delay(clock=40000000)
#use rs232(baud=115200, parity=N, xmit=PIN_C6, rcv=PIN_C7, bits=8)

#build(reset=0x200)
#build(interrupt=0x208)
#org 0x0000,0x01ff
void bootloader() {
#asm
nop
#endasm
} // Reserve space for the bootloader

//###### IN PORTS ######
#define DOOR PIN_B7
#define BREAK PIN_B6
#define RFID PIN_B5
#define ABS PIN_B4
#define IGN PIN_B3

//###### OUT PORTS ######
#define RED PIN_C4
#define GREEN PIN_C5
#define R1 PIN_C0
#define R2 PIN_C1
#define R3 PIN_C2
#define R4 PIN_C3


void run()
{
int8 doors, ignition;
doors=0;
ignition=0;

do
{
doors=input(DOOR);
ignition=input(IGN);
}while(doors!=0 || ignition!=0);

//restart program
}

void off()
{
output_high(R2);
}

void stop()
{
output_high(R1);
delay_ms(1000);
//wait 20seconds for sens=input(ING) is TRUE
output_high(R1);
delay_ms(1000);
//wait 20seconds for sens=input(ING) is TRUE
output_high(R1);
delay_ms(1000);
//wait 20seconds for sens=input(ING) is TRUE

off();
}

void main ()
{
int8 start,sens,wait;

start=0;
sens=0;
wait=0;

while(1)
{
do
{
start=input(IGN);
}while(start!=0);

do
{
sens=input(RFID);
wait=wait++; //or wait 40000000 impulses from input wave
}while((sens!=0 && wait!=40000000) || wait!=40000000);

if (sens==1) run();
else stop();
}
}


variables "wait" and "sens=input(ING)" need work with an interrupts correct?

some one can help me?

kind regards, Filipe Abrantes
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