Am having significant problems trying to transmit some data.
I'm using some wireless transceivers as found here: http://www.littlebirdelectronics.com...nsfer-x-2.html
they are supposed to be 'transparent' to and should just replace a cable. They are set up by default to be 9600bps.
I've hooked them up to a couple of micros and run a scope on them. I cant really figure out whats going on.
The number I'm sending out is 100 so = 1100100
The input to the transmitter & receiver output timings listed below
(first column transmitter input - second column receiver output)
L 1.25ms L 0.93ms
H 0.42ms H 0.1ms
L 0.83ms L 0.82ms
H 0.83ms H 0.2ms
L 0.42ms L 0.42ms
I figure either the output baud of my PIC isnt 9600 so the transmission is getting skewed or maybe it's inverted? The line on both starts and finished high.
Have done comms just a couple of times before but never fully grasped the concepts.
transmitter code:
and receiver code:Code:'pic16f722 DEFINE OSC 4 DEFINE HSER_BAUD 9600 'Set Baud rate to 9600bps DEFINE HSER_BITS 9 'Set to 9 bit mode DEFINE HSER_EVEN 1 'Set Even Parity DEFINE HSER_CLROERR 1 'Clear overflow error automatically DEFINE HSER_TXSTA 20h 'Set receive register to TX en define HSER_SPBRG 25 DEFINE HSER_SPBRGH 1 INTCON = 0 'Disable interrupts TRISB = %00000100 'SET PORTB RB2(RX) as input, others to OUTPUT TRISA = %00000000 'SET PORTA AS OUTPUTS ADCON0 = %0110010 'disable ADCON1 = %1000000 TRISA= %00000000 'Set all to outputs ANSELA= %00000000 'Set all to digital TRISB= %00000111 'set buttons as input ANSELB= %00000000 'all digital TRISC= %00000000 'Set PortC all outputs SSPCON= 0 'disable spi CPSCON0 = %00001101 'Cap sense off porta = 63 PAUSE 1000 LeftBtn Var PORTB.1 RiteBtn Var PORTB.0 StopBtn VAR PORTB.2 RadioEn var PortC.5 B0 VAR BYTE TXdata var byte pause 1000 clear B0 = 1 startloop: pause 500 b0 = b0*2 porta = b0 if b0 > 60 then start goto startloop radioen = 1 Start: txdata = 100 pause 100 hserout [txdata] goto start
I would really appreciate some help from you wonderful people, I've just started back into PBP and every aspect of my first project back is turning to custard. Many Thanks in advanceCode:@ __config _CONFIG1, _XT_OSC & _WDT_ON & _LVP_OFF & _CP_OFF & _MCLR_OFF 'pic16f88 ADCON0 = %00000000 'ADC Disabled CMCON = 7 ANSEL = 0 DEFINE OSC 4 DEFINE HSER_BAUD 9600 'Set Baud rate to 9600bps DEFINE HSER_BITS 9 'Set to 9 bit mode DEFINE HSER_EVEN 1 'Set Even Parity DEFINE HSER_CLROERR 1 'Clear overflow error automatically DEFINE HSER_RCSTA 90h 'Set receive register to receiver en define HSER_SPBRG 25 DEFINE HSER_SPBRGH 1 ANSEL = 0 'ALL DIGITAL CMCON = 7 'COMPARATORS OFF INTCON = 0 'Disable interrupts TRISB = %00000100 'SET PORTB RB2(RX) as input, others to OUTPUT TRISA = %00000000 'SET PORTA AS OUTPUTS 'Variables MtrPwr Var PortA.1 ServoEn VAR PortB.3 '0 = enabled RadioEn VAR PortB.4 '1 = enabled RXdata var byte 'received data frm tx b0 var byte PortA = 0 PortB = 0 ServoEn = 1 radioen = 1 BCMDATA VAR BYTE[12] 'Define BCMAADATA as a byte array (12 Bytes) Count1 VAR BYTE 'Define Count1 as a byte variable (Used in For/Next Loops) CheckSum VAR BYTE 'Define CheckSum as a byte variable pause 1000 for b0 = 0 to 20 toggle mtrpwr pause 100 next b0 mtrpwr = 0 clear Commloop: 'Start of Communications Loop HSERIN [Rxdata] 'receive data if rxdata = 100 then mtrpwr = 1 pause 10000 else mtrpwr = 0 endif pause 500 goto commloop





Bookmarks