Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

0
votes
1answer
44 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 ...
1
vote
2answers
40 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
94 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
160 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
55 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
184 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
1answer
205 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
191 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 ...
0
votes
1answer
156 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
325 views

XC8 compiler with linker to own libraries

I have tried to set linker to My own Folder with my libraries. In folder are only .c file and i set location in "Include directories": But when I compile my project it says : ...
0
votes
0answers
205 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
143 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
291 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-...
2
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
418 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
228 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
112 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
846 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
209 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
178 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
393 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 ...
3
votes
2answers
671 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
85 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
267 views

XC8 pointer issue

I am struggling with the following code: ...
-2
votes
1answer
173 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
616 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
614 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
932 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
214 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
544 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
102 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
2k 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
2k 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 (...
2
votes
1answer
1k views

XC8 Interrupt function qualifier

Referring to the XC8 user manual, DS50002053E, section 2.5.10.3 the following is stated: For 8-bit compilers, change any occurrence of the interrupt qualifier e.g., from: ...
1
vote
3answers
7k views

convert Unsigned Int to array of chars (String)

EDIT: I am using this for programming a pic, so the C will be quite limited. The compiler is XC8. Following function expects me to pass a string: ...
3
votes
1answer
1k views

Inserting compile date/time into the code in XC8

I'm in the process of writing code for a real time clock, and I want to compile the code with constants for the date/time of compilation to burn onto the clock immediately upon programming. I believe ...
1
vote
1answer
3k views

Does any MPLAB compiler e.g XC8 have built in functions to control PIC peripherals like in CCS PIC C

The CCS compiler provides a lot of built-in functions to access and use the PIC microcontroller's peripherals. This makes it very easy for the users to configure and use the peripherals without going ...
2
votes
1answer
210 views

Ohmmeter not working as expected

I am trying to build a simple ohmmeter by creating a voltage divider and then using an analog pin on a PIC18F2550 to read the output voltage and determine the ohmic value of one of the resistors. I ...
0
votes
1answer
639 views

12 bit ADC conversion simple code not working as expected

I posted a couple days ago a couple of functions that I wrote to do 10-bit ADC. the problem is I couldn't figure out what was wrong with my code so I wrote a much simpler single function that does a ...
2
votes
2answers
770 views

PIC - ADC - Negative value? - Wrong settings?

I'm trying to read an analog input with my PIC18F66K22 using ADC. But the supposingly 10-bit value often comes to values like 63.241. I found out that a negative value (printing as unsigned) results ...