PDA

View Full Version : 18F4550 + Usb + VB6 + Reg Shifting



MeSaKu
- 13th June 2009, 10:43
i have some problems about 18f4550 usb +vb6 and register shifting ;

*** Problem 1

how can i use usb interrupt ?

idont know how to do it so i write a code ;



if portc.7=1 then
usbinit
gosub dousbin
endif

DoUSBIn:
USBBufferCount = USBBufferSizeRX ' RX buffer size
USBService ' keep connection alive
USBIn 1, USBBuffer, USBBufferCount, DoUSBIn ' read data, if available
return


but if portc.7=1,program goes to dousbin title but never back,program always stays dousbin title

How can i solve this ?


*** Problem 2


i have a 320 registers in charreg ;

charreg var byte[320]


i want to shift left only 1 charreg[0] and charreg[0].bit0 = charreg[7].bit7

in a code ;


for x=0 to 319
temp=charreg[x] : temp=temp<<1
if x>311 then
call casex
else
buff=charreg[x+8]
endif
temp.0=buff.7
charreg[x]=temp

casex :

select case x
case 312
buff=charreg[0] : return
case 313
buff=charreg[1] : return
case 314
buff=charreg[2] : return
case 315
buff=charreg[3] : return
case 316
buff=charreg[4] : return
case 317
buff=charreg[5] : return
case 318
buff=charreg[6] : return
case 319
buff=charreg[7] : return
end select


i look my codes again cant see any error but in a program it doesnt work what i want to do..

I want to shift register value's (8 step each register),how can i do ?


*** Problem3

i have a program on vb6, i cant send datas to pic. I want to send chars like A,B,C... but it doesnt :(

I research vb6,i see this code in hiddllinterface modeule;

Declare Function hidReadEx Lib "mcHID.dll" Alias "ReadEx" (ByVal pVendorID As Long, ByVal pProductID As Long, ByRef pData As Byte) As Boolean


data type defined boolean but i want to send string,i change this boolean declaration but doesnt solve :(

How can i send strings with usb ?


All of my codes,i can compile with mcsp but ihave that problems.

if u have any non-understanding point i will give all of my codes and vb6 program.

SOrry for my bad eng :(