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
1 vote
1 answer
61 views

PIC16F1825 trouble with simple increment MPLAB XC8

I have set myself up with on a breadbord with a simple PI16F1825. I am using MPLAB x with XC8 V2.45 i have a led that turn on/off every second using the simple delay function. i would just like to ...
old_fool's user avatar
0 votes
1 answer
44 views

Why can't I drive pin RA4 low on PIC16F1823?

I am using PIC16F1823 MCU. Pin RA4 is a multipurpose pin but can be used as I/O. But I cannot find which settings are required to achieve this. I've tried to disable all unrequired peripherals ...
RickyBoy's user avatar
1 vote
2 answers
75 views

Not having a PORTAbits.RAx on ISR breaks my code

I'm working on a 433MHz RF reciver code for a PIC16F628A using a cheap 433MHz receiver. The catch here is that I'm only able to use RA4 for the RX, and because of that i had to use timer2 (because the ...
fpp's user avatar
  • 159
0 votes
1 answer
93 views

How can I create variables like registers?

I'm currently working on a small home alarm system that runs on the PIC16F628A microcontroller. It's not the first time I came to a project with the idea of using my own custom created registers that ...
fpp's user avatar
  • 159
0 votes
1 answer
98 views

Interfacing HD44780 LCD with PIC16F690 in C (XC8 compiler)

I am trying to interface a PIC16F690 with a HD44780 LCD module, in 4-bit mode. My connections are as follows: ...
Al2110's user avatar
  • 103
1 vote
0 answers
142 views

PIC18 I2C EEPROM interface SEN stuck high

I'm trying to get a PIC18F46K40 I2C interface to work with a M24M01-D EEPROM, however I'm having problems where my code is checking for the I2C bus to be idle before initating a start condition using ...
Dan Twining's user avatar
3 votes
0 answers
60 views

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 ...
Chris Aung's user avatar
2 votes
1 answer
151 views

PIC18F4550 USART transmission keeps repeating

I used the following code to send out an USART asynchronous transmission of a string "AT\n\r" using a PIC18F4550. ...
Chris Aung's user avatar
6 votes
2 answers
655 views

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 ...
Chris Aung's user avatar
1 vote
1 answer
141 views

Retry function - I2C hung state handling PIC XC8

This may be a very borderline Stack Overflow question, but I decided to post here because I'm dealing with the I2C protocol for a PIC MCU in XC8. I'm learning how to talk with devices over I2C and it'...
ezra_vdj's user avatar
  • 600
0 votes
2 answers
90 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 ...
chuackt's user avatar
  • 609
-1 votes
1 answer
177 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 ...
K.Azizollahi's user avatar
1 vote
1 answer
296 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 ...
K.Azizollahi's user avatar
0 votes
1 answer
141 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 ...
Omar and Lorraine's user avatar
0 votes
0 answers
237 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 ...
ted9090's user avatar
  • 11
1 vote
0 answers
117 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 ...
Chris Aung's user avatar
1 vote
1 answer
420 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. ...
karthikkk's user avatar
1 vote
1 answer
146 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 ...
Nathaniel Murphy's user avatar
0 votes
3 answers
848 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 ...
John123's user avatar
  • 19
0 votes
0 answers
139 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 ...
RukshanJS's user avatar
  • 149
1 vote
1 answer
465 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 ...
Dan Twining's user avatar
0 votes
1 answer
217 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 ...
Cerezo's user avatar
  • 314
0 votes
1 answer
154 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 ...
Geo's user avatar
  • 213
0 votes
1 answer
202 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. ...
Geo's user avatar
  • 213
1 vote
3 answers
551 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 ...
Geo's user avatar
  • 213
1 vote
1 answer
423 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. ...
Geo's user avatar
  • 213
1 vote
1 answer
2k 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. ...
Geo's user avatar
  • 213
0 votes
1 answer
350 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. ...
Geo's user avatar
  • 213
0 votes
1 answer
1k 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 ...
Geo's user avatar
  • 213
1 vote
0 answers
112 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 ...
JonesyH's 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 ...
Harry Beadle's user avatar
3 votes
1 answer
865 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 ...
Harry Beadle's user avatar
4 votes
1 answer
109 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. ...
Decapod's user avatar
  • 3,910
1 vote
0 answers
114 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 ...
Daniel's user avatar
  • 907
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 ...
be-ee's user avatar
  • 395
3 votes
3 answers
2k 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 ...
anrieff's user avatar
  • 5,371
0 votes
1 answer
645 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 ...
nerdsley's user avatar
  • 105
2 votes
1 answer
242 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 ...
Mr.MD's user avatar
  • 46
-1 votes
1 answer
337 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/ ...
Alan 's user avatar
  • 11
0 votes
2 answers
1k 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 ...
Wall-E's user avatar
  • 103
1 vote
0 answers
116 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 ...
TheSoulkiller's user avatar
0 votes
0 answers
781 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 ...
Decapod's user avatar
  • 3,910
1 vote
3 answers
619 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 ...
Abel Tom's user avatar
  • 435
0 votes
1 answer
443 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-...
bos's user avatar
  • 950
0 votes
1 answer
713 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 ...
ChicoDaMan's user avatar
2 votes
1 answer
459 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°, and illuminate a series of ...
btommo's user avatar
  • 21
1 vote
0 answers
477 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 ...
Sreez..'s user avatar
  • 23
1 vote
1 answer
266 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. ...
Sreez..'s user avatar
  • 23
1 vote
1 answer
718 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-...
Arturo Rosete's user avatar
3 votes
1 answer
4k 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: ...
Dau's user avatar
  • 515