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
36 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 ...
0
votes
0answers
69 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 ...
0
votes
1answer
64 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. ...
0
votes
1answer
51 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 ...
0
votes
3answers
173 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 ...
0
votes
0answers
53 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 ...
1
vote
1answer
173 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 ...
0
votes
1answer
84 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 ...
0
votes
1answer
61 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 ...
0
votes
1answer
73 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. ...
1
vote
3answers
85 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 ...
0
votes
1answer
181 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. ...
0
votes
1answer
348 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. ...
0
votes
1answer
110 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. ...
0
votes
1answer
346 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 ...
1
vote
0answers
70 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
472 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
74 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
97 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
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 ...
0
votes
1answer
264 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
1answer
168 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
286 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
798 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
86 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
528 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 ...
1
vote
3answers
489 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
338 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
537 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
329 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 ...
1
vote
0answers
367 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
195 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
540 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
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: ...
3
votes
2answers
867 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
1answer
480 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
317 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
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: ...
1
vote
1answer
448 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
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 ...
1
vote
0answers
256 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 ...
3
votes
2answers
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 ...
2
votes
1answer
960 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
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 ...
2
votes
0answers
121 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
388 views

XC8 pointer issue

I am struggling with the following code: ...
-1
votes
1answer
233 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
2k 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 ...