Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

combining to programs

Status
Not open for further replies.

sonic05

Member level 1
Joined
Mar 14, 2010
Messages
32
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Location
Manila
Activity points
1,580
please anybody can teach me how to combine two programs using void...

and i want to know to call it using switch...

the ic that i used is 16f877a
 


I'm not sure what 'void' has to do with it. All it does it tell the compiler the function after it does not return a value.
When you say 'combine two programs' do you mean two functions, within the same program or functions in a different '.C' programs?

In either situation, the switch command takes a parameter which you use to decide which exit from the statement you intend to take. Within the switch command you have either 'case' or 'default' statements. There should only be one 'default', it's the exit taken if all the 'case' checks fail. Each case has a condition which if true, makes the following code execute, if false, the program looks for the next 'case' or 'default' statement to check instead. You can run any code within a case statement, including calls to other functions.

Brian.
 

@betwixt yes can you please help me for some part of this program...
 

Could you not refer the links & study it? Then if you have doubts,do post it in the forum. We are here to help you..........
Regards,
Jerin. :)
 

You didn't answer my original question.

Basically, a switch/case structure works the same as several "if (something is true) do ThisFunction() ;" statements, the difference is that the 'case' value must be a constant and that you can use 'default' as a catch-all if all the previous 'case' values failed to match. For example:

switch (MyValue)
{
case 1: FunctionMyValueWas1(...) ;
case 2: FunctionMyValueWas2(...) ;
case 3: FunctionMyValueWas3(...) ;
default: FunctionMyValueWasSomethingElse(...) ;
}

As in all 'C' functions, you can group several statements together between { and } so more than one instruction can execute per case match.
It is also common to see 'break' statements inside 'case' sections to skip the remaining checks and go straight to the end of the switch function.

Brian.
 

to excel at the highest level, you have to excel at the basics first.

in your case, if you cannot express yourself clearly, I would suggest that you stop whatever you are doing and take some basic classes in composition and comprehension.
 

PLEASE POST YOUR CODE or POST YOUR DOUBTS CLEARLY buddy!!!!!!!!!!!!!!!!!!
Regards,
Jerin. :)
 

#include <16F877A.h>
#fuses XT,NOWDT,PUT,NOBROWNOUT,NOLVP
#use delay(clock = 4000000)
#byte PORTA=0X05
#byte PORTC=0x07
#byte PORTB=0X06
#define A0 PIN_A0
#define A1 PIN_A1
#define A2 PIN_A2
#define A3 PIN_A3
#define A4 PIN_A4


int sec1,sec2,min1,min2,hour1,hour2;
int num1=5,num2=5,num3=5;

int counter=125;
int flag=0;


const int table[10]={0b00111111,
0b00000110,
0b01011011,
0b01001111,
0b01100110,
0b01101101,
0b01111101,
0b00000111,
0b01111111,
0b01101111};

void main()
{
PORTB=0X00;
PORTC=0X00;


set_tris_a(0xff);
set_tris_c(0x00);
set_tris_b(0x00);
set_RTCC(6);
setup_counters(RTCC_INTERNAL,RTCC_DIV_32);
enable_interrupts (INT_RTCC);
enable_interrupts (GLOBAL);

for(;;)
{
PORTB=table[sec1];
PORTC=0X01;
delay_ms(15);

PORTB=table[sec2];
PORTC=0x02;
delay_ms(15);

PORTB=table[min1];
PORTC=0x04;
delay_ms(15);

PORTB=table[min2];
PORTC=0x08;
delay_ms(15);

PORTB=table[hour1];
PORTC=0x10;
delay_ms(15);

PORTB=table[hour2];
PORTC=0x20;
delay_ms(15);



if(flag==1){


flag=0;
}





if(input(A4)==1)
{
disable_interrupts(INT_RTCC);

if(input(A2)==1) { --num1; }
if(num1==0){
if(++min1>9) {
min1=0;
if(++min2>5) { min2=0; }
}
num1=5;
}
if(input(A3)==1){ --num2; }

if(num2==0) {
if( ++hour1>9 )
{
hour1=0;
++hour2;
}
if( (hour2==1) & (hour1==3) ) {
hour1=1;
hour2=0;
}
num2=5;
}
if(input(A1)==1) { --num3; }
if(num3==0){
if(++sec1>9) {
sec1=0;
if(++sec2>5) { sec2=0; }
}
num3=5;
}
}


else if(input(A4)==0){
enable_interrupts(INT_RTCC);
}
}

}

#int_RTCC
void microII()

{ //void switch_time();
if(--counter>0)return;
counter=125;
flag=1;


if(++sec1>9){
sec1=0;

if(++sec2>5){
sec2=0;

if(++min1>9){
min1=0;

if(++min2>5){
min2=0;
if( ++hour1>9 )
{
hour1=0;
++hour2;
}
if( (hour2==1) & (hour1==3) ) {
sec1=0;
sec2=0;
min1=0;
min2=0;
hour1=1;
hour2=0;
}


}
}
}
}


}

---------- Post added at 10:02 ---------- Previous post was at 10:00 ----------

this is the program of clock and i don't know how to start and insert the program of stopwatch,..can you please help me for some part of the programs...please please...
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top