MPLAB X, PIC18F2420 AND MICROCHIP C COMPILER? - Page 1
Forum section: electronics / general

author: kolbep
author_rank: Frequent Contributor
timestamp: January 19, 2013, 06:27:11 am
content: Hi All.It has been some time since I did some Pic'ing.I used to use MPLAB (The Version just before X), Microchip C18 Compiler, and my 18f2420's.I also used the libraries for the C18 CompilerNow I have put on MPLAB X, and want to start new projects from scratch. Does anybody know if the XC8 Compiler has the same libraries, or should I just put C18 on again, and use that?ThanksPeter

author: mamalala
author_rank: Unknown
timestamp: January 19, 2013, 02:48:31 pm
content: Better stay with C18. The XC8 generates extremely lousy code in the free version. You might also want to check SDCC, which also produces rather decent code and has some advantages over C18. But going with SDCC means you have to rework the libraries you already have a little bit.Greetings,Chris

author: kolbep
author_rank: Frequent Contributor
timestamp: January 19, 2013, 07:41:27 pm
content: Thanks.I am sticking to C18. The change to Mplab X has confused me enough as it is.Just another question, has anybody used the XLCD Library by Microchip for a 16x2 LCD with Data on Port C, and RA1-3 for the control lines.I have been trying the whole day so far. It seems still to be doing something to PortB instead of the LED's on PortC (for debugging) doing what they are supposed to do.I can get the LCD to work if I do my own code (after wasting about 3 hours because I had the LCD plugged the wrong way into the dev board - it was giving black squares, so I thought it was ok). but I thought if the lib works, it would be easier.So again, do you all use the lib, or rather code your own external LCD driverThanksPeter

author: JVR
author_rank: Regular Contributor
timestamp: January 21, 2013, 08:04:38 am
content: For the LCD not working, follow the defines for the data port. IIRC there was a problem there somewhere. The lib just defaulted to some port, regardless of the setting

author: poorchava
author_rank: Super Contributor
timestamp: January 21, 2013, 09:37:59 am
content: free version of XC8 is only recommended when u need to write a non time-critical code and have plenty of flash space to waste. It is kinda user-friendly, especially when compared to C18, but if u need any tight coding, you have to go _asm or buy the commercial licence.

author: kolbep
author_rank: Frequent Contributor
timestamp: January 27, 2013, 01:35:58 pm
content: Ok, so when i changed the defines in xlcd.h , i had to recompile the library for my pic.Now all is working except for the writing of a string to the lcd. Individual bytes and characters work, just not strings. Maybe i should code this part myself.

author: Niklas
author_rank: Frequent Contributor
timestamp: January 27, 2013, 02:55:33 pm
content: There are some differencies between C18 and XC8 regarding the RAM and ROM string handling. With C18 you had to use different type of pointers for RAM and ROM so the easiest solution was to have separate functions for them. I have ported some of my own RS232 string functions from C18 to XC8.C18Code:void RS232_TxRAMString(char *String){while(*String){RS232_TxChar(*String);String++;}}void RS232_TxROMString(const near rom char *String){while(*String){RS232_TxChar(*String);String++;}}XC8Code:void RS232_TxString(char *String){while(*String){RS232_TxChar(*String);String++;}}