i try to use the legacy USB HID device on a PIC32MX450F128H.
i try the "HID_Read_Write" example (interrupt mode)
i just modify the OSC settings to be compliant with my board :
16MHz external oscillator ==>
- PLL input divider = 4
PLL multiplier = 24 (define a 96MHz MCU clock)
USB PLL input divider = 4
USB PLL Enable
but anyway, can't to have an right enumeration of a HID device : Windows 7 X64 complain about the device !
this is the first time i use this lib on PIC32, but i use it many many time on PIC18F.
it seem that the DMA3 channel is used in this lib version (IPC11 : DMA3 interrupt priority bits are set)
but when i check the DMACON registers, the DMA module is OFF !
here it is the code ( pretty same as the original ME example )
Code: Select all
'
' * Project name:
' HID_Read_Write (USB HID Read & Write Test)
' * Copyright:
' (c) Mikroelektronika, 2012.
' * Revision History:
' 20120810:
' - initial release (FJ);
' * Description:
' 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. The character that user sends to PIC from the HID
' terminal will be re-sent back to user.
' * Test configuration:
' MCU: P32MX795F512L
' http://ww1.microchip.com/downloads/en/DeviceDoc/61156F.pdf
' Dev.Board: EasyPIC Fusion v7 - ac:USB
' http://www.mikroe.com/easypic-fusion/
' Oscillator: XT-PLL, 80.000MHz
' Ext. Modules: None.
' SW: mikroBasic PRO for PIC32
' http://www.mikroe.com/mikrobasic/pic32/
' * NOTES:
' - None.
' *
program HID_Read_Write
dim cnt as byte
dim readbuff as byte[64]
dim writebuff as byte[64]
sub procedure USB1Interrupt() iv IVT_USB_1 ilevel 7 ics ICS_SRS
USB_Interrupt_Proc()
end sub
sub procedure DebugString_UART(dim byref str as string)
UART3_Write_Text(str)
UART3_Write(0x0D)
end sub
sub procedure DebugStringLWord_UART(dim byref str as string, dim value as longword)
dim txt_buffer as string[8]
UART3_Write_Text(str)
LongWordToHex(value, txt_buffer) ' convertir le longword en HEX ASCII
UART3_Write_Text(txt_buffer)
UART3_Write(0x0D)
end sub
main:
JTAGEN_bit = 0
'AD1PCFG = 0xFFFF
ANSELB = 0 ' IMPORTANT !! ALL IO's as DIGITAL pins
ANSELC = 0 ' IMPORTANT !!
ANSELD = 0 ' IMPORTANT !!
ANSELE = 0 ' IMPORTANT !!
ANSELF = 0 ' IMPORTANT !!
ANSELG = 0 ' IMPORTANT !!
TRISF.B1 = 0 ' DBG_TX
TRISF.B0 = 1 ' DBG_RX
TRISF.B3 = 1 ' USBID
Unlock_IOLOCK()
PPS_Mapping_NoLock(_RPF1, _OUTPUT, _U3TX) ' Sets pin PORTF.B1 to be Output and maps UART3 Transmit to it
PPS_Mapping_NoLock(_RPF0, _INPUT, _U3RX) ' Sets pin PORTF.B0 to be Input and maps UART3 Receive to it
Lock_IOLOCK()
UART3_Init_Advanced(512000, 96000, _UART_HIGH_SPEED, _UART_8BIT_NOPARITY, _UART_ONE_STOPBIT) ' to DBG terminal
DebugString_UART("START : ")
DebugStringLWord_UART("OSCCON : ", OSCCON)
USBIE_bit = 0
IPC11SET = 7 << 10 ' Inerrupt priority 7
EnableInterrupts()
delay_ms(1000)
HID_Enable(@readbuff,@writebuff)
delay_ms(1000)
DebugStringLWord_UART("OSCCON : ", OSCCON)
DebugStringLWord_UART("DMACON : ", DMACON)
DebugStringLWord_UART("DMASTAT : ", DMASTAT)
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.
Code: Select all
OSCCON : 01673320<CR>
OSCCON : 01673360<CR>
DMACON : 00000000<CR>
DMASTAT : 00000000<CR>
thanks, regards
Phil