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
2 answers
71 views

Why my timer1 not working?

My purpose is to measure phase angle between 2 square wave as below(yellow represent voltage ZCD and blue represent current ZCD passing through ACS712 hall effect current sensor) Below is my circuit ...
user avatar
  • 563
-1 votes
1 answer
61 views

XC8, need help. RC3 is holding micro in reset mode

I am trying to write a program for PIC18LF14K50 using MPLAB X and XC8 compiler. So far everything was working fine, but as soon as I set RC3 (input) to 0 and go back to 1, the pic goes into a frozen ...
user avatar
1 vote
1 answer
60 views

PIC18, XC8 compiler, enable multiple interupts

I am trying to make a module that needs to communicate over USART module, and also, do some tasks on a timer basis. (1ms / 30sec / 2 minutes) Now I need to enable USART interrupt and enable a 1ms ...
user avatar
0 votes
1 answer
89 views

Does XC8 have a particular way to set or clear GPIO pins?

I'm using MPLAB X and XC8 to compile a simple project for the PIC16F886. To manipulate the GPIOs, what I'm doing is ...
user avatar
  • 404
0 votes
0 answers
70 views

Why my pic18f458 send 0x00 by uart after recived a byte from pc?

I wish to know is you can help. I'm trying to comunicate by rs485 a pic18f458 and my PC, like it show the image. This is what I want to happen: Send a byte from PC to microcontroller. The ...
user avatar
  • 11
1 vote
0 answers
87 views

Could a PIC18 running two functions simultaneously?

I am building a robotic car with stepper motors (for wheels) and infrared sensors(avoiding obstracles) using PIC18F4550 microcontroller. So, I have created a function to drive the stepper motor steps ...
user avatar
1 vote
1 answer
180 views

External interrupt debugging with PIC16F877A

I am working with a PIC16F877A on a simulator on MPLABX 5.35 with XC8 compiler ver 2.32. I am trying to understand and work with the external interrupt, I am facing a few issues while debugging. ...
user avatar
1 vote
1 answer
79 views

PIC10F200 OPTION Register constants not present in header files

I'm brand new to any microcontroller programming and am playing around with the PIC10F200. I'm using MPLAB X 5.45 with XC8 2.32 pic-as compiler and I saw that most of the registers have constants ...
user avatar
0 votes
3 answers
406 views

How to write simple text or display image on the SSD1322 OLED display

As anyone been successful to display a simple text or a grayscale image to the OLED display using the SSD1322 controller like the Newhaven Display 25664? I have managed to initialize the display using ...
user avatar
  • 19
0 votes
0 answers
84 views

NodeMCU AT Commands with UART not working

Hi, here are my specs :- PIC16F877A microcontroller NodeMCU (reflashed and got AT commands working via software only) XC8 Compiler (using MPLAB X IDE) Question :- What I'm trying to do is, trying to ...
user avatar
  • 149
1 vote
1 answer
299 views

PIC Microchip TCP IP Lite Stack on 8bit Microcontroller

I'm trying to learn about ethernet communication on a PIC micro following application note AN1921 however I'm getting compilation errors which seem to imply that the Microchip TCP/IP Lite Stack ...
user avatar
0 votes
1 answer
108 views

XC8 compiler: Same variable names across different C source files causes issues

I am currently working with a PIC18F25k80 device using the XC8 compiler and MPLABX. I spent the whole of yesterday trying to debug some code I ported from a PIC32 micro project. This code did not ...
user avatar
  • 304
0 votes
1 answer
84 views

how to shifted phases in PWM with PIC18F4431

I am trying to design a driver for a BLDC motor. I have managed to generate 6 PWM signals with the PIC18F4431. But I don't know how I can shifted the phases. I attach my code and the image of the ...
user avatar
  • 93
0 votes
1 answer
103 views

PIC16F887 PWM multiple output

I am trying to design a control for a BLDC motor with a PIC16F887. I have managed to activate a PWM output and be able to vary it with a potentiometer. The point is, I need to get 6 PWM signals out. ...
user avatar
  • 93
1 vote
3 answers
137 views

Activate 3 or more PWM signals in PIC

I am doing a PWM with the PIC18f4550 and it managed to do it. But only activate an output by varying the value of CCP1CON. What I want to achieve is to have three PWM outputs and then be able to ...
user avatar
  • 93
0 votes
1 answer
281 views

MPLAB X XC8 error expression is not assignable and invalid digit 'F' in octal constant

I am programming a PIC16F887 with MPLAB X, the compiler is XC8 v2.10 and the hardware tool is PICkit3. When compiling the program I get these errors in the following constants of the program. ...
user avatar
  • 93
0 votes
1 answer
697 views

Error interrupt funcition with MPLAB X v5.30 XC8

I am programming a pic18f4550. When I try to compile the project I get two errors. According to what the console indicates, they are caused by the following function. ...
user avatar
  • 93
0 votes
1 answer
203 views

Making PWM with analog input control in PIC18F4550

I am trying to program with the PIC18F4550 a PWM with which I can regulate the duty-cycle with a variable resistance. I attach my code to explain the problem I have. ...
user avatar
  • 93
0 votes
1 answer
569 views

PIC18F2550 [PIC18] PC=0x0000 MCLR is low. Processor is in reset

I am learning to program microcontrollers. I'm trying to simulate the result in Proteus but when I run the simulation I get the error. [PIC18] PC=0x0000 MCLR is low. Processor is in reset. What is ...
user avatar
  • 93
1 vote
0 answers
87 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 ...
user avatar
  • 23
3 votes
2 answers
2k 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 ...
user avatar
3 votes
1 answer
612 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 ...
user avatar
3 votes
1 answer
81 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. ...
user avatar
  • 3,850
1 vote
0 answers
104 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 ...
user avatar
  • 847
11 votes
3 answers
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 ...
user avatar
  • 377
3 votes
3 answers
1k 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 ...
user avatar
  • 4,907
0 votes
1 answer
389 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 ...
user avatar
  • 105
2 votes
1 answer
193 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 ...
user avatar
  • 46
-1 votes
1 answer
307 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/ ...
user avatar
  • 11
0 votes
2 answers
911 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 ...
user avatar
  • 103
1 vote
0 answers
96 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 ...
user avatar
0 votes
0 answers
591 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 ...
user avatar
  • 3,850
1 vote
3 answers
565 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 ...
user avatar
  • 435
0 votes
1 answer
358 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-...
user avatar
  • 900
0 votes
1 answer
620 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 ...
user avatar
2 votes
1 answer
367 views

PIC16F1783 inclinometer project using Accelerometer 12-bit ADC issue

I am working on an inclinometer project using an accelerometer, a MMA1220KEG and a PIC16F1783. It is designed to switch a relay when the angle of inclination is below 15 degrees and illuminate a ...
user avatar
  • 21
1 vote
0 answers
394 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 ...
user avatar
  • 23
1 vote
1 answer
212 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. ...
user avatar
  • 23
1 vote
1 answer
600 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-...
user avatar
3 votes
1 answer
3k 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: ...
user avatar
  • 525
3 votes
2 answers
955 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 ...
user avatar
1 vote
1 answer
531 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: ...
user avatar
  • 525
0 votes
1 answer
359 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 "...
user avatar
  • 900
0 votes
1 answer
2k 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: ...
user avatar
  • 525
1 vote
1 answer
493 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? ...
user avatar
2 votes
1 answer
2k 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 ...
user avatar
1 vote
0 answers
268 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 ...
user avatar
3 votes
2 answers
2k 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 ...
user avatar
2 votes
1 answer
1k 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 ...
user avatar
  • 339
2 votes
2 answers
1k 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 ...
user avatar