Questions tagged [xc8]

The Microchip XC8 compiler is a C compiler that can target Microchip's PIC 10/12/16/18 range of 8-bit microcontrollers. A free version is available that offers less optimization than paid versions.

122 questions
11
votes
3 answers

Variable declaration with @ in C

I am reading some C code and came across this declaration in the program: unsigned char serv_ctr @0x0002; Can someone point me to documentation, or explain what the "@0x0002" is for in the Mplab XC8 v1.35 C compiler?
be-ee
  • 395
  • 3
  • 13
7
votes
3 answers

Strategies for managing code size - PIC18 XC8

I'm new to embedded C development and I'm looking for some general principals/guidelines for managing the size of the generated code. In my specific example I'm using XC8 on a PIC18F4550. My code so far uses about 13% of the space. Once I use…
Andre
  • 267
  • 2
  • 11
6
votes
2 answers

PIC18F4550 CPU appear to be not running at external crystal frequency

I am trying to add a 20MHz external crystal oscillator to my PIC18F4550 microcontroller. The external crystal oscillator circuit connections to the PIC18F4450 is as below: The Datasheet suggest to use 15pF capacitors for 20MHz crystal however, I…
Chris Aung
  • 338
  • 2
  • 9
5
votes
2 answers

XC8 pointer issue

I am struggling with the following code: #include #include "config.h" void Init(void); void uart_send(char*); void main(void) { char arr[2]= {'a','b'}; char i=0; Init(); uart_send(arr+i); i++; …
PeterPal
  • 51
  • 3
5
votes
1 answer

MPLAB XC8 + PIC18 + external memory = Error 712 (can't generate code for this expression)

I'm currently having a bad time trying to use an external RAM chip (512 kB) with a PIC18F8720 and the Microchip XC8 compiler (v1.35, PRO mode). Whenever I try to write some code to modify a variable in the external memory, the linker throws an error…
equalizer
  • 53
  • 4
5
votes
1 answer

PIC16F628A Blinking LED

I was setting up a PIC16F628A for a simple Hello World program (blinking LED) and somewhere in the process, I have failed. The LED stays lit at the specified pin and does not "blink". I am using the Internal Oscillator (which resonates at 4 MHz).…
Seif Shawkat
  • 301
  • 1
  • 6
  • 13
5
votes
1 answer

PIC XC8 arguments redeclard

I'm trying to get to know my PIC with simple 'start-up' projects. I made a LED flash with a button. I made a BCD count up from 0 to 9 with a delay. Now I want to combine those two and also refractor the code a bit. So I want the BCD to increment on…
Jeroen
  • 153
  • 1
  • 5
4
votes
1 answer

How to offset program location in memory with MPLABX XC8?

I have a bootloader residing at locations 0x0000 to 0x0fff on an 8-bit PIC18F. How do I tell the XC8 compiler to output a hex file which starts at 0x1000? With a CCS compiler my friend is using, he's using the following code: #define LOADER_SIZE …
Daniel
  • 334
  • 1
  • 5
  • 18
4
votes
1 answer

Sequential I2C read from MPU6050 with PIC16F18877 different from expected

To save time and reading I copied a code block from a program found on the internet to determine the X angle of inclination. int Ay = (((int)I2C_Read(0)<<8) | (int)I2C_Read(0)); int Az = (((int)I2C_Read(0)<<8) | (int)I2C_Read(1)); During the…
Decapod
  • 3,900
  • 9
  • 23
4
votes
1 answer

i2c undefined symbols on compile MPLab XC8

I am trying to compile a simple I2C program for a PIC18F45K22 using MPLab XC8 compiler. I am getting the error: :0: error: (500) undefined symbols: apparently relating to _WriteI2C1, _ReadI2C1 and _OpenI2C1 at the production.obj stage of project…
user105113
  • 81
  • 4
4
votes
1 answer

Using XC8 compiler instead CCS

I'm programming PIC with CCS. It's quite simple and functional. It's libraries are the best. Recently, I look for XC8 compiler, from Microchip. What are the advantages of using XC8 instead CCS?
Gonzalo Cervetti
  • 113
  • 2
  • 11
4
votes
2 answers

Pre-Defining EEPROM Values in XC8 Compiler

I'm working with a PIC16F690, using Microchip's XC8 compiler. I want to embed EEPROM values into the hex file, so that the EEPROM gets programmed at the same time as the program memory. I've done this in the past with the C18 compiler (it was for a…
bitsmack
  • 16,747
  • 9
  • 52
  • 108
4
votes
3 answers

Maximum length of variable and function names?

I'm not sure whether this is a property of the compiler or something standard to C. I've heard of limits on the number of characters long a variable or function can be (e.g. 25characters). I'm not there yet, but just saw a decently long function…
tarabyte
  • 3,112
  • 10
  • 43
  • 67
3
votes
0 answers

ESP8266 only responds to first AT command

While interfacing the ESP8266 module to PIC18F4550, I noticed that the ESP8266 only responds to the first AT command that is transmitted by the PIC MCU. It will not respond for the rest of the commands that follow. I have tried increasing the delay…
Chris Aung
  • 338
  • 2
  • 9
3
votes
2 answers

How can I implement regular expressions on an embedded device?

I have some (I thought) pretty portable code that uses . When I tried to port this over to compile for a PIC18 with xc8, the compiler could not find the header file for the library. module/ciface/ciface.h:12:10: fatal error: 'regex.h' file…
Harry Beadle
  • 791
  • 3
  • 18
1
2 3
8 9