Mikroelektronika MIKROE-724 データシート

ページ / 726
mikroBasic PRO for dsPIC30/33 and PIC24
MikroElektronika
635
Library Example
This example establishes connection with the HID terminal that is active on the PC. Upon connection establishment, the HID 
Device Name will appear in the respective window. After that software will wait for data and it will return received data back. 
Examples uses 
USBdsc.mbas
 descriptor file, which is in the same folder, and can be created by the HID Terminal.
Copy Code To Clipboard 
program HID_Write
dim cnt as char
dim readbuff as char[64]
dim writebuff as char[64]
sub procedure USB1Interrupt() iv IVT_ADDR_USB1INTERRUPT
   USB_Interrupt_Proc()
end sub
main:
  AD1PCFGL = 0xFFFF
  USB_Init_desc()
  HID_Enable(@readbuff,@writebuff)
  while TRUE
    while(HID_Read() = 0)
    wend
    
    for cnt=0 to 63
      writebuff[cnt] = readbuff[cnt]
    next cnt
    
    while(HID_Write(@writebuff,64) = 0)
    wend
  wend
end.
HW Connection
USB connection scheme