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 support@ccsinfo.com

Same program but different results why !?!??!!?

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







Same program but different results why !?!??!!?
PostPosted: Fri Feb 22, 2002 9:46 am     Reply with quote

Hie, i wrote 2 programs which have exactly the same code but when compiled, the 1st program works fine but the 2nd program doesn't work. Could someone please tell me why.
When a low is applied to RB0 the program is supposed to transmit 'c' to the computer.

//This is the code that works//
#include<c:\16f84.h>
#use delay(clock=4000000)
#use fast_io(A)
#use fast_io(B)
#byte _portA = 5
#byte _portB = 6
#use rs232 (baud=9600,xmit=pin_a1,rcv=Pin_a2, parity=N, bits=8, restart_wdt)

int main(void);
void reset(void); //ch//

int main()
{
//int i;
reset();
return;
}
//set_tris_b(0xff);
//set_tris_a(0x00);

void reset()
{
int i;
reloop: set_tris_a(0x00); //set all portB as output//
_portB = 0x01;
delay_us(10); //change//
bit_clear(_portB,0); //low reset pulse for minimum of 480us//
delay_us(500);
bit_set(_portb,0); //VPullup//
delay_us(100);

//receive mode//
i = bit_test(_portB,0);
if (!i)
{
delay_us(500);

printf(" C ");
delay_us(400);
}
else
delay_us(500);
goto reloop;


return;
}


//This doesn't work//

#include<c:\16f84.h>
#use delay(clock=4000000)
#use fast_io(A)
#use fast_io(B)
#byte _portA = 5
#byte _portB = 6
#use rs232 (baud=9600,xmit=pin_a1, rcv=Pin_a2, parity=N, bits=8, restart_wdt)

int main(void);
void reset(void);

int main()
{

reset();


return;
}

void reset()
{ //reset pulse//

int i;

reloop: set_tris_B(0x00); //set all portB as output//
_portB = 0x01;
delay_us(10);
bit_clear(_portB,0); //low reset pulse for minimum of 480us//
delay_us(500);
bit_set(_portb,0); //VPullup//
delay_us(100);

//receive mode//
i = bit_test(_portB,0);
if (!i)
{
printf(" c ");
delay_us(400);
}
else
delay_us(500);
goto reloop;


return;
}

Thanks
___________________________
This message was ported from CCS's old forum
Original Post ID: 2761
Todd C. Micallef
Guest







Re: Same program but different results why !?!??!!?
PostPosted: Fri Feb 22, 2002 9:57 am     Reply with quote

Hi, I hate to state the obvious but your first program has a set_tris_A

and the second has a set_tris_B

:=Hie, i wrote 2 programs which have exactly the same code but when compiled, the 1st program works fine but the 2nd program doesn't work. Could someone please tell me why.
:=When a low is applied to RB0 the program is supposed to transmit 'c' to the computer.
:=
:=//This is the code that works//
:=#include<c:\16f84.h>
:=#use delay(clock=4000000)
:=#use fast_io(A)
:=#use fast_io(B)
:=#byte _portA = 5
:=#byte _portB = 6
:=#use rs232 (baud=9600,xmit=pin_a1,rcv=Pin_a2, parity=N, bits=8, restart_wdt)
:=
:=int main(void);
:=void reset(void); //ch//
:=
:=int main()
:={
:=//int i;
:=reset();
:=return;
:=}
:=//set_tris_b(0xff);
:=//set_tris_a(0x00);
:=
:=void reset()
:={
:=int i;
:=reloop: set_tris_a(0x00); //set all portB as output//
:= _portB = 0x01;
:= delay_us(10); //change//
:= bit_clear(_portB,0); //low reset pulse for minimum of 480us//
:= delay_us(500);
:= bit_set(_portb,0); //VPullup//
:= delay_us(100);
:=
:= //receive mode//
:= i = bit_test(_portB,0);
:= if (!i)
:= {
:= delay_us(500);
:=
:= printf(" C ");
:= delay_us(400);
:= }
:= else
:= delay_us(500);
:= goto reloop;
:=
:=
:= return;
:=}
:=
:=
:=//This doesn't work//
:=
:=#include<c:\16f84.h>
:=#use delay(clock=4000000)
:=#use fast_io(A)
:=#use fast_io(B)
:=#byte _portA = 5
:=#byte _portB = 6
:=#use rs232 (baud=9600,xmit=pin_a1, rcv=Pin_a2, parity=N, bits=8, restart_wdt)
:=
:=int main(void);
:=void reset(void);
:=
:=int main()
:={
:=
:=reset();
:=
:=
:=return;
:=}
:=
:=void reset()
:={ //reset pulse//
:=
:=int i;
:=
:=reloop: set_tris_B(0x00); //set all portB as output//
:= _portB = 0x01;
:= delay_us(10);
:= bit_clear(_portB,0); //low reset pulse for minimum of 480us//
:= delay_us(500);
:= bit_set(_portb,0); //VPullup//
:= delay_us(100);
:=
:= //receive mode//
:= i = bit_test(_portB,0);
:= if (!i)
:= {
:= printf(" c ");
:= delay_us(400);
:= }
:= else
:= delay_us(500);
:= goto reloop;
:=
:=
:= return;
:=}
:=
:=Thanks
___________________________
This message was ported from CCS's old forum
Original Post ID: 2762
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