Author Topic: MPLAB X, PIC18F2420 AND MICROCHIP C COMPILER?  (Read 4440 times)

0 Members and 1 Guest are viewing this topic.

Offline kolbepTopic starter

  • Frequent Contributor
  • **
  • Posts: 600
  • Country: za
    • ShoutingElectronics.com
MPLAB X, PIC18F2420 AND MICROCHIP C COMPILER?
« on: January 19, 2013, 06:27:11 am »
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 Compiler

Now 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?

Thanks
Peter
====================================
www.ShoutingElectronics.com Don't just talk about Electronics, SHOUT ABOUT IT! Electronics Blog Site and Youtube Channel
 

Offline mamalala

  • Supporter
  • ****
  • Posts: 777
  • Country: de
Re: MPLAB X, PIC18F2420 AND MICROCHIP C COMPILER?
« Reply #1 on: January 19, 2013, 02:48:31 pm »
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
 

Offline kolbepTopic starter

  • Frequent Contributor
  • **
  • Posts: 600
  • Country: za
    • ShoutingElectronics.com
Re: MPLAB X, PIC18F2420 AND MICROCHIP C COMPILER?
« Reply #2 on: January 19, 2013, 07:41:27 pm »
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 driver

Thanks
Peter
====================================
www.ShoutingElectronics.com Don't just talk about Electronics, SHOUT ABOUT IT! Electronics Blog Site and Youtube Channel
 

Offline JVR

  • Regular Contributor
  • *
  • Posts: 201
  • Country: be
Re: MPLAB X, PIC18F2420 AND MICROCHIP C COMPILER?
« Reply #3 on: January 21, 2013, 08:04:38 am »
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
 

Offline poorchava

  • Super Contributor
  • ***
  • Posts: 1673
  • Country: pl
  • Troll Cave Electronics!
Re: MPLAB X, PIC18F2420 AND MICROCHIP C COMPILER?
« Reply #4 on: January 21, 2013, 09:37:59 am »
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.
I love the smell of FR4 in the morning!
 

Offline kolbepTopic starter

  • Frequent Contributor
  • **
  • Posts: 600
  • Country: za
    • ShoutingElectronics.com
Re: MPLAB X, PIC18F2420 AND MICROCHIP C COMPILER?
« Reply #5 on: January 27, 2013, 01:35:58 pm »
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.
====================================
www.ShoutingElectronics.com Don't just talk about Electronics, SHOUT ABOUT IT! Electronics Blog Site and Youtube Channel
 

Offline Niklas

  • Frequent Contributor
  • **
  • Posts: 397
  • Country: se
Re: MPLAB X, PIC18F2420 AND MICROCHIP C COMPILER?
« Reply #6 on: January 27, 2013, 02:55:33 pm »
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.

C18
Code: [Select]
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++;
}
}

XC8
Code: [Select]
void RS232_TxString(char *String)
{
while(*String)
{
RS232_TxChar(*String);
String++;
}
}
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf