[SOLVED] using if command in hitec c

Status
Not open for further replies.

prasad70

Member level 3
Joined
Mar 24, 2011
Messages
67
Helped
3
Reputation
6
Reaction score
3
Trophy points
1,288
Activity points
1,690
Can some one please explain what is the wrong with below expressions.

if (( X1>9)&&(Y1>12)) RB0 =1
else
RB0 =0 ;
 

yes you have to make it like this

if (( X1>9)&&(Y1>12)) RB0 =1;
else
RB0 =0 ;

try it now it will work


ISMAIL
 

sorry . It was my typing mistake.
It doesnt work .

thk
 

no it doesnt work. Compiler doesn't give any error but i dont get any output.

- - - Updated - - -

below is my code.

Code:
unsigned char D1=0,D2=0,D3=0 ;
unsigned int RSL1=0 ,S2=0, RSL2 =9 ;

void main(void)  
{
	
TRISB = 0x00 ;

for(;;) 
	{

	
	RSL1++ ;
	if (( RSL1 >5)&&(RSL2<9))    RB0=1;
	else 
	RB0 =0 ;

	if (RSL1 >=9)  RSL1 =0 ;
	}
}
 
Last edited by a moderator:

You r making code for what elaborate completely...
Are you using any uC here or what???
 

I am using HI-TECH C® for PIC10/12/16.
 

I don't have any idea about PIC 10/12...
but the program is working fine..may be you are doing some sapling mistake in (TRISB or RB0) ...

Code:
unsigned char D1=0,D2=0,D3=0 ;
unsigned int RSL1=0 ,S2=0, RSL2 =9 ;
void main(void) 
{

TRISB = 0x00 ;

for(;;) 
{
	RSL1++ ;
	if (( RSL1 >5)&&(RSL2<9))
	{
		RB0=1;
	}
	else 
	{
		RB0 =0 ;
	}
		if (RSL1 >=9) 
		{
			RSL1 =0 ;
		}
}
}

Ismail
 
thks. I will check again.
 

The code in post #5 and post #8 will keep RB0=0 constantly (because RSL2 = 9). Is this what you intend?
 

No. I intend to keep RB0 high only when predefined RSL2 < 9 and internal variable RSL1 >5 . During other ranges, RB0 should be low.
thks

- - - Updated - - -

I changed the code like below but still I dont see RB0 changes when program run.

Code:
unsigned int RSL1=0 , RSL2 =9 ;




void main(void)  
{
	
TRISB = 0x00 ;

for(;;) 
	{

	
	RSL1++ ;
	if  (( RSL2 <5)&&(RSL1<8))
		{
		  RB0=1;
		}
	else 
		{
			RB0 =0 ;
		}

	if (RSL1 >=9) 
		{
			 RSL1 =0 ;
		}
	}
}
 

How do you check RB0 state? It's supposed to change pretty fast.
 

I am using MPLAB SIM .

- - - Updated - - -

once i chnaged if (( RSL2 <5)&&(RSL1<8)) to if ( RSL2 <5 && RSL1<8) probelm dissapered. Now it's solved.
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…