![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
NewGuy2008 Guest
|
TX/RX module |
Posted: Tue Dec 09, 2008 5:14 am |
|
|
Hi !
Please be so kind and drop some suggestion on project that am working on.
I want to make wireless TX/RX transmitting between two same RX/TX transceivers. Working frequency is 433MHZ-a and each device should have keyboard. The output of the transceiver device will have few different ports ... like serial port etc.
Should i choose some commercial RT/TX transceiver or can i make all this with some PICMICRO ?
Thank you for your time ! |
|
![](templates/subSilver/images/spacer.gif) |
NewGuy2008 Guest
|
|
Posted: Tue Dec 09, 2008 7:09 am |
|
|
rfPIC12F675H should be an OK choice.
What's the maximum transmitting range ( can't find in data sheet ) and can I increase this to 2 KM ( of course if FCC allows ).
Regards! |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
![](templates/subSilver/images/spacer.gif) |
Guest
|
Serial Communication Problem |
Posted: Tue Dec 09, 2008 10:01 pm |
|
|
Hi all,
I also need to design a intermediate node which has the capability of receiving and transmitting data using serial communication. Here I'm going to use 16F877A micro controller. So I have written a program (with the help of some code samples posted on this forum). it has been posted below.
I needs to receive 16 byte long string at a time and transmit the same string back. Actually I need to receive the 16 byte long string and do some modification to the string and transmit it to the next station. If the receiving string can be sent back without any error, I can do some modification to the string and send it again.
I simulated the below code several times using PIC simulator IDE and also on cct. But both of them doesn't give the correct output. For an example let say I send the string "ThisIsTheTestSt$" as the input it doesn't give the same string as the output(gives some of the characters of the above string with some garbage values).
If I remove the line "memset(buffer,0,sizeof(buffer));" and send the same string, again it doesn't send the whole string back and it sends it with some additional garbage values. When I send another 16byte string, it doesn't capture second string also.
So I couldn't figure out the reason and spent more than a week on it.
Please be kind enough to help me to go through this barrier. If I have done some thing wrong on the code, please be kind enough to mention it here.
Thank you very much to you all and any help regarding my matters are highly appreciated...!
Code: |
#include <16F877A.h>
#device adc=8
#FUSES NOWDT //No Watch Dog Timer
#FUSES XT //Crystal osc <= 4mhz
#FUSES NOPUT //No Power Up Timer
#FUSES NOPROTECT //Code not protected from reading
#FUSES NODEBUG //No Debug mode for ICD
#FUSES NOBROWNOUT //No brownout reset
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOCPD //No EE protection
#FUSES WRT_50% //Lower half of Program Memory is Write Protected
#use delay(clock=4000000)
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)
#include <math.h>
#include <stdio.h>
#include <stddef.h>
#include <stdlib.h>
#include <stdlibm.h>
#include <string.h>
#define MAXBUF (16)
#define DELIM ('$')
#define isempty(buff,free,in,out,size) (free>=size)
#define isfull(buff,free,in,out,size) (free<2)
#define tobuff(buff,free,in,out,size,chr) {buff[in++]=chr; --free; in=(in & (size-1));}
#define STBUFF (16)
#byte TXREG=0x19
#byte PIR1 = 0x0c
#bit TXIF=PIR1.4
char buffer[MAXBUF+1];
int8 numPos=0;
int1 rcvd_uart = False;
int RSTcount,RSTin,RSTout;
unsigned int RSTbuff[STBUFF+1] = "";
unsigned int RSTfrom(){
static unsigned int temp;
temp=RSTout;
RSTout=(++RSTout) & (STBUFF-1);
temp=(RSTbuff[temp]);
RSTcount++;
return(temp);
}
void tchar(unsigned int chr) {
if((TXIF==0) && (isempty (RSTbuff,RSTcount,RSTin,RSTout,STBUFF))) {
while (TXIF==0) ;
TXREG=chr;
}
else {
while (isfull(RSTbuff,RSTcount,RSTin,RSTout,STBUFF)) {
if (TXIF){
TXREG=RSTfrom();
}
}
tobuff(RSTbuff,RSTcount,RSTin,RSTout,STBUFF,chr);
}
enable_interrupts(INT_TBE);
}
#int_RDA
void RDA_isr(void)
{
int16 temp;
temp=getc();
if (rcvd_uart==false){
buffer[numPos] = temp;
}
if (temp==DELIM){
rcvd_uart = true;
buffer[numPos+1]='\0';
}
else{
numPos++;
if (numPos==MAXBUF) numPos=MAXBUF-1;
}
}
#int_TBE
void TBE_isr(void){
if (!isempty(RSTbuff,RSTcount,RSTin,RSTout,STBUFF)) {
TXREG=RSTfrom();
}
else{
DISABLE_INTERRUPTS(INT_TBE);
}
}
void main()
{
int16 pwm_duty = 50;
int a;
setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_OFF);
setup_psp(PSP_DISABLED);
setup_spi(SPI_SS_DISABLED);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DIV_BY_1,24,1);
setup_ccp1(CCP_PWM);
set_pwm1_duty(pwm_duty);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
enable_interrupts(INT_RDA);
enable_interrupts(GLOBAL);
// TODO: USER CODE!!
while(true){
if(rcvd_uart){
rcvd_uart=false; //Re-enable reception ASAP
}
for(a=0;a<8;a++){
tchar(buffer[a]);
}
memset(buffer,0,sizeof(buffer)); //assign nul values to the array.
}
}
|
Thanks in advance,
Harshana |
|
![](templates/subSilver/images/spacer.gif) |
|
|
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
|