clarence501
Junior Member level 3
- Joined
- Jan 24, 2011
- Messages
- 26
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Location
- Philippines
- Activity points
- 1,463
Hey Guys, I really need your professional help right now. I'm making this 24 second shotclock timer for my project.
I have been able to make the source code for setting the 24 shot clock, using interrupt. But I'm stuck on how to do the timing. What I want to do is to set the shot clock either from 0-24 value and then when i switch RB4 == 1 and press the interrupt RB0 again, it will start counting on the current set value. I don't know how to do that yet. Can you guys give me some professional Help? This is the ISIS circuit model :**broken link removed**
Here is my source code:
I have been able to make the source code for setting the 24 shot clock, using interrupt. But I'm stuck on how to do the timing. What I want to do is to set the shot clock either from 0-24 value and then when i switch RB4 == 1 and press the interrupt RB0 again, it will start counting on the current set value. I don't know how to do that yet. Can you guys give me some professional Help? This is the ISIS circuit model :**broken link removed**
Here is my source code:
Code:
#include <pic.h>
int num = 0;
void initialize(void);
void timing(void);
void do_outputs(void);
void main(void)
{
initialize();
while(1)
{
do_outputs();
timing();
}
}
void initialize(void)
{
PORTC = 0x40;
PORTD = 0x40;
TRISC = 0x00;
TRISD = 0x00;
INTEDG = 0;
GIE = 1;
INTE = 1;
}
void timing(void)
{
}
void do_outputs(void)
{
GIE = 0;
if (INTF)
{
INTF = 0;
if((RB2==1) && (RB4==0))
{num++;}
if((RB2==0) && (RB4==0))
{num--;}
{
if(num==-1)
{
num=24;
PORTC = 0x10;
PORTD = 0x40;
}
if(num==0)
{
PORTC = 0x40;
PORTD = 0x40;
}
if(num==1)
{
PORTC = 0x79;
PORTD = 0x40;
}
if(num==2)
{
PORTC = 0x24;
PORTD = 0x40;
}
if(num==3)
{
PORTC = 0x30;
PORTD = 0x40;
}
if(num==4)
{
PORTC = 0x19;
PORTD = 0x40;
}
if(num==5)
{
PORTC = 0x12;
PORTD = 0x40;
}
if(num==6)
{
PORTC = 0x02;
PORTD = 0x40;
}
if(num==7)
{
PORTC = 0x78;
PORTD = 0x40;
}
if(num==8)
{
PORTC = 0x00;
PORTD = 0x40;
}
if(num==9)
{
PORTC = 0x10;
PORTD = 0x40;
}
if(num==10)
{
PORTC = 0x40;
PORTD = 0x79;
}
if(num==11)
{
PORTC = 0x79;
PORTD = 0x79;
}
if(num==12)
{
PORTC = 0x24;
PORTD = 0x79;
}
if(num==13)
{
PORTC = 0x30;
PORTD = 0x79;
}
if(num==14)
{
PORTC = 0x19;
PORTD = 0x79;
}
if(num==15)
{
PORTC = 0x12;
PORTD = 0x79;
}
if(num==16)
{
PORTC = 0x02;
PORTD = 0x79;
}
if(num==17)
{
PORTC = 0x78;
PORTD = 0x79;
}
if(num==18)
{
PORTC = 0x00;
PORTD = 0x79;
}
if(num==19)
{
PORTC = 0x10;
PORTD = 0x79;
}
if(num==20)
{
PORTC = 0x40;
PORTD = 0x24;
}
if(num==21)
{
PORTC = 0x79;
PORTD = 0x24;
}
if(num==22)
{
PORTC = 0x24;
PORTD = 0x24;
}
if(num==23)
{
PORTC = 0x30;
PORTD = 0x24;
}
if(num==24)
{
PORTC = 0x19;
PORTD = 0x24;
}
if(num==25)
{
PORTC = 0x40;
PORTD = 0x40;
num = 0;
}
}
GIE =1;
}
}
Last edited by a moderator: