Thanks I've made some changes to my code and it is working sort of.
Now what I want to do is use a qualifier so that the Hserin waits until $AA is received before it starts filling the array. I also want the $AA in the array though? Possible?Code:'------------------------------------- ' PBP Fake BCM CODE 21/10/09 V.04 '------------------------------------- @ DEVICE PIC16F88,INTRC_OSC_NOCLKOUT @ DEVICE PIC16F88,PROTECT_OFF @ DEVICE PIC16F88,WDT_OFF @ DEVICE PIC16F88,PWRT_ON @ DEVICE PIC16F88,MCLR_OFF @ DEVICE PIC16F88,BOD_OFF @ DEVICE PIC16F88,LVP_OFF @ DEVICE PIC16F88,CPD_OFF @ DEVICE PIC16F88,DEBUG_OFF @ DEVICE PIC16F88,CCPMX_OFF DEFINE OSC 8 'Set oscilator speed to 8mHz 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 OSCCON=%01111000 '8 Mhz ANSEL = 0 'ALL DIGITAL CMCON = 7 'COMPARATORS OFF INTCON = 0 'Disable interrupts TRISB = %00000100 'SET PORTB RB2(RX) as input, others to OUTPUT TRISA = %11111111 'SET PORTA AS INPUTS DATAIN VAR BYTE[12] 'Define DATAIN as a byte array (12 Bytes) loop: 'Start of Communications Loop HSERIN [str DATAIN\12] 'Receive 12 bytes into array DATAIN HSEROUT [str DATAIN\12] 'Transmit 12 bytes from array DATAIN goto looP 'Goto Loop END
So it should receive twelve bytes in all like this.
0xAA,0x10,0x00,0x00,0x00,0x20,0x40,0x61,0x10,0x01, 0x00,0x74
Does this look right?
I read that a delay may be required after the last send in the HSEROUT section or it may not transmit the last byte correctly?Code:loop: 'Start of Communications Loop HSERIN [WAIT($AA), str DATAIN\12] 'Receive 12 bytes into array DATAIN HSEROUT [str DATAIN\12] 'Transmit 12 bytes from array DATAIN goto looP 'Goto Loop




Bookmarks