Questions tagged [mplab-c18]

For questions specifically about the MPLAB C Compiler for PIC18 MCUs (also known as MPLAB C18). This is a C89-compatible compiler for Microchip's PIC18 series of microcontroller units. DO NOT USE this tag for questions about the C standard ISO 9899:2018—use the [c17] tag for that.

C18 is Microchip's C compiler for PIC18 MCUs. Some of its main features are compatibility with Microchip's MPLAB and MPLAB X IDEs, Microchip's hardware and software debuggers, support for code size optimizations, support for PIC18F extended mode instructions and library support for SPI, I2C, PWM, UART, string manipulation and math.

It is available in free LITE version which doesn't support size optimizations and PIC18F extended mode instructions.

Official website of the compiler is here.

Microchip is currently phasing out the C18 compiler in favour of new XC8 compiler.

46 questions
2
votes
1 answer

How do I use larger stack size on Microchip's C18?

Ok, I've been trying to solve this issue by my own for long time now, and I simply give up. I've searched through all the web until I couldn't take it anymore and I need help! I read the whole "C18 Compiler User's Guide" and it says C18 supports the…
john1034
  • 128
  • 1
  • 8
2
votes
1 answer

Why ROM String is not being passed correctly?

I am trying to pass a String to a function. I have read a lot about RAM/ROM Strings in C18 and my code seems ok but it is not working. My function is like this: int setBluetoothName (static const rom char *name){ unsigned int n = 0, k = 0; …
Andres
  • 6,080
  • 13
  • 60
  • 110
2
votes
1 answer

sprintf is outputting some strange data

I am working an embedded project which involves reading/writing a struct into EEPROM. I am using sprintf to make it easy to display some debugging information. There are two problems with this code for some reason. The first; sprintf is printing a…
dantheman
  • 275
  • 2
  • 12
2
votes
1 answer

Linker error in USB HID Code for Microchip PIC (MPLAB/C18)

I'm trying to compile some code for basic USB HID functionality. I'm using a PIC18F14K50 with MPLAB 8.43 and the Microchip C18 compiler. I'm using some standard files from Microchip's website. Here is my C file and here is my header file. I'm…
Ozzah
  • 10,631
  • 16
  • 77
  • 116
2
votes
4 answers

Why is this C macro causing syntax error?

This is the first time I'm using macros in C and I'm trying to replace a large section of code that I'd normally place into a function with a macro. This is a part of an interrupt which will be used quite often and therefore I need to optimize it as…
AndrejaKo
  • 1,721
  • 5
  • 25
  • 41
2
votes
0 answers

Microchip C18 naked function

Someone knows a way to declare a naked function on C18 compiler? By naked function I mean function without any epilogue and prologue. in gcc I use: __attribute__((naked)) int func(int par1) Maybe a #pragma or some trick to have the same…
Gustavo Vargas
  • 2,497
  • 2
  • 24
  • 32
1
vote
2 answers

Trouble Compiling my Microchip PIC18f4550 USB project using MPLAB X IDE C18 compiler. The compiler keep highlighting "syntax error" and won't compile

I am unable to compile my code using the MPLAB X IDE C18 Compiler. The link below is a link to my printscreen picture of the error.As you can see the IDE said that there is a syntax error at the statement LED3 = 0; PrintScreen of Error I have attach…
1
vote
0 answers

Using C18 compiler on MPLAB X on with Wine

I have been wanting to use the C18 Compiler on MAC OS X for a long while for my MPLAB projects, (so as I can use the mdd library), but it isn't available except for Windows. So I have installed Wine and have installed the compiler through it, and…
CN railfan
  • 23
  • 3
1
vote
1 answer

C18 Passing a char array to function

I am new to C programming and microcontrollers. I am using a PIC18F24K20 microcontroller with C18. I have it set up to receive information from a computer input using USART transmit and receive functions. My goal is to compare the received word…
user3115691
  • 95
  • 4
  • 9
1
vote
1 answer

C macro syntax error (C18 compiler)

I got a syntax error when trying to compile this macro. I have to use a macro as C18 doesn't support function inlining. Using a regular function call will cause the compiler to have a much bigger ISR overhead (normally it's about 10 assembly…
serenity
  • 11
  • 5
1
vote
1 answer

Link step can't find symbols (XC8 compiler)

I'm trying to compile and link a C program using the XC8 compiler. I changed from the C18 compiler and made some minor compatibility changes to the code. With C18, the code compiled and linked just fine. With XC8, compiling goes fine, but the link…
user1544337
1
vote
0 answers

PIC 18F87J50 USART Configuration and ISR Troubles

I'm having trouble with a project using a PIC 18F87J50, specifically in my coordination with its 2 USART channels. There are 2 main problems. 1.) Unable to set target Baud Rate: I'm using the Open1USART() and Open2USART() functions to initialize the…
1
vote
2 answers

How to have more than one source file with C18 in MPLAB?

In many languages, such as C++, having lots of different source files is normal, but it doesn't seem like this is the case very often with PIC microcontroller programs -- at least not with any of the tutorials or books I've read. I'm wondering how I…
Nate
  • 26,164
  • 34
  • 130
  • 214
1
vote
2 answers

C18 Microchip compiler and strcmp function

I want to compare two strings: The first string is declared above my main: char _newState[] = "AVAILABLE"; When I want to compare with a const string, i put the line: if(strcmppgm2ram((const char *) "AVAILABLE", _newState ) == 0){ code: } The…
0
votes
1 answer

C18: Representation of LONG and FLOAT constants in code

Is a special representation needed for long and float numbers in the code? In computer programming with C/C++ we put an f letter after a float typed constant number to distinguish it from double type. In C18 language, should/must we do the same…
hkBattousai
  • 10,583
  • 18
  • 76
  • 124