Hi guys,
I'm starting to play with Rx/Tx modules.
I've bought a couple of Cy2198TR-a modules ( http://www.sure-electronics.net/rf,audio/GP-GC010.pdf ) and connected them to a couple of 16F88 pics.
I was able to communicate from pic to module, choose the channel and when transmitting/receiving i can see the Busy led on on both of them.
The transmitter is sending a simple message ( a 4 digit value ) every second.
The problem is the receiver side.
Sometimes skips messages, sometimes shows the entire message ( 4 digit value ), sometimes shows just on or two digits of the message.
Here is the code for the RX and TX:
RX
and the RXCode:CCP1CON = %00000000 ' Disable CCP SSPCON.5 = 0 ' Disable SSP Module CMCON = %00000111 ' comparator off TRISA=%00010001 TRISB=%00000111 '***************************************************************************** 'DEFINEs '***************************************************************************** @ DEVICE PIC16F88, HS_OSC @ DEVICE PIC16F88, MCLR_OFF @ DEVICE PIC16F88, PROTECT_OFF DEFINE OSC 8 @ DEVICE PIC16F88, CPD_OFF @ DEVICE PIC16F88, LVP_OFF @ DEVICE PIC16F88, BOD_OFF @ DEVICE PIC16F88, PWRT_OFF @ DEVICE PIC16F88, WDT_OFF @ DEVICE PIC16F88, CCPMX_OFF '***************************************************************************** 'ADC DEFINE ADC_BITS 10 ' Set number of bits in result ( 8 or 10 bits ) DEFINE ADC_CLOCK 3 ' Set clock source (3=rc) DEFINE ADC_SAMPLEUS 50 ' Set sampling time in uS '***************************************************************************** ANSEL=%00000001 ADCON1=%10000000 'no Vref - Right Justify ADCON0=%11000001 '***************************************************************************** ' DEFINE LCD pins DEFINE LCD_DREG PORTB DEFINE LCD_DBIT 4 DEFINE LCD_RSREG PORTA DEFINE LCD_RSBIT 3 DEFINE LCD_EREG PORTA DEFINE LCD_EBIT 2 DEFINE LCD_BITS 4 DEFINE LCD_LINES 4 DEFINE LCD_COMMANDUS 2000 DEFINE LCD_DATAUS 50 '***************************************************************************** 'debug defines INCLUDE "modedefs.bas" DEFINE DEBUG_REG PORTB DEFINE DEBUG_BIT 3 DEFINE DEBUG_BAUD 19200 DEFINE DEBUG_MODE 1 DEFINE DEBUGIN_REG PORTB DEFINE DEBUGIN_BIT 2 DEFINE DEBUGIN_BAUD 19200 DEFINE DEBUGIN_MODE 1 '***************************************************************************** 'PINS adc var PORTA.0 'analog input in var PORTA.1 'n/a A2 var porta.2 'lcd A3 var porta.3 'lcd A4 var porta.4 'n/a pgm var porta.5 'n/a RsBit var porta.6 'xtal EBit var porta.7 'xtal BUT1 var portb.0 'button stat var portb.1 'reserved for buSY led2 var PORTB.2 ' in nc var PORTB.3 ' out lcd4 var portb.4 'Data pin for LCD lcd5 var portb.5 'Data pin for LCD lcd6 var portb.6 'Data pin for LCD lcd7 var portb.7 'Data pin for LCD '***************************************************************************** 'variables media var WORD 'average ME var WORD ' ps4 var WORD ' value var WORD 'value received ra var word MYDATA var word 'contants Row1 CON 128 'constant for LCD line1 Row2 CON 192 'constant for LCD line2 Row3 CON 148 'comstant for LCD line3 Row4 CON 212 'constant for LCD line4 cl con 254 'constant for LCD clear line clear '***************************************************************************** INCLUDE "lcdbarIN.bas" DEFINE LCD4X20 1 '*********************************************************** INIT: pause 400 lcdout $fe,1," TX demo " lcdout $fe,$c0," ... " pause 1500 debug $55 if but1=1 then goto chann endif man: high pgm me=0 for ra=0 to 15 adcin adc,value pause 50 me=me+value next ra me=me/16 media=me media=(media*/5000)>>2 lcdout cl,row1," adc ", dec value lcdout cl,row2," average ", dec media transmit: lcdout cl,row4,"transmiting - ",dec value ," "'change B1 for B2 debug $55,"ok", dec value dig 3, dec value dig 2, dec value dig 1, dec value dig 0 goto man chann: low pgm pause 50 while but1=1 debug $af, $00 wend goto man end
Any ideas for this to occur ?Code:CCP1CON = %00000000 ' Disable CCP SSPCON.5 = 0 ' Disable SSP Module ANSEL = %00000000 ' digital mode CMCON = %00000111 ' comparator off TRISA=%00111100 TRISB=%00000111 '***************************************************************************** 'DEFINEs '***************************************************************************** @ DEVICE PIC16F88, HS_OSC @ DEVICE PIC16F88, MCLR_OFF @ DEVICE PIC16F88, PROTECT_OFF DEFINE OSC 8 @ DEVICE PIC16F88, CPD_OFF @ DEVICE PIC16F88, LVP_OFF @ DEVICE PIC16F88, BOD_OFF @ DEVICE PIC16F88, PWRT_OFF @ DEVICE PIC16F88, WDT_OFF @ DEVICE PIC16F88, CCPMX_OFF '***************************************************************************** ' DEFINE LCD pins DEFINE LCD_DREG PORTB DEFINE LCD_DBIT 4 DEFINE LCD_RSREG PORTA DEFINE LCD_RSBIT 1 DEFINE LCD_EREG PORTA DEFINE LCD_EBIT 0 DEFINE LCD_BITS 4 DEFINE LCD_LINES 4 DEFINE LCD_COMMANDUS 2000 DEFINE LCD_DATAUS 50 '***************************************************************************** 'debug defines INCLUDE "modedefs.bas" DEFINE DEBUG_REG PORTB DEFINE DEBUG_BIT 3 DEFINE DEBUG_BAUD 19200 DEFINE DEBUG_MODE 1 DEFINE DEBUGIN_REG PORTB DEFINE DEBUGIN_BIT 2 DEFINE DEBUGIN_BAUD 19200 DEFINE DEBUGIN_MODE 1 '***************************************************************************** 'PINS a1 var PORTA.0 'lcd a2 var PORTA.1 'lcd led var porta.2 'n/a A3 var porta.3 'n/a A4 var porta.4 'n/a pgm var porta.5 'frequency RsBit var porta.6 'xtal EBit var porta.7 'xtal BUT1 var portb.0 'button1 stat var portb.1 'reserved for buSY led2 var PORTB.2 ' in nc var PORTB.3 ' out lcd4 var portb.4 'Data pin for LCD lcd5 var portb.5 'Data pin for LCD lcd6 var portb.6 'Data pin for LCD lcd7 var portb.7 'Data pin for LCD '***************************************************************************** 'variables media var WORD 'average ME var WORD ' ps4 var WORD ' value var WORD ' ra var word MYDATA var word 'contants Row1 CON 128 'constant for LCD line1 Row2 CON 192 'constant for LCD line2 Row3 CON 148 'comstant for LCD line3 Row4 CON 212 'constant for LCD line4 cl con 254 'constant for LCD clear line clear '***************************************************************************** INCLUDE "lcdbarIN.bas" DEFINE LCD4X20 1 '*********************************************************** INIT: pause 400 lcdout $fe,1," RX demo " lcdout $fe,$c0," ... " pause 1500 if but1=1 then goto chann endif man: high pgm me=0 lcdout cl,row1," adc ", dec value lcdout cl,row2," media ", dec media rec: debugin [wait ("ok"),dec4 MYDATA] lcdout cl,row4," " lcdout cl,row3," " lcdout cl,row4, "received - ",DEC MYDATA goto REC chann: low pgm pause 50 while but1=1 debug $af, $00 wend goto man end
I thank in advance


thanks




Bookmarks