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 ...
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 ...
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 ...
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 ...
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 (<...
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 ...
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 ...
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 ...
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.
...
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
...
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 ...
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):
...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 "...
2
votes
Accepted
PIC16F887 PWM multiple output
Your Controller has got only 2 PWM outputs. The PIC16F1783 could maybe help you.
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 ...
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)....
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 ...
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 ...
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 ...
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 ...
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 ...
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 (...
Only top scored, non community-wiki answers of a minimum length are eligible