Hot!HOW TO: PIC32MZ USB without Harmony

Page: < 123 Showing page 3 of 3
Author
nigelwright7557
Super Member
  • Total Posts : 197
  • Reward points : 0
  • Joined: 2006/11/06 08:15:51
  • Location: 0
  • Status: offline
Re: HOW TO: PIC32MZ USB without Harmony 2019/02/08 20:24:35 (permalink)
0
I was going to upload my harmony USB for pic32mz but its so full of swear words for bits I had problems with !
I got my code mostly from the harmony libraries for HID_DEMO_BASIC
I used the app.h and app.c as the basis for my program.
My program reads data from a2d to the pc.
PIC32MZ a2d is a beast to get to grips with after using smaller pics !
There are dozens of 32 bit registers to get to grips with.
On previous projects there have been about 3 registers to set up to deal with !
 
I had a big problem with my usb interface.
It kept sending back the transmit buffer data from the previous exchange !
I had to add some code which accessed my a2d buffer before it would behave.
#41
MisterHemi
Junior Member
  • Total Posts : 100
  • Reward points : 0
  • Joined: 2017/11/02 12:24:21
  • Location: 0
  • Status: online
Re: HOW TO: PIC32MZ USB without Harmony 2019/02/08 23:23:11 (permalink)
0
AGL59
Thank you !
I will try it for HID device on PIC32MM, even if I have already boards working well for some applications.
I'm a hardware guy, so this is software as I like. Harmony drives me crazzy. I wrote many applications with TCP/IP, web server, digital filtering... without Harmony, which is painfull for me.
Now, the dream would be same code but for host HID on PIC32MZ2048EFM144, as I'm unable to do same thing with Harmony. It was working with a PIC32MX570 and old stack... I will think about it, now I've seen it was possible to use USB without thousands of lines.




You're welcome!
I'm just happy people are finding it useful.
I get frustrated with Harmony too and figured there had to be a way... I worked on it, off and on, for about a year. I had to do a lot of digging and reading, but finally it worked!

My configuration:
MacBook Pro (Retina, 15-inch, Mid 2015) with MacOS High Sierra (10.13.3) and MPLAB X IDE v4.15
 
Curiosity PIC MZ EF, PIC24F Curiosity, and XPRESS EVAL BOARD (PIC16F18855).
#42
Timmons
New Member
  • Total Posts : 18
  • Reward points : 0
  • Joined: 2018/02/07 01:09:23
  • Location: 0
  • Status: offline
Re: HOW TO: PIC32MZ USB without Harmony 2019/02/09 09:02:29 (permalink)
0
Dear MisterHemi
 
i Tested the input endpoint and works Ok!
 
But I cannot transmit packet from EP2. did you testes the transmission?
I try to put the transmission function on "if" below and I try to enable bit 
 
USBCSR0bits.EP2TXIF
 
in the main, but it happen that i have a "reset" when i try to transmit
and windows notifie me "Unknow Device"
 
can you post a transmission example code?
 
Thanks
 
 /* Endpoint 2 TX Interrupt Handler */
   if(USBCSR0bits.EP2TXIF){ // Endpoint 2 Transmit A Packet.
        // To send packets via EP2 call function txUSB_ep2()
        // see how packets are sent in function controlTrans() as an example
        // otherwise this interrupt handler may have limited use depending
        // upon your implementation.
 
    USBCSR0bits.EP2TXIF = 0; // Supposedly Cleared By Hardware (Clear Just In Case).

 
post edited by Timmons - 2019/02/09 09:04:45
#43
MisterHemi
Junior Member
  • Total Posts : 100
  • Reward points : 0
  • Joined: 2017/11/02 12:24:21
  • Location: 0
  • Status: online
Re: HOW TO: PIC32MZ USB without Harmony 2019/02/09 14:28:41 (permalink)
0
Timmons
Dear MisterHemi
 
i Tested the input endpoint and works Ok!
 
But I cannot transmit packet from EP2. did you testes the transmission?
I try to put the transmission function on "if" below and I try to enable bit 
 
USBCSR0bits.EP2TXIF
 
in the main, but it happen that i have a "reset" when i try to transmit
and windows notifie me "Unknow Device"
 
can you post a transmission example code?
 
Thanks
 
 /* Endpoint 2 TX Interrupt Handler */
   if(USBCSR0bits.EP2TXIF){ // Endpoint 2 Transmit A Packet.
        // To send packets via EP2 call function txUSB_ep2()
        // see how packets are sent in function controlTrans() as an example
        // otherwise this interrupt handler may have limited use depending
        // upon your implementation.
 
    USBCSR0bits.EP2TXIF = 0; // Supposedly Cleared By Hardware (Clear Just In Case).

 




I haven't tested the TX endpoint (ep2 if I remember off the top of my head) but it should function similar to the way ep0 functions when sending data, except it has it's own interrupt and handler.

My configuration:
MacBook Pro (Retina, 15-inch, Mid 2015) with MacOS High Sierra (10.13.3) and MPLAB X IDE v4.15
 
Curiosity PIC MZ EF, PIC24F Curiosity, and XPRESS EVAL BOARD (PIC16F18855).
#44
MisterHemi
Junior Member
  • Total Posts : 100
  • Reward points : 0
  • Joined: 2017/11/02 12:24:21
  • Location: 0
  • Status: online
Re: HOW TO: PIC32MZ USB without Harmony 2019/02/09 15:00:21 (permalink)
0
Timmons
Dear MisterHemi
 
i Tested the input endpoint and works Ok!
 
But I cannot transmit packet from EP2. did you testes the transmission?
I try to put the transmission function on "if" below and I try to enable bit 
 
USBCSR0bits.EP2TXIF
 
in the main, but it happen that i have a "reset" when i try to transmit
and windows notifie me "Unknow Device"
 
can you post a transmission example code?
 
Thanks
 
 /* Endpoint 2 TX Interrupt Handler */
   if(USBCSR0bits.EP2TXIF){ // Endpoint 2 Transmit A Packet.
        // To send packets via EP2 call function txUSB_ep2()
        // see how packets are sent in function controlTrans() as an example
        // otherwise this interrupt handler may have limited use depending
        // upon your implementation.
 
    USBCSR0bits.EP2TXIF = 0; // Supposedly Cleared By Hardware (Clear Just In Case).

 




In this function:

void txUSB_ep2(uint32_t ep2TXLen){
volatile uint8_t *ep2fifo = NULL;
ep2fifo = (uint8_t *)&USBFIFO2;

for(ep2ArrPos = 0; ep2ArrPos < ep2TXLen; ep2ArrPos++){
*ep2fifo = ep2usbData[ep2ArrPos];
}

USBE2CSR0bits.TXPKTRDY = 1;
}

you should be able to send data, similar to the way ep0 does, using this function:

ep2usbData = your_data;
txUSB_ep2(sizeof(your_data));

the array your_data is where you'd store the data you want to be transmitted, also be sure the length of your_data isn't more than the ep2 TX buffer size. 
Also maybe clear the array after the data has been transmitted, maybe using something such as
memset
.

My configuration:
MacBook Pro (Retina, 15-inch, Mid 2015) with MacOS High Sierra (10.13.3) and MPLAB X IDE v4.15
 
Curiosity PIC MZ EF, PIC24F Curiosity, and XPRESS EVAL BOARD (PIC16F18855).
#45
MisterHemi
Junior Member
  • Total Posts : 100
  • Reward points : 0
  • Joined: 2017/11/02 12:24:21
  • Location: 0
  • Status: online
Re: HOW TO: PIC32MZ USB without Harmony 2019/03/20 16:52:37 (permalink)
5 (1)
I just added an update and a USB MIDI example. See the updates in the first post.

My configuration:
MacBook Pro (Retina, 15-inch, Mid 2015) with MacOS High Sierra (10.13.3) and MPLAB X IDE v4.15
 
Curiosity PIC MZ EF, PIC24F Curiosity, and XPRESS EVAL BOARD (PIC16F18855).
#46
Page: < 123 Showing page 3 of 3
Jump to:
© 2019 APG vNext Commercial Version 4.5