Skip to main content
22 votes
Accepted

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

The problem is not with your type but with the way you print it. In C %d format specifier is for int, not for ...
Eugene Sh.'s user avatar
  • 10.1k
20 votes
Accepted

Variable declaration with @ in C

This is to specify an absolute address to place the variable at. From the XC8 compiler manual page 27, section 2.5.2 Absolute Addressing: Variables and functions can be placed at an absolute ...
Eugene Sh.'s user avatar
  • 10.1k
14 votes

How can I implement regular expressions on an embedded device?

Since you wrote your own answer, it's clear that you wanted to promote a particular solution. In a more general sense, the standard C regex library is for both ...
Dave Tweed's user avatar
  • 178k
11 votes
Accepted

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

64-bit datatypes are available to use but you must use the following flags when compiling: --std=C99 --ext=cci This makes the compiler use the C99 standard with ...
Harry Beadle's user avatar
10 votes
Accepted

PIC18F4550 CPU appear to be not running at external crystal frequency

With the PIC running at 20MHz, and each instruction being 4 crystal clock cycles, this gives an instruction clock rate of 5MHz (or 200ns). It takes 1 instruction cycle to change the output to high (<...
Tom Carpenter's user avatar
6 votes

Variable declaration with @ in C

@ is a common non-standard extension to the C language which allows you to declare a variable at a specific address. It can be used for memory-mapped hardware ...
Lundin's user avatar
  • 22.3k
6 votes

PIC18F4550 CPU appear to be not running at external crystal frequency

This is your code: 7FF2 8E8A BSF LATB, 7, ACCESS 7FF4 F000 NOP 7FF6 9E8A BCF LATB, 7, ACCESS 7FF8 EFF9 GOTO 0x7FF2 From datasheet, we see that ...
jonathanjo's user avatar
  • 16.2k
5 votes
Accepted

PWM using XC8 compiler and peripheral libraries

I have solved my question. The problem is that I was using the 1.40 version of XC8 compiler. The periperial libraries are not longer supported and were compiled with version 1.34 of MPLAB XC8. Any ...
Nau's user avatar
  • 525
5 votes

How can I implement regular expressions on an embedded device?

Although it could be possible to get the library to compile with xc8, I had better luck using re2c, which is a utility that uses special syntax in your source file to produce a FSM that runs a regex. ...
Harry Beadle's user avatar
4 votes
Accepted

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

You seem to be using an SSD1306 oled. (worth mentioning!) To get such a display to life, you must initialize it. The sequence I use is ...
Wouter van Ooijen's user avatar
4 votes

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

As Roger says, use XC8. It's the newer compiler. The C18 compiler is obsolete and it won't support any newer devices. Another disadvantage of C18 is that it only supports the PIC18 family of ...
m.Alin's user avatar
  • 10.8k
4 votes
Accepted

Error interrupt funcition with MPLAB X v5.30 XC8

In XC8, you need to define interrupts this way (the myISR can be changed to whatever you want): ...
Ron Beyer's user avatar
  • 2,598
3 votes
Accepted

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

R2 is pulling the reset line to ground. Tie R2 to VCC. Although it's weird because you have two different ground symbols in your circuit (or so I think). Another thing you could do is disable the ...
Big6's user avatar
  • 5,784
3 votes
Accepted

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

You ask the question "How to define 14-bit lookup table for PIC/XC8 (if it's possible to do without assembly)?" It is almost possible to do this in XC8 without assembly. Assembly must be used to ...
Dan1138's user avatar
  • 1,389
3 votes

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

C18 is the old Microchip compiler, and XC8 is the new Microchip compiler that they bought from HiTech (or some name like that, anyway, the Aussie compiler). XC8 has the current support and is what ...
Olin Lathrop's user avatar
3 votes
Accepted

undefined symbols for structs on compile MPLab XC8 on pic16F872

There's a difference between declaring a variable and defining it. You've declared that debounce[] and input[] exist somewhere ...
youtooth's user avatar
  • 709
3 votes

PIC18, XC8 compiler, enable multiple interupts

Enable interrupt generation bit for each peripheral in the PIE registers If you need priority for interrupts (which you should) set priority bits in the IPR registers for each peripheral. this way a ...
Tirdad Sadri Nejad's user avatar
3 votes
Accepted

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

You should always write to the latch (LATA4 in this case) and read from RA4, otherwise you can have issues because of the read-modify-write problem with writing to RA4, depending on what is connected ...
Spehro 'speff' Pefhany's user avatar
2 votes

Pre-Defining EEPROM Values in XC8 Compiler

After looking at the above suggestions and and some other searches i came across the following solution. This includes the updates to compiler so I am using MPLABX 5.25 and XC8 v2.1. I used the ...
couchingEngr's user avatar
2 votes
Accepted

Define Pins For Use By a Library xc8

I don't know if that changed recently, but a year ago or two I contacted Microchip technical support who confirmed that XC8 doesn't support libraries as such. What you can do is have the C file in a "...
Szidor's user avatar
  • 437
2 votes
Accepted

PIC16F887 PWM multiple output

Your Controller has got only 2 PWM outputs. The PIC16F1783 could maybe help you.
Mike's user avatar
  • 2,206
2 votes

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

That is perfectly normal under any compiler. By default, if you declare variable X in modules A and B then these will be the same variable, as by default these will have ...
Justme's user avatar
  • 172k
2 votes

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

Look at the example code that you linked to. It has multiple functions that you want, for show font (single character), show string, show pattern, and the demo functions (pushes a black and white bmp)....
Passerby's user avatar
  • 73.4k
2 votes
Accepted

Retry function - I2C hung state handling PIC XC8

The answer involves a Timer 2 to keep track of timing, and loops to give the ability of restarting from the beginning. The main send function is now grouped in a while(1) loop to allow multiple ...
ezra_vdj's user avatar
  • 628
2 votes

Not having a PORTAbits.RAx on ISR breaks my code

This is almost certainly a classic race condition bug. Whenever you have a GPIO register and using the pins for unrelated purposes, you can never write to that register from both an ISR and the main ...
Lundin's user avatar
  • 22.3k
2 votes

Does anyone know if there is a way to increase the power of the PIC16F pin using MPLABX?

There should not be any difference in pin behaviour between compilers. XC8 emits a BSF PORTB, 0x4 and I assume Mikro would do the same if you used PORTB.B4 rather than PORTB.B5. The delays you have ...
Spehro 'speff' Pefhany's user avatar
2 votes

Does anyone know if there is a way to increase the power of the PIC16F pin using MPLABX?

The problem was the lack of GND on the TM1637. Before removing the PIC16F876A to place the ATmega328P, I reconnected the TM1637. Then the PIC was programmed with MPLABX and the pin signal was as in ...
user3394963's user avatar
1 vote

Sequential I2C read from MPU6050 with PIC16F18877 different from expected

Order of evaluation is not defined by standard. It is up to the compiler how it implements this. Refer to the compiler manual if it can be changed. I highly doubt it is changeable. Besides, it would ...
Justme's user avatar
  • 172k
1 vote

Variable declaration with @ in C

A short extension: This is no longer working since xc8 2.0 and up. You now had to write: unsigned char serv_ctr __at(0x0002); to put a variable (...
Mike's user avatar
  • 2,206

Only top scored, non community-wiki answers of a minimum length are eligible