|
|
View previous topic :: View next topic |
Author |
Message |
gpsmikey
Joined: 16 Nov 2010 Posts: 588 Location: Kirkland, WA
|
|
Posted: Sun Oct 02, 2011 9:52 pm |
|
|
bkamen wrote: | get yourself the book "The C Programming Language" by Kergnihan & Ritchie.
It's the definitive reference on 'C'.
-Ben |
While that is indeed the "C Bible", I have found that K&R can also cure insomnia :-)
I would definitely get a copy of the K&R book, but I think I would also check out some of the many intro "C" books available as they are a bit easier to read (then go to K&R for questions). Check out amazon.com's books and see what others like and why. You should be able to find one that makes sense to you (everybody has a different way of learning).
mikey _________________ mikey
-- you can't have too many gadgets or too much disk space !
old engineering saying: 1+1 = 3 for sufficiently large values of 1 or small values of 3 |
|
|
bkamen
Joined: 07 Jan 2004 Posts: 1615 Location: Central Illinois, USA
|
|
Posted: Sun Oct 02, 2011 10:14 pm |
|
|
gpsmikey wrote: | bkamen wrote: | get yourself the book "The C Programming Language" by Kergnihan & Ritchie.
It's the definitive reference on 'C'.
-Ben |
While that is indeed the "C Bible", I have found that K&R can also cure insomnia :-)
|
Thus my use of "reference" and not "tutorial" -- hahaha.. cause you are right.
It's the book you look stuff up in - but there's tutorials out there that are much better at teaching. _________________ Dazed and confused? I don't think so. Just "plain lost" will do. :D |
|
|
chin0609
Joined: 13 Sep 2011 Posts: 18
|
|
Posted: Mon Oct 03, 2011 7:34 am |
|
|
i found an code that may be suit be my hardware anyone can tell how to connect the pin based on my hardware provided
transmiter: http://www.cytron.com.my/viewProduct.php?pcode=RF-TX-315&name=RF%20Transmitter%20315MHz
Receiver: http://www.cytron.com.my/viewProduct.php?pcode=RF-RX-315&name=RF%20Receiver%20315MHz
Trasmitter Code:
Code: | #include <16F877A.h>
#fuses XT, NOWDT, NOPROTECT,NOLVP,NOBROWNOUT, PUT
#use delay (clock = 4000000)
#use rs232(baud=1200, xmit=PIN_D3, rcv=PIN_D4, ERRORS, STREAM=COM_A)
void main()
{
for(;;){
if(input(PIN_C4)==0) //if button pressed
{
output_high(PIN_D2); //enable Vcc of transmitter module
output_high(PIN_D1); //output high Led
delay_ms(20);
fputc('T', COM_A);
delay_ms(20);
delay_ms(1000); //delay some ms
output_low(PIN_D1); // output low led
output_low(PIN_D2); //disable Vcc of transmitter module TSW434
}
output_high(PIN_D1); // if button not pressed then just on off led on pin D1
delay_ms(50);
output_low(PIN_D1);
delay_ms(50);
}
}
|
Receiver Code:
Code: | #include <16F877A.h>
#fuses XT, NOWDT, NOPROTECT,NOLVP,BROWNOUT, PUT
#use delay (clock = 4000000)
#use rs232(baud=1200,parity=N, xmit=PIN_D3, rcv=PIN_D2, ERRORS, STREAM=COM_A)
char data;
#int_RDA
void RDA_isr(void)
{
data= fgetc(COM_A);
}
void main()
{
enable_interrupts(global);
enable_interrupts(int_rda);
for(;;){
if(data=='T')
{
output_high(PIN_D1);
delay_ms(1000);
output_low(PIN_D1);
data=0;
}
output_high(PIN_D1);
delay_ms(50);
output_low(PIN_D1);
delay_ms(50);
}
} |
|
|
|
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
|
Posted: Mon Oct 03, 2011 8:07 am |
|
|
i don't see how your code can work with any stability -
since you are turning the transmitter on and off for no reason i can see -
remember - the cheepie receiver module has no squelch (!!)
- this alone will likely generate trash transitions in your RECEIVER -
that will mess up the signal stream -
and then this:
i have to question WHY you are using the inferior software RS-232
method when the PIC you selected has perfectly good, reliable HARDWARE RS-232 - on pins C6,C7
NOW a bigger issue -
#int_RDA
is ONLY triggered when the HARDWARE EUSART is triggered
by a new character fully received in the buffer --
but YOU are using a SOFTWARE receiver - so your receive handler will never be called or get any characters anyway
forget your problems with CODE for a moment -
( where there is already trouble enough )
BUT - the code you posted implies to me anyway -
big conceptual trouble in all the circuitry associated with the PIC.
fixing the code won't address the unknowns of your hardware design |
|
|
|
|
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
|