Monday, November 24, 2014

PIC24FJ64GB004, first successful USB data transfer

I just got my first successful data transfer through to my PIC.The first transfer in a enumeration process is the "get device descriptor" transfer, which consists of three transfers, setup, in and out transfer. Here is the UART output of the transfer:

***************************

Welcome to MIDI2VC+
Version 0.15
Build date Nov 24 2014

***************************
0x01bf> USB device attached.
0x01bf> Waiting for device power stabilization
0x01ca> Device power stabilized
0x01ca> Full speed device found
0x01ca> Device reset initiation
0x01d3> Device reset complete
0x01d3> Setup token sent
0x01d3> Setup token transfer complete
0x01d3> Handshake was: 0002
0x01d3> In token sent
0x01d3> In token transfer complete
0x01d3> Handshake was: 000b

***************************
Selected register dump:
***************************
0x01d3> U1CON   = 0x0089
0x01d3> U1ADDR  = 0x0000
0x01d3> U1TOK   = 0x0090
0x01d3> U1BDTP1 = 0x0012
0x01d3> U1EP0   = 0x000d
0x01d3> U1CNFG1 = 0x0000
0x01d3> BDT[0]  = 0x6c12
0x01d3> BDT[1]  = 0x0800
0x01d3> BDT[2]  = 0x0808
0x01d3> BDT[3]  = 0x0840
0x01d3> &BDT[0] = 0x1200
0x01d3> &ep0TxBuffer[0] = 0x0840
0x01d3> ep0TxBuffer[0] = 0x0680
0x01d3> &ep0RxBuffer[0] = 0x0800
0x01d3> ep0RxBuffer[0] = 0x0112
0x01d3> U1IR = 0x0044
0x01d3> U1STAT = 0x0000
***************************
***************************


***************************
ep0RxBuffer dump:
***************************
0x01d3> ep0RxBuffer = 0x0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0100 0201 0150 0121 0944 4000 0000 0110 0112 
***************************
***************************

0x01d3> Out token sent
0x01d3> Out token transfer complete
0x01d3> Handshake was: 000e

Now, everything is not great here. The last transfer has an 0xe handshake, which is a stall handshake. This can't be right since I have disabled stalling. The second thing that is fishy is the content of the RxBuffer. I analyzed the USB data transfer of my MicroKey keyboard, by using  Device Monitoring Studio (demo version). Here I can see that the transferred data should actually be:

12 01 10 01 00 00 00 40 44 09 21 01 50 01 01 02 00 01

As you can see, bytes are in the wrong order. I'll look into these issues next...
I'm really happy for this road mark, it means that I get the hardware and it's working! 

No comments:

Post a Comment