# Does any MPLAB compiler e.g XC8 have built in functions to control PIC peripherals like in CCS PIC C

The CCS compiler provides a lot of built-in functions to access and use the PIC microcontroller's peripherals. This makes it very easy for the users to configure and use the peripherals without going into in depth details of the registers associated with the functionality.

Examples:

D/A conversion: dac_write(), setup_dac()

RTOS: rtos_await(), rtos_msg_send(), rtos_run(), rtos_disable(), rtos_overrun() e.t.c

Non-volatile memory: erase_eeprom(), read_external_memory(), write_eeprom( ) e.t.c

Timers: get_timer_x(), set_timerx(), setup_timer_0() e.t.c

Is it possible to somehow get the same functionality in the MPLABX IDE as well or shall I have to write my own library functions like the ones shown above by writing code that tampers with registers at low level? I am using the XC8 compiler.

The CCS C Compiler having these type of functions is the main reason why I have used it in the past. But now I want to move over to MPLAB.

• You can find everything from here ccsinfo.com/content.php?page=syntax-functions Mar 25 '15 at 20:47
• The ccs compiler is worth every cent. Mar 26 '15 at 0:11
• Scott Seidman. I understand. Unfortunately, I have an ICD3 which is not working with my CCS C Compiler (ver 5). Have you found any bugs in the MPLAB software you would like to point out? I have found people supporting both the tools, MPLAB as well as CCS C Compiler. I am not sure which is better i.e less bugs and provides more ease in programming and debugging PIC microcontrollers. Mar 27 '15 at 18:01
• How to use the ccs compiler with icd3 is made clear in the ccs faq Mar 27 '15 at 20:59

You should find documentation for Microchip's XC8 Peripheral Library in the 'docs' folder where you've got the XC8 compiler installed.
On my PC its at C:\Program Files (x86)\Microchip\xc8\v1.21\docs
The file you're looking for is MPLAB_XC8_Peripheral_Libraries.pdf

I don't particularly like the documentation or their automated Doc-O-Matic system which produces it since it doesn't feel particularly user-friendly to me, but YMMV ...

• I must say after checking this document that this is poooor documentation. What a shame... Mar 25 '15 at 21:17
• Personally I never use plib but always roll my own code to access the registers - that way I know exactly what it's doing and how it works. Mar 25 '15 at 23:38
• As far as I'm aware, plib is for PIC18 only, which may affect its usefulness to the OP.
– mlp
Mar 26 '15 at 3:24
• plib is also for pic32, and I would imagine pic24/dspic33. On the chipKIT platform we have completely phased out the use of plib in the core now - it's all 100% hand written code. Mar 26 '15 at 10:42
• plib is implemented on the 16 & 32-bit PICs (although on PIC32's its being phased out in favor of 'harmony'). But one of my pet gripes with Microchip's plib is its inconsistency across different families. For example you'd expect to write some plib code on an 18F to do a bit of I2C-ing and then at some later date port it over to a 24F - but all of the plib function calls and parameters change so you end up rewriting it all from scratch ... Mar 26 '15 at 12:52