Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

MPLAB X trying to get it to work

Status
Not open for further replies.

large_ghostman

Well-Known Member
Most Helpful Member
Because mplab8 and C18 are no longer, on the new laptop I am having to use mplab x and xc8.
I started with the picc18 template, I liked the look of it at first, so first job I thought was give the ADC a go, I looked in the xc8 docs folder and found
MPLAB_XC8_Peripheral_Libraries.pdf
So looked up my chip 18f4685 and looked at the ADC example, the idea was to copy the example across, But turns out although the doc is named MPLAB_XC8_Peripheral_Libraries.pdf the actual lib used is the C18 lib! so when I tried to use the #include uart.h it tells me it cant find it in the IDE, I have tried adding the file manually but no luck.
Am I correct in thinking that if you use the xc8 compiler then you cant use the C18 header files? in that case why put them in the docs for XC8??
Or is there something I have missed in the reading? 5 days now and still getting nowhere with this tool chain, ok that could be me, but surely it shouldnt be this difficult to get it working?
Finaly got the mplabx to recognize my ICD3, the solution was simple, keep closing and opening mplabx until it finally said it recognized it!!
Yes some are saying I am bashing microchip for no reason, but lets be fair here, taking away tools that worked and making you use tools that in all honesty, are not ready to be released is unfair.
I have gone through the tutorials, I have read the docs. I have contacted microchip support, they take was its my fault I am using windows 8.1! I pointed out that wasnt by choice, it was a new laptop and now thats what you get on them.
Just as a comparison ARM MDK with Attol IDE and I had a 32 bit chip doing graphics and touch screen within 40 mins of starting, and no I didnt use the libs included, the tool just works and works well.
I am willing to give mplabx and xc8 a fair shot, so any advice? what am I doing wrong? because none the documentation has told me yet.
 
ok I might have not explained well, I will try again
The situation, you are a new user. you cannot get a standalone copy of C18 anymore, only upgrade ones, so as a new user you dont have access to C18 files.
You read the help doc for peripheral libs, and for example want to use the ADC one.
you goto page 949 of the document (the xc8 lib doc), and they kindly give you an example. BUT you cant use it, it uses the C18 header files! So why is it in a document that is meant to show you how to use xc8 libs??? ok the work around is start mplab8 with C18 and build it all in that, then import to mplabx.
BUT if your new you cant get a student or trial version of C18. you have to already have this as they have now taken the file away! the only C18 compiler files available are upgrade ones that need the base compiler.
ADC is one example, most the others are the same. So how the hell do you now use the peripheral libs if you are new, or dont have C18 anymore?? and why do they use the C18 libs in the xc8 docs, when they dont work as is with xc8??
 
forgot to add, if you do have the C18 tool chain try and use the example ADC lib in mplabx, from the xc8 lib doc, set the tool chain to C18, then cut and paste ;)
what happens is the formatting changes! so comments and commands all blend!!!
But the main point is, the xc8 libs are worthless if your completely new to pics and dont already have the old tools.
 
Here is a link to download C18 eval and lite versions, you might have to create a (free) account first.
**broken link removed**
 
thanks I looked all over for it!!!! thats a great help, shame it is no longer going to be updated, I still dont get why they use C18 libs now tho
 
The plan was (and maybe still is) to have legacy C18 mode for XC8.
 
it does, but first you have to find the C18! so far I havnt seen much on actual xc8 peripheral libs???? and all the examples I found used C18 headers, the whole thing seems a mash up. For now I have gone back to C18 and mplab8, its only for a couple of projects then I can get rid of the rest of my pic stuff.
Now ive used 8051 and arm mdk, I find them alot easier and the tools better, just my opinion. Also android in phones etc is ARM based, so looking ahead maybe thats what I should be learning.
only thing I will miss with pics is DIP packages. Its a shame the new tools are how they are, I really liked MPLAB x layout and some other stuff, and had they kept C18 I would probably have stayed with pics, but xc8 just isnt my thing! Funny thing is my school in the upper and lower sixth form use pics in there tech classes, apparently they are being phased out in favour of something else (we dont know what yet), the two teachers that take the course both are dropping pics because of xc8.
I must keep an eye out on the skips :D.
You only get micro's in the last two years, so from 16-18 years old. Yet it seems alot of people here like it?? maybe its just not liked by beginners??? I dont think the school will go with ARM tho, or 8051, my guess would be freescale because they have had one of there vans in the carpark alot lately :D
 
XC8 is a software engineers (and software company) idea of how the C language should isolate the programmer from the hardware by removing/minimizing PIC architecture defaults and restrictions at the source level , translating C to very general code blocks and letting a very good (value added Omniscient Code Generation) optimizer translate those code blocks into good PIC' machine code. That works if the compiler is top-notch and the best optimizer modules is enabled even at 'free/student' levels. The problem is without the optimizer it generates very bad code because it generalizes too much to be a good teaching compiler in the free mode.



The latest XC8 versions are getting better at default optimizations.

C18 seems to have been designed to mainly sell hardware. Even the free versions produce decent code when optimizations are disabled if you understand why it has what seems to be bugs or limitations that are actually source code level optimizations instead of a back-end optimize function.
 
Last edited:
LG! Everyone who has used C18 for a while runs into the same issue as you are having.... I mentioned somewhere else on the forum....

If you rely on microchips libraries, then you are in the hands of other people... I watch people here and on AAC using MikroC.... Because all the legwork has been done, It doesn't teach you jack!!! If you want to learn for yourself then you need to write ALL of your own code... Pulling up libraries written by someone else..

I have been using Hi-tech for some years.... I have moved to XC8 with relative ease as they are the same pieces of software.... C18 has been mashed with Hi-tech for pic18 and included into XC8 so I'm already ok with it..

XC8 has a few issues with MPLABX but I'm sure these will be resolved... If you use XC8 with MPLAB 8 for the time being you can at least get used to it...
 
Ian are you saying Hi Tech C already runs pretty much as s with XC8? My issue is I look at the libs to see how things are done, I then go and like you say do my own thing, normally by using the register name or bitfield name. Where I have run into trouble, is the documentation. The other problem is while learning, if I cant something to work, I use the lib in part. Then use the watch window and debug, that way I see what registers and bits need setting. Then I take the lib code out, and replace with my own.
The advantage it gave me was, I could read the datasheet and not always understand the language used, but once the code works, you can then watch the registers and go back into the datasheet and understand what they are saying. So I am not writing code to use the libs, I use them when I get stuck, so I can go peek at why I was stuck. Then I delete that function and replace with a often tweaked version, this has helped me understand what is sometimes a too technical babble datasheet. The babble makes sense doing it the way I was.
But if Hi Tech C is close to XC8 then I have a couple of books that will help. Dad got Mikro C when he first started, it got used once because you cant use the pk's to debug with it. Also to me its alot like flow code, it dosnt teach you anything, but if you just want to get things done without having to mess with code, then Mikro C I think is ace, I have never used it as such. But its what I think you once called a RDS. I dont want a RDS , I dont want to use libs, I use them to work back from so I can teach myself.
And that is the main problem, I am a kid trying to learn and there just isnt the resources geared up for that, no one teaches you how to get information from a datasheet. For example it took ages before I realized that in the oscon table in the datasheet, where it gives you bits called IRFC then tells you 001 000 111 etc etc for setting the speed of the internal osc, no where, no one said look that IRCF can be used, you can write in your code IRCF2=1 etc etc, that would have made a massive difference. 18 months after trying to learn, I came across that fact and I use bit field names alot in my code.
Small silly bits of info like that, make it much easier for someone with no idea easy to learn.

BUT my point was not that I want to use the libs, but a new person is lead to believe that you can use the examples given in the xc8 docs, and get it to work! you cant, not at the moment. Also they have used a doc format that means you cant cut and paste into code, all the formatting goes funny and words merge.
I will do some screen shots later.

thank you for the information guy's, it helps. Its real hard learning without books and without someone sitting there with you. Frustration makes you give up in the end.
 
XC8 is Hi-tech..... You can take your old hi-tech code and compile it with XC8 without any changes

XC8.H just calls HTC.H which in turn calls PIC.H.... All they have done is re-written (badly) all the C18 libraries to run on XC8 ( Hitech 18 )...

When I say badly... The headers have been changed so any old files you have MUST be recompiled with the newer definitions.... The ADC library is a nightmare.... C18 uses OR and AND masks... Recently they swapped them around....

As I said.. I have my own code, so I have little problems compiling my stuff....
 
:D so problem solved!!! all I need to do is take apart H Tech libs and work from them! It seems totaly mad they used C18 examples instead of the Hi Tech ones!!! I am just starting to do my own libs, but first I sometimes need to use there one's so I can see what they did, then I do it my way if that makes sense!!
By the way Dad is having his op today, hence why I am off for a bit. He is fine, but his shoulder/arm needs tendons and other bits sorting out, also he damaged an artery, so they are going to graft it, he should be home in a couple of days.
What gets me is, all my life dad has told me when around tractors, never stick your hands anywhere you wouldn't want to put your willy! So he either forgot his golden rule. Or my dad is a perv :D.
 
Its been hard, but finally making a small dent into this, I gave up using the complete ADC lib, instead I am looking at the perith Lib and datasheet and sort of making my own functions.
I like the template in mplab x, some of the H files and user H files are a bit confusing, But I do like to be able to put function declarations in one place and the functions in another and the config stuff somewhere else! Rather than stick it all in MAIN like I used to. Yes I am aware you could do it in C18, but having the template to work from makes the job a bit easier, and I have found it good for learning what goes in the H files and what goes in the C files etc. XC8 still annoying the hell out of me! gives me errors,moans and b itches but then compiles fine!!
Also a small point but it keeps telling me if I buy the pro version it could save me x amount of space and do things 400% quicker if I part with cash!
Not a chance will I pay top wallop for something that dosnt yet work correctly!
Makes me wonder how they can make my code perform 400% faster if they cant even get the basics working right:D.
I would pay a little bit of cash for a partly working pro version, which after all it is!
Dad is ok and home tomorrow.
 
I always hated when you need to have separate function definitions in one place and then functions themself in a separate place. If I already wrote a function in one place, why do I need to copy and paste it somewhere else? Or if I want to change arguments, why do I need to do that twice?

Many languages require this in various forms. Java is ahead of the others in this respect. Assembler, of course, too, because there's no definitions at all :)
 
I like it because of my ocd like neatness! But yes I can see why others would hate it, For me its more a case of hating everything in one huge long file, having to scroll through it all to find one little bit.
Of course if I learnt to use the tool properly I could get around that! But for now I am stuck with home learning any way I can.
 
I like it because of my ocd like neatness! But yes I can see why others would hate it, For me its more a case of hating everything in one huge long file, having to scroll through it all to find one little bit.
Of course if I learnt to use the tool properly I could get around that! But for now I am stuck with home learning any way I can.

Do not start writing single file programs.. The way you are coding now sounds really good. Keep it up. Keep the files small.. write well defined modules.
 
So. I have spent day's, reading the Mchip forum about XC8, very interesting! for ages the all knowing were saying XC8 and C18 not compatible, and that was why C18 was being updated still. Then C18 was stopped, but still little is compatible, and the advice is still use C18 for CAN and USB, most the microchip stacks in the new release dont support pic 18f, so I put in a support ticket.
Apparently alot of the USB examples etc that were originally in the old releases , and the CTMU and other stuff, are NOT going to be ported over to XC8 from C18.
So they advise old designs use C18, new designs use XC8, I asked well what about CTMU examples etc? they have replied they are no longer going to provide those for 8 bit micro's in the new releases.
Seems a bit odd.
Apparently all the Htech hacks work tho, so why dosnt M chip just say, look XC8 is Hi Tech C bodged with net beans? I really thought I was being stupid, but it appears even the clever people are still having to use C18 for much of there stuff. Or some say with XC8 your on your own, you write your own libs, trust the compiler and not the IDE, the IDE throws many false errors. Oh well I will keep trying with XC8, no point flogging a dead C18 :D
 
And more than that!! I thinks its a new version!!! I was sure 3.46 was latest before. I have no way of checking because dont have old version on here!!
wow seems like maybe I wasnt the only one sticking alot of tickets in :D
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top