Hi Steve,
I'm revisting USB again and using parts of the demo as a bit of a refresher 
Im writing a program where I want to send half a dozen NMEA strings (of varrying string length) which are stored in their own array, to the pc running hyperterminal.
I can send them successfully via USB using 6 separate DoUSBOut subroutines (without the SendUSB macro array code) but I want to trim my code down and use one (1) DoUSBOut routine to do the lot.
->>> I kinda have it working but the received data into hyperterminal appear as though some strings aren't received or are being over written or something.
I've modified the SendUSB macro array so that the USBBufferOut should just keep filling up according to my USBBufferCount (array size) and suspect this is the problem but I'm rusty on ASM. Perhaps the USBBufferOut needs to be "erased" after each visit to DoUSBOut? How would I do that?
I'm going blind looking at this code and wonder if you could see any traps I may have fallen into...
Code:
USBBufferCount Var Byte '
USBBufferOut Var Byte[50] ' store outgoing USB data ...... this value originally [8]
GPZDA VAR BYTE[28]
GPGLL VAR BYTE[41]
GPGGA VAR BYTE[49]
GPVTG VAR BYTE[27]
'...... arrays get filled up here.........
'...... other code........
asm
SendUSB macro array
; Use to Copy an specific array to USBBufferOut AND send it
; to USB bus
variable i=0
;while i<8 ' ...............original line here........
while i<_USBBufferCount
MOVE?BB (array+i),(_USBBufferOut+i)
i+=1
endw
L?CALL _DoUSBOut
endm
endasm
USBBufferCount = 28
@ SendUSB _GPZDA
USBBufferCount = 41
@ SendUSB _GPGLL
USBBufferCount = 49
@ SendUSB _GPGGA
USBBufferCount = 27
@ SendUSB _GPVTG
DoUSBOut:
'
' Send data to the USB bus & Wait for USB interface to attach
' ===========================================================
T1CON.0 = 0 ' TURN OFF TIMER
WaitPC: '
USBService ' keep connection alive
USBOut 3, USBBufferOut, USBBufferCount, Waitpc ' if bus available, transmit data
T1CON.0 = 1 ' Re-Enable TMR0 interrupt
return
Bookmarks