|
|
View previous topic :: View next topic |
Author |
Message |
Paradoxz
Joined: 08 Sep 2011 Posts: 1
|
RF Transmitter and Receiver |
Posted: Thu Sep 08, 2011 8:07 pm |
|
|
Hi everyone, this is my first post here and I am looking for a little help. I have a PIC16F690 that is transmitting properly over RS232. I can use my Arduino connected to my RF receiver to verify this. I can not for the life of me get another one of my PIC16F690's to work as a receiver though.
WRL-10535 Transmitter http://www.sparkfun.com/products/10535
WRL-10533 Receiver http://www.sparkfun.com/products/10533
PIC16F690 Datasheet: http://ww1.microchip.com/downloads/e...Doc/41262c.pdf
Arduino Uno
Here is the working code: (16F690 Counting from 0-20 repeatedly)
Code: |
// The 16F690 in CCSC as Transmitter (Working)
#include <16F690.H>
#include <stdlib.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#fuses INTRC_IO, NOWDT, NOPROTECT, NOBROWNOUT, PUT
#use delay(clock=4000000)
#use rs232(baud=4800, xmit=PIN_C2, rcv=PIN_A0)
int value;
int count;
main() {
output_high(PIN_A2);
value = "0";
while(1) {
count = 0;
while(count < 20) {
if(value > 20) {
value = 0;
}
printf("%c", value);
count++;
}
value++;
}
} |
Any here is the working code on the Arduino, as a receiver.
// Arduino Uno as Receiver (Working)
Code: | int incomingByte = 0;
void setup(){
Serial.begin(4800);
}
void loop(){
incomingByte = Serial.read();
Serial.println(incomingByte, DEC);
} |
Here is my attempt to use the PIC16F690 as a receiver. Any suggestions on why it isn't working? I get a reading, but it's just a mess of numbers.
Code: |
// Trying to use CCSC W/ 16F690 as Receiver (Not Working)
#include <16F690.H>
#include <stdlib.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#fuses INTRC_IO, NOWDT, NOPROTECT, NOBROWNOUT, PUT
#use delay(clock=4000000)
#use rs232(baud=4800, xmit=PIN_A0, rcv=PIN_B5)
int value;
main() {
while(1) {
value = getc();
printf("%d", value);
printf("\n");
}
} |
It might help to add I have tried getc, getch, getchar and have tried assigning a stream to RS232. This should not matter though since it is two different PIC's (one as tx and one as rx). There is only one RS232 in use on each. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Sep 08, 2011 9:52 pm |
|
|
Quote: |
#use rs232(baud=4800, xmit=PIN_A0, rcv=PIN_B5)
while(1) {
value = getc();
printf("%d", value);
printf("\n");
}
|
You're using a software UART. The hardware pins are B7 and B5
(Tx and Rx). Both pins must be specied as the hardware pins in order
for the compiler to generate code for a hardware UART.
When your code is printing the value and the newline, it can't be polling
the software UART's Rx pin. But polling the pin is required for a
software UART to work properly.
Just as a test, you could add a 10ms delay between characters on
transmitter side.
Or, you could change to a hardware UART, and also add a interrupt-
driven receive fifo (circular buffer) to your program. See the CCS
example file, Ex_sisr.c. |
|
|
|
|
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
|