After reading your posts and having a look at the camera datasheet, I would look at a couple of things.
First, if you are still trying to communicate to the camera at 14400 and your PIC OSC frequency is 8MHz, then I would set the following parameters.
For the second EUSART port, set the following register bits manually:
SYNC = 0
BRGH = 1
BRG16 = 1
SPBRGH = 0
SPBRG = 137
This will setup 14400 with a resultant 0.64% error rate. This is as good as you can get at 8MHz.
Secondly, looking at the camera datasheet, the communication between the PIC and camera is NOT sending "ascii" Hex characters, it is binary data.
So that being said, you should not use Input/Output modifiers (I.e. HEX/BIN/DEC) with the HSERIN2/HSEROUT2 commands to/from the camera.
I would try the following for testing purposes.
This assumes that the PC is connected to the 1st HSER port of the PIC for debug purposes and the PC is running a terminal emulator program.
Code:
com var byte[12]
i var byte
GETPIC:
PAUSE 3000
COM=0
GOSUB SYNC
GOTO GETPIC
; UART2 IS CONNECTED TO THE CAMERA (www.4dsystems.com.au/downloads/micro-CAM/Docs/uCAM-DS-rev7.pdf)
; UART1 IS CONNECTED TO MY PC
SYNC:
HSEROUT2 [$AA,$0D,$00,$00,$00,$00] 'TX SYNC
for i = 0 to 11
HSERIN2 1000,SYNC,[COM(i)] 'Rx ACK & SYNC pattern (2 x 6 bytes)
next i
HSEROUT2 [$AA,$0E,$0D,$00,$00,$00] 'TX ACK
for i = 0 to 11 'Tx 12 bytes to PC for display
HSEROUT [hex2 COM(i)] 'hex2 sends the data as "ascii" codes representing HEX digits
HSEROUT [13,10]
next i
GOTO GETPIC
RETURN
This should:
1. Send the 6byte SYNC pattern to the camera.
2. Receive the 6byte ACK pattern response from the camera.
3. Receive the 6byte SYNC pattern response from the camera.
4. Send the 6byte ACK pattern to the camera.
5. Transmit out "ascii" character representations of the binary data stored in the COM byte array to the PC to be displayed in a terminal emulation program.
Bookmarks