|
|
View previous topic :: View next topic |
Author |
Message |
Garath Guest
|
Same program but different results why !?!??!!? |
Posted: Fri Feb 22, 2002 9:46 am |
|
|
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 !?!??!!? |
Posted: Fri Feb 22, 2002 9:57 am |
|
|
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 |
|
|
|
|
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
|