Episode #125 of the Stack Overflow podcast is here. We talk Tilde Club and mechanical keyboards. Listen now

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.

Filter by
Sorted by
Tagged with
0
votes
0answers
22 views

PIC16F7X I2C Issues With 24AA01/24LC01B EEPROM

I have an existing PCB that is no longer supported by the manufacturer and has been plagued with software issues for years. So i don't have much control over how the board is laid out and what ...
3
votes
2answers
1k views

How can I implement regular expressions on an embedded device?

I have some (I thought) pretty portable code that uses <regex.h>. When I tried to port this over to compile for a PIC18 with xc8, the compiler could not find ...
3
votes
1answer
142 views

How can I use 64-bit integers on a PIC18?

When I try to declare either a unsigned long long or a uint64_t the xc8 compiler throws the ...
3
votes
1answer
59 views

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. ...
1
vote
0answers
64 views

How to specify in the project or firmware of the application, where to start writing the code?

I have a bootloader to PIC18F4550 that was written using Mikro C for PIC and I have two firmware applications, one was written using Mikro C for PIC and the other using MPLAB X with XC8 compiler. With ...
11
votes
3answers
1k views

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 ...
3
votes
3answers
414 views

How to define 14-bit lookup table for PIC/XC8 (if it's possible to do without assembly)?

I'm writing the firmware for a simple testing device that would need to store a very large lookup table (I need 13500 entries with values 0..100 decimal). The target PIC MCU is PIC16F1829 (8K words of ...
0
votes
1answer
106 views

Timer0 not interrupting on PIC18f4321

I'm trying to run some basic code from my textbook onto a PIC18F4321, using the latest XC8 compiler. It's supposed to turn on an LED after 10 seconds, but the LED never turns on. I've checked my ...
2
votes
2answers
92 views

Why are different names given to the same bit in MPLAB XC8?

I am using PIC18F45K22 and MPLAB XC8. Recently I stumbled upon something while reading ADCON0 register. A particular bit in the register, GO/DONE has many representations while I try bit addressing it ...
-1
votes
1answer
190 views

SRF05 | PIC16F18875

I´m doing a project for my electronics class. I´m trying to calculate a distance using a SRF- 05 Ultrasonic Sensor; but the result in the display is 0 . I´m using a Curiosity HPC Development Board w/ ...
0
votes
2answers
388 views

software pwm with pic16F628A and XC8

My current knowledge of PICs is currently limited to simple LED blinking with and without the use of interrupts and timers in C code with XC8, MPLAB IDE, and Pickit 3. I have trouble implementing this ...
1
vote
0answers
67 views

Migrating from C18 to XC8 ADC Conversion Issue

I'm working with Pic18f6622 and migrating my program into XC8 compiler. Before I'm using the C18 compiler ADC conversion was working just fine, but in new compiler ADC returns me 11 bits value and the ...
0
votes
0answers
369 views

EEPROM read/write problems on PIC16F18877

For a reason not clear to me I can not write to the EEPROM of the PIC16F18877. Programming is done with the XC8 compiler. Debugging with PICKIT3 The function works well in the simulator but fails to ...
0
votes
2answers
344 views

PIC18LF24K40 I2C read and write using Polling method

I'm trying to implement read and write routines using Polling method for a PIC18LF24K40, write seems to work, but not read. I cannot figure out what i am doing wrong. EDIT: Reading a byte stored in a ...
0
votes
1answer
280 views

Playing around with I2C does not yield expected results for SSD1306-OLED

I'm trying to use an OLED-screen with I2C, but nothing happens (literally) so I come here to see if anyone can shed some lights on what I've done wrong. My first approach was to write a software I2C-...
0
votes
1answer
333 views

MPLABX + XC8 + Proteus 12F683 Configuration Word problem

I use MPLABX + XC8 with Proteus to simulate PIC designs. It usually works fine...but I recently tried to use a 12F683 part and I get an MPLABX message "ERROR writing to CONFIG_MEM". I think the ...
2
votes
1answer
228 views

PIC16F1783 Inclinometer Project using Accelerometer 12-bit ADC issue

I am working on an inclinometer project using an accelerometer, MMA1220KEG and a PIC16F1783, it is designed to switch a relay when the angle of inclination is below 15 degrees and illuminates a series ...
0
votes
0answers
289 views

Serial Flash always returning 0x00 while reading after writing

Could someone look into the code and tell me the mistake in the code I am trying to Interface PIC16F877a and AT25SF041 serial flash. I have pulled up CS pin to 5V using 1K resistor The flash is ...
1
vote
1answer
153 views

scrambled uart output

I am new to pic uart communicatioon with PC using RS232. I have tried the below code and used Hyperterminal to view the output. But the output gets scrambled here and there each time when I reset pic. ...
1
vote
1answer
397 views

I2C doesn't send data in PIC16F887

I'm relatively new using PIC microcontrollers and MPLAB XC8 compiler. I want to communicate two PIC16F887 using I2C. I did use this tutorial (https:// electrosome .com /i2c- pic-microcontroller-...
3
votes
1answer
2k views

PWM using XC8 compiler and peripheral libraries

I am trying to run the most simple example of PWM using a PIC18F4550, XC8 compiler and the libraries plib/timers.h and plib/pwm.h My code is the next: ...
3
votes
2answers
638 views

Define Pins For Use By a Library xc8

I've got some code i'd like to use in multiple projects so i'd like to put it into a library The library will use no special features of the chip and whichever two pins it uses to do its job only ...
1
vote
0answers
328 views

Turning on a led using PIC18F4550 and XC8 compiler

I am trying to run the simple hello world program for a PIC18F4550 using the XC8 compiler. I am really new on pic microcontrollers. My code is the next: ...
0
votes
1answer
170 views

Why is MPLABX reporting the wrong amount of program memory used?

I've been using XC8 v1.34 for a while, and since v1.41 got released I upgraded to that version instead. Just for the sake of nothing-ness, I recompiled a mature project and saw that the value under "...
0
votes
1answer
1k views

How to display variables in LCD using PIC18 and XC8 compiler

I am trying to display a variable in an LCD. I am using a PIC18F4550 and I am compiling with XC8. My code is the next: ...
1
vote
1answer
342 views

undefined symbols for structs on compile MPLab XC8 on pic16F872

I'm receiving the undefined symbols error on XC8 for two struct arrays declared as externs in file io.h. Why is this happening? ...
2
votes
1answer
1k views

XC8's Microchip compiler long type doesn't go up 32bits value

I need a big number in my firmware, So i choosed long for the job. In the microchip's documents the long type provides 4Bytes for use: So i created this variable (timeCounter): In a interrupt of ...
1
vote
0answers
217 views

Writing Scheduler/RTOS in XC8

I have an interest in writing a scheduler/RTOS project in XC8 using an enhanced MCU with access to the hardware stack. I am trying to figure out how to control the creation of the software stacks so ...
2
votes
2answers
1k views

Deciding which compiler for PIC18F26K22 in MPLAB X, C18 or XC8?

I'm trying to program a microprocessor for the first time, and having lots and lots of doubts. I have installed both the C18 and the XC8 compilers, plus a few others. When I create a new project and ...
2
votes
1answer
593 views

Confusion about #pragma in XC8

I'm currently programming a pic16f18323. I'm using MPLAB X. And XC8 as the compiler. I just want to ask if pragma configurations can be shown as ('110' is the binary representation of 3 bit RSTOSC ...
2
votes
2answers
882 views

Writing SSPBUF from variable in I2C slave protocol in PIC18

I am migrating this question from StackOverflow to this forum because I believe it is more adequate. I am writing an I2C slave routine for PIC18F25K80 and I am stuck on a weird problem. This is my ...
1
vote
0answers
103 views

EEPROM in Simulator for Microchip Pic18f

When programming a Microcontroller from Microchip using Pic18F and using XC8 Compiler, can i use Simulator to test / verify it ? ...
5
votes
2answers
339 views

XC8 pointer issue

I am struggling with the following code: ...
-1
votes
1answer
200 views

MikroC VS xc8 codes [closed]

I have found this codes for controlling DC motor speed using PWM by connecting two switches to increase and decrease the PWM value. The problem is this codes is in MiKroc and my compiler is XC8. May i ...
0
votes
2answers
1k views

No clock signal on SCL pin of PIC16F1618

I have been trying to configure I2C on PIC16F1618 microcontroller. I am using MPLAB X IDE, along with xc8 compiler. The MSSP code is being generated through MPLAB code configurator. I have set the ...
0
votes
2answers
1k views

PIC16f877A: Working in Debug mode not working in Release mode

I am facing an Issue with my PIC16f877A controller. Its working in Debug mode with PicKit3 connected. But when I program the device for release mode, It gives no sign of working. I am using MPLAB X ...
3
votes
1answer
1k views

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 ...
5
votes
1answer
731 views

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 ...
0
votes
1answer
89 views

How to store modify and resend 4 bytes of data from an assembly coded dspic to that in a c compiler based pic18f

I'm using Xc8 compiler and pic18f.Im communicating with a dspic30f ;coded in assembly and receiving a 4 byte variable via i2c. Task: I have to receive the 4 byte packet store,modify it and send ...
4
votes
1answer
1k views

Using XC8 compiler instead CCS [closed]

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?
2
votes
2answers
699 views

PIC's MSSP SPI = oddity, but bit-banging works?

I'm trying to get a PIC16LF1825 master to communicate with an ADXL362 slave over SPI at 1.8v. First I tried the MSSP (PIC's serial port) configured for hardware SPI @4MHz FOSC, 1MHz SPI rate (...
2
votes
2answers
1k views

Can't get PWM to work on a PIC12F683 using MPLAB XC8

I'm trying to make PWM to work on the PIC12F683. According to my calculations I should get an 8 bit 20kHz PWM at GPIO2, but that does not happen. Instead I get a 5kHz "weird" PWM signal such that when ...
1
vote
1answer
267 views

Why interrupt is not triggered?

When pin RB5 changes between high and low it should trigger interrupt. Interrupt happens when IC gets powered and does not occur afterwards when RB5 gets connected or disconnected from vdd. Why so? I ...
1
vote
1answer
764 views

MPLABX syntax cheker errors in ASM mixed with C

I'm using XC8 for a project in MPALBX using a PIC18F26K80 and I'm getting lots of Unable to resolve Identifier errors in the editor: The code works compiles an ...
0
votes
1answer
2k views

PIC16f877: MPLAB X error 1250 (Could not find space for variable)

I am using Pic16f877 microcontroller for my project. I am trying to declare a char Array as char dataPkt[256] = {0}; While compiling, i received an error ...
0
votes
1answer
108 views

Efficient, Concise PIC C Code Help

I'm fairly new to programming PIC Microcontrollers, but am getting real stuck into it and loving it. Today my little project was to make a 7 segment display count from 0 to 9, multiplexing each ...
1
vote
2answers
2k views

Problem with XC8, RX interrupt [PIC18F4550]

I have a problem with my interrupt and I don't know why. I want to use an interruption each time I receive a data from my RX port. So, I used the interrupt on the port RX of my microcontroller. My ...
2
votes
2answers
3k views

SD card SPI interface for PIC18F25k80

I am using a PIC18f25k80 microprocessor and I want to transfer data on an SD card over SPI. The compiler I am using is MPLAB X XC8. Could you please provide an example of how I can initialise the SD ...
3
votes
3answers
3k views

Using I2C and SPI communication on the same same clock and data lines

I am using a PIC18F25K80 with multiple slave devices. All of them uses I2C except one. What i want to know is that can i first use I2C with the devives that uses I2C and then close I2C, change clock ...
3
votes
1answer
3k views

PIC18 High Priority Interrupt doesn't Interrupt the Low one (xc8)

I was trying to learn and implement the priority property of interrupts on PIC18F46K22 uC. I use MPLABX and XC8 compiler. In my code (transformed from a sample code), I have one external interrupt (...