MPLAB X MLA? - Page 1
Forum section: electronics / general

author: vlad777
author_rank: Frequent Contributor
timestamp: August 08, 2014, 05:35:04 pm
content: I have been trying to figure out how to use MLA examples in MPLAB X with XC8.Can somebody help me on this, particularly I want to use USB HID example.Just to get a clean compile for starters.Only thing on the net I found that is helpful for me is this:I got the files from github and managed to convert them to XC8 compiler form.So I got my LEDs blinking, but now I want to learn how to use MLA (Microchip Libraries for Applications).The pic I am using is pic18f2550.Please help me, many thanks.

author: dannyf
author_rank: Super Contributor
timestamp: August 08, 2014, 05:45:18 pm
content: QuoteDownload from Microchip (80+MB) and there is plenty of examples for you to play with.

author: vlad777
author_rank: Frequent Contributor
timestamp: August 08, 2014, 05:49:52 pm
content: Who are you quoting, did I miss something?I did download but can't make heads or tails of it.

author: RenGate
author_rank: Contributor
timestamp: August 09, 2014, 04:09:03 pm
content: I found example located in %Your MLA Install directory%\apps\usb\device\hid_custom\firmware\src to be the easiest to get started with USB HID. It uses raw uint8 buffers to exchange data with PC and doesn`t contain any redundant application specific logic like other examples. Copy its files along with required .h and .c files from %Your MLA Install directory%\framework\usb folder to your own project, and try to compile it.There is a good tutorial series about USB HID implementation on Microchip PICs athttp://www.engscope.com/pic24-tutorial/14-1-usb-an-introduction/. Although it is written for PIC24 so some changes will be required if you want to use that code in your project.

author: vlad777
author_rank: Frequent Contributor
timestamp: August 09, 2014, 04:55:35 pm
content: Thank you I get what you are saying.But I am having trouble with #include<usb/usb.h>When I copy usb dir to project it doesnt see it.When I set include path in project properties than it sees it,but then it doesn't see system.h or system_config.h until i put them in framework directory.Can you please provide a tree structure of your project that compiles.Many thanks.

author: janoc
author_rank: Super Contributor
timestamp: August 09, 2014, 05:03:12 pm
content: Quote from: vlad777 on August 08, 2014, 05:35:04 pmAre those examples actually converted to XC8 already? From what I remember, they were made for the older C18 compiler and don't really compile with XC8 at all without major porting effort. Yay for Microchip shipping libraries that don't work with their preferred toolchainHowever, that was some time ago when I have used their stuff last time.

author: dannyf
author_rank: Super Contributor
timestamp: August 09, 2014, 05:13:44 pm
content: QuoteSet up the include directories right in the project.

author: vlad777
author_rank: Frequent Contributor
timestamp: August 09, 2014, 05:38:15 pm
content: Quote from: dannyf on August 09, 2014, 05:13:44 pmI did, but then usb.h has #include"system.h" in it...

author: dannyf
author_rank: Super Contributor
timestamp: August 09, 2014, 06:11:37 pm
content: They are part of the downloads, for each "system" or "board".

author: vlad777
author_rank: Frequent Contributor
timestamp: August 09, 2014, 06:17:14 pm
content: I figured it out and I find it amazing.You have to set current directory, as include dir by setting one of include paths to . (dot) which means this dir.

author: RenGate
author_rank: Contributor
timestamp: August 09, 2014, 07:39:05 pm
content: Quote from: vlad777 on August 09, 2014, 06:17:14 pmGlad you have made it. I my case I created "usb" subfolder in project directory where I copied all required usb framework`s *.h and *.c files. Next I included that folder via Project properties -> General -> Source Folders menu. Those files are included in my own source files as #include "usb/usb_device.h". Usb framework`s headers include other usb headers directly, e.g., #include "usb_ch9.h".Quote from: janoc on August 09, 2014, 05:03:12 pmThere are many #if defined directives in source files of recent versions of framework, which take into consideration both C18 and XC8 as well as 16 bit compilers and PIC32 one.

author: dannyf
author_rank: Super Contributor
timestamp: August 09, 2014, 07:55:08 pm
content: QuoteIt is fairly basic and a pre-requisite: you have to know how to set up your projects, which files to include and how.

author: vlad777
author_rank: Frequent Contributor
timestamp: August 09, 2014, 08:00:29 pm
content: I got one project to compile and another to attach.This really is NOT a library. It is a bunch of projects for which you have source code.I guess that is why they call it a stack.

author: janoc
author_rank: Super Contributor
timestamp: August 09, 2014, 11:20:47 pm
content: Quote from: RenGate on August 09, 2014, 07:39:05 pmThanks for the info, that's good to know. I haven't touched that stuff in a while. I have looked at the XC8 compiler when Microchip released it, but it was pretty much useless (generated code size, the USB stack not supporting it, etc.), so I have stayed with the C18 one for the projects I did and then moved over to ARM instead. The Microchip tools were not very confidence inspiring - pity, because the chips were nice, especially for the price.

author: dannyf
author_rank: Super Contributor
timestamp: August 10, 2014, 12:01:04 am
content: QuoteI am a recent convert (from PICC to XC8), running 1.12. Nice compiler, even in free mode.QuoteNow, THAT is a horrible compiler.QuoteYeah. I have largely avoided their PIC18 chips because of a lack of tools that I want to use.QuoteI would disagree, unless you get to PIC24.QuoteMicrochip is one of the more expensive vendors.

author: janoc
author_rank: Super Contributor
timestamp: August 10, 2014, 03:30:29 pm
content: Quote from: dannyf on August 10, 2014, 12:01:04 amYeah agreed. Unfortunately it was the only thing that was compiling the stuff I needed back then. I am glad things have changed and when I need PIC next time I can avoid that POS of a compiler.QuoteI have only worked with 18F25J50 and 18F14K50. They work and it is quite hard to find other micros in that price/performance category with hardware USB, unless going to some of the small ARMs. The usual alternative are things like ATMega/XMega and they can't really compete on price (in small quantities) nor features here. That's why I went with PIC even though I am normally an Atmel guy.I have heard good things about PIC24, but haven't really the need for them.

author: dannyf
author_rank: Super Contributor
timestamp: August 10, 2014, 04:10:20 pm
content: The biggest problem for me, for the low-end PIC10/12/16/18 chips, is the lack of a vectored interrupt controller. I utilize extensively canned modules from prior projects. On other chips, I simply include those modules and install my isr handles and I am done.With those low-end pics, you have to manually fuse the isrs together. Pain in that body part.QuoteAn absolutely superb part. The remapable pins are just unbelievable. Your layout guys will love you.QuoteSTM8 is my favorite 8-bit part now: full featured, widely available and quite inexpensive.On the flip side, highly limited compiler support, non-existent code base and uncertain future.