Simplified Microchip PIC USB demos (C18/XC8 MLA)

Re: Simplified Microchip PIC USB demos (C18/XC8 MLA)

Postby skr100470 » Wed Sep 09, 2015 11:38 am

Dear Vloki
Thank you very much for the code LPC_FSUSB-HID-X-r2(v2014_07_22,) and It works for me well.
I could able to exchange data to HOST PC via USB.
One challenge I face here is, I am unable to configure PORTD as
input while using this USB Stack . I need to read 4 switches connected on PORTD . I checked the PORTD input
functionality through separate code and works fine but not working with USB STACK.
Do I need to set/reset any register apart from TRISD?.Please find below my initialization code I called in main

Is there any relation between PORTD input configuration with USB STACK function?
I am not using SPP and hence SPPEN set to 0

Thank you very much in advance for the supports

void InitApp(void) {


SPPEN=0;
LATD =0x00;
PORTD=0x00;
TRISA = 0x00; // bits 0..3 data, bit 4 = R/W, bit 5 = RS
TRISB = 0xFF; // Temp switch
TRISC = 0xFE; // not used set as input
TRISD = 0x1F; // bits 4..7 = LEDs, bits 0..3 = switch inputs
TRISE = 0xFE; // bit 0 = LCD Ena, remainder not used set as input

ADCON1 = ADCON1 | 0x0F;
}


MAIN_RETURN main(void)
{

SYSTEM_Initialize(SYSTEM_STATE_USB_START);

USBDeviceInit(); //usb_device.c
#if defined(USB_INTERRUPT)
USBDeviceAttach(); //usb_device.c
#endif
/* Configure the oscillator for the device */
ConfigureOscillator();

/* Initialize I/O and Peripherals for application */
portb_change_int_en();
InitApp();
lcd_init();
on_change=PORTB;
pos=0x00;
skr100470
 
Posts: 1
Joined: Thu Aug 06, 2015 5:40 am
PIC experience: Professional 1+ years with MCHP products

Re: Simplified Microchip PIC USB demos (C18/XC8 MLA)

Postby ric » Wed Sep 09, 2015 3:03 pm

What PIC are you using?
Latest test project, an LED matrix display made from one reel of addressable LEDs. here
User avatar
ric
Verified identity
 
Posts: 659
Joined: Sat May 24, 2014 2:35 pm
Location: Melbourne, Australia
PIC experience: Professional 5+ years with MCHP products

Re: Simplified Microchip PIC USB demos (C18/XC8 MLA)

Postby deiv23 » Thu Oct 01, 2015 4:39 pm

Hi again Vloki,

everything working fine with hid comunication in my project, but... it goes too slow. I have to send 768 bytes of data to the pic. I send a first packet identifying the command to run in my app, and another 12 packets of 64 bytes. The whole transaction takes 0.15 seconds and I want to do it faster.

I'm thinking about changing the type of comunication from interrupts to usb polling. What's the max packet size in this mode? If it is greater than 256, how I configure the descriptors if the max value i can put there seems to be 0xFF?

Thanks
deiv23
 
Posts: 12
Joined: Fri Aug 07, 2015 12:21 pm

Re: Simplified Microchip PIC USB demos (C18/XC8 MLA)

Postby vloki » Thu Oct 01, 2015 7:32 pm

I think there is possibly some misunderstanding here.
HID uses the usb interrupt transfer type like described in the former link I gave to you.
That a usb interrupt transfer happened is signed then by a flag from the (usb)SerialInterfaceEngine.
You may poll this flag - or configure an interrupt that is fired if the flag is set.

Do the 13 transfers really last 150ms or 15ms?
(The minimum interval time the host should poll the endpoint is given in the endpoint descriptor and should be 1ms)
vloki
Verified identity
 
Posts: 186
Joined: Wed May 28, 2014 8:42 am
Location: Germany
PIC experience: Professional 5+ years with MCHP products

Re: Simplified Microchip PIC USB demos (C18/XC8 MLA)

Postby imarian241t » Fri Oct 02, 2015 7:24 am

Guys please help, I've tried all my best to resolve this issue but I just can't.....I get some compiler errors , mainly related to the PDFUSB4550.C file, where these includes were commented
//#include <USB/usb.h>
//#include <USB/usb_device_hid.h>
//#include <ADC.h>
So I tried uncommenting the first two, got no problems related to them, I tried to uncomment the third include (ADC.h) thinking that may be the problem I get compiler errors, but it just added to the error pile( error: (141) can't open include file "ADC.h": No such file or directory)
I've atached a print screen with the errors I'm getting
Attachments
pic1.png
pic1.png (189.34 KiB) Viewed 7062 times
imarian241t
 
Posts: 7
Joined: Fri Oct 02, 2015 7:09 am

Re: Simplified Microchip PIC USB demos (C18/XC8 MLA)

Postby imarian241t » Fri Oct 02, 2015 7:26 am

If I comment anything related to the ADC the project compiles with no errors, but this can't be right
imarian241t
 
Posts: 7
Joined: Fri Oct 02, 2015 7:09 am

Re: Simplified Microchip PIC USB demos (C18/XC8 MLA)

Postby vloki » Fri Oct 02, 2015 7:45 am

xc8 compiler newest version?
-> You have to install the plib separately
(you will find them at the bottom of the compilers download page)
vloki
Verified identity
 
Posts: 186
Joined: Wed May 28, 2014 8:42 am
Location: Germany
PIC experience: Professional 5+ years with MCHP products

Re: Simplified Microchip PIC USB demos (C18/XC8 MLA)

Postby ric » Fri Oct 02, 2015 7:45 am

I can't see any indication on your screen cap of which version of XC8 you are using.
If it is the most recent version, you have to download the plib files seperately from the compiler, whereas previously they used to come with it.
Latest test project, an LED matrix display made from one reel of addressable LEDs. here
User avatar
ric
Verified identity
 
Posts: 659
Joined: Sat May 24, 2014 2:35 pm
Location: Melbourne, Australia
PIC experience: Professional 5+ years with MCHP products

Re: Simplified Microchip PIC USB demos (C18/XC8 MLA)

Postby imarian241t » Fri Oct 02, 2015 7:48 am

I use XC8 v1.35, is this causing me problems?
imarian241t
 
Posts: 7
Joined: Fri Oct 02, 2015 7:09 am

Re: Simplified Microchip PIC USB demos (C18/XC8 MLA)

Postby vloki » Fri Oct 02, 2015 7:51 am

Yes -> http://www.microchip.com/mymicrochip/fi ... e=en574973

From the v1.35 release notes
1. Overview
1.0. Introduction
This is general update to the Microchip MPLAB® XC8 C compiler. This version introduces several new features, corrects a large number of reported bugs, optimizes many code sequences, and consolidates support for many new devices. Note that this distribution no longer includes the PIC18 peripheral libraries.

...

4. Migration Issues
The following are features that are now handled differently by the compiler. These changes may require modification to your source code if porting code to this compiler version. The version number in the subheadings indicates the first compiler version to support the changes that follow.

4.0. Version 1.35
Removal of PIC18 peripheral libraries The PIC18 peripheral libraries and their associated header files and documentation are no longer shipped with this compiler. The MPLAB Code configurator (MCC) can be used to generate routines that perform similar tasks to those supplied by the peripheral library, and can generate code for many devices, not just the PIC18 family. The MCC is available as an MPLAB X IDE plugin and can be downloaded from the IDE under the Tools > Plugins menu. If you need to use the peripheral libraries that were formerly shipped with the compiler, these are available as a separate download and will need to be installed over the top of your compiler installation.





I think they want to replace the old plib with the new MCC and therefore "hide" the plib.
-> http://www.microchip.com/pagehandler/en ... /home.html
I don't like it;-)
Last edited by vloki on Fri Oct 02, 2015 8:12 am, edited 3 times in total.
vloki
Verified identity
 
Posts: 186
Joined: Wed May 28, 2014 8:42 am
Location: Germany
PIC experience: Professional 5+ years with MCHP products

PreviousNext

Return to USB

Who is online

Users browsing this forum: No registered users and 6 guests

cron