49 questions
0
votes
0
answers
98
views
read a hex string over UART for PIC Microcontrollers in C using mikroC for PIC
I'm using a PIC18F microcontroller with mikroC PRO for PIC.
The PIC micro reads strings over the UART, which Software implemented because there is only one UART, and I need two.
I'm trying to write a ...
0
votes
2
answers
459
views
MPLAB X IDE code for PIC18F452 microcontroller (indirect addressing)
Using Indirect addressing I'm trying to copy the value 77H into RAM memory locations 50H to 55H. The issue I'm running into is a build error where it says FSR and INDF are not previously defined ...
0
votes
2
answers
2k
views
Programming HEX using MPLAB X IPE v6.15, leads to PIC not starting
When programming my PIC18F6722 using MPLAB IDE v8.91 (the 32bit version), my PIC works and starts successfully, but when I use the HEX generated from MPLAB IDE, but program it using MPLAB X IPE, the ...
0
votes
1
answer
107
views
Unable to resolve identifier RBIE and RBIF, any guess?
trying to compile a code but keep giving build failed and checking red flags shows only Unable to resolve identifier in RBIE and RBIF.
below is the code i have im using it with a pic18f45k50 with a ...
2
votes
1
answer
1k
views
MPLAB gives Low power and device failed to connect error when programming pic18f25q10
I am trying to add a simple led application to a PIC18F25Q10 in another circuit using the Curiosity HPC development board. I am using the MCLR, PGD, PGC and GND pins. Although I set the LVP mode to ...
0
votes
0
answers
123
views
Problem while coding in mplab x ide for pic18f
I am using pic18f and coding on mplab v ide. While compiling the code it's showing that 'RD3' is depricated. What should be the solution to it.
1
vote
2
answers
902
views
Trouble Compiling my Microchip PIC18f4550 USB project using MPLAB X IDE C18 compiler. The compiler keep highlighting "syntax error" and won't compile
I am unable to compile my code using the MPLAB X IDE C18 Compiler. The link below is a link to my printscreen picture of the error.As you can see the IDE said that there is a syntax error at the ...
1
vote
0
answers
403
views
Using C18 compiler on MPLAB X on with Wine
I have been wanting to use the C18 Compiler on MAC OS X for a long while for my MPLAB projects, (so as I can use the mdd library), but it isn't available except for Windows. So I have installed Wine ...
2
votes
2
answers
287
views
Concatenate 5 or more bytes and convert to decimal and then to ASCII
I've this array below:
dataIn[5] = 0x88;
dataIn[6] = 0x2A;
dataIn[7] = 0xC7;
dataIn[8] = 0x2B;
dataIn[9] = 0x00;
dataIn[10] = 0x28;
I need to convert those values to decimal because after that I need ...
0
votes
2
answers
262
views
Microchip C18 send data to Terminal as numeric
I am working on a project on which i need to send data over USART to terminal.
I need to display the data as the numeric value (0-255) of the char (which collected from the EEPROM
i have managed to ...
3
votes
2
answers
557
views
const function parameters in prototypes but not declarations (in C)
When writing code in C, I often include const in function parameter declarations in the function's definition, but not its declaration:
int func(int arg);
...
int func(int const arg)
{
return ...
2
votes
2
answers
2k
views
Using enums and switch in functions (C18 Compiler)
I recently started rewriting a program to make it more easy to understand and I started using enums for describing the different states my program can be in.
byte VoltageLimit(byte progState, word ...
2
votes
2
answers
4k
views
What is the difference between the Microchip XC8 and C18 compilers?
I want further understand the difference between XC8 & C18 compiler.
I know that XC8 is the latest compiler for all 8-bit microchip controllers. e.g. PIC16F, PIC18F. And C18 is the compiler for ...
0
votes
1
answer
1k
views
what is the meaning of __18CXX and __PCB__ in picc codes
I commonly see the following lines of compiler-related codes :
#if defined(__18CXX) ... #endif
and
#if (defined(__PCB__) || defined(__PCH__) || defined(__PCM__)) ... #endif
How can I know the ...
0
votes
1
answer
1k
views
how to assign structures in C18 compiler, MPLAB (ANSI C89)
I am trying to assign values in main program.
typedef struct PointStructure
{ unsigned char x;
unsigned char y;
unsigned char offset;
unsigned char page;
}point;
volatile far ...
1
vote
1
answer
3k
views
C18 Passing a char array to function
I am new to C programming and microcontrollers. I am using a PIC18F24K20 microcontroller with C18. I have it set up to receive information from a computer input using USART transmit and receive ...
0
votes
1
answer
92
views
reading back a float number
I am using microchip c18 and i have this function which splits the float in to 4 respective bytes.And C18 follow little endianess
a[0]=*(fptr); address 0
a[1]=*(fptr+1); 1
a[2]=*...
0
votes
1
answer
148
views
function for eeprom searching
I have an array stored in EEPROM
Starting with {0,0,0,0,1,1,1...} up to 54 elements from address '0'-address'53' and i have cross checked the value and everything is fine.
but when i employ a '...
0
votes
2
answers
658
views
Random Characters in Terminal Emulator
I am currently working on a project to select different outputs based on a text input from a laptop via USB.
What I am currently trying to do is send a character out from my PIC18F1320 to ...
2
votes
2
answers
3k
views
reading pic18 rom constants with C18
I am struggling to understand why I get random data while trying to read from multidimensional table that is stored in rom.
I have a table of bitmap character which I want to display on OLED screen. ...
4
votes
1
answer
8k
views
Char array comparison in C
I have following function to compare two char arrays in C:
short test(char buffer[], char word[], int length) {
int i;
for(i = 0; i < length; i++) {
if(buffer[i] != word[i]) {
...
0
votes
1
answer
91
views
Defining array as global in case of multi file embedded project
I've been trying to declare an array as global in mplab c18 and never found much success. Is there any possible way to access the array elements, or can we declare the array as global /extern and ...
0
votes
2
answers
4k
views
Long Delay using Delay Functions from C18 Libraries for PIC18
I'm using a PIC18 with Fosc = 10MHz. So if I use Delay10KTCYx(250), I get 10,000 x 250 x 4 x (1/10e6) = 1 second.
How do I use the delay functions in the C18 for very long delays, say 20 seconds? I ...
1
vote
1
answer
639
views
C macro syntax error (C18 compiler)
I got a syntax error when trying to compile this macro. I have to use a macro as C18 doesn't support function inlining. Using a regular function call will cause the compiler to have a much bigger ISR ...
1
vote
1
answer
4k
views
Link step can't find symbols (XC8 compiler)
I'm trying to compile and link a C program using the XC8 compiler. I changed from the C18 compiler and made some minor compatibility changes to the code. With C18, the code compiled and linked just ...
2
votes
1
answer
2k
views
Suspcicious pointer conversion warning
I'm compiling my C code using Microchip's C18 compiler. I'm getting a warning [2054] suspicious pointer conversion in this code:
unsigned char ENC_MAADR1 = 0x65;
unsigned char ENC_ReadRegister(...
2
votes
2
answers
1k
views
How does C handle non-booleans in an if statement?
I sometimes see this in a C program (I'm using the C18 compiler):
unsigned char someValue = getSomeDataFromSomewhere();
if (someValue) {
doStuff();
} else {
doOtherStuff();
}
I know what ...
0
votes
2
answers
631
views
Let C18 throw a compiler error
Is there a way to let the C18 compiler throw an own, customized error message during compiling?
For example, consider a situation with two user-defined settings:
#define SETTING_A 0x80
#define ...
3
votes
1
answer
589
views
C18 pseudo variables
I'm looking for a way to make Jalv2-like pseudo variables in C using the C18 compiler. A pseudo variable is something that acts like a variable but actually is a function.
In Jalv2, it's possible to ...
2
votes
1
answer
2k
views
How do I use larger stack size on Microchip's C18?
Ok, I've been trying to solve this issue by my own for long time now, and I simply give up. I've searched through all the web until I couldn't take it anymore and I need help!
I read the whole "C18 ...
0
votes
1
answer
120
views
C18: called function is skipped
Iwould be most grateful if your experts on using the C18 compiler could give me a pointer as to what I am doing wrong.
To become familiar I started a simple thermometer project:-
NTC thermistor --> ...
0
votes
1
answer
400
views
C18: Will the compiler "know" a function call will never return?
I'm building a 16 state FSM on a PIC18 with C18. I'm considering having each state as its own function which jumps to and gets jumped by other states. I'm tempted to just write a branch cases of "...
0
votes
1
answer
479
views
Bit-banged serial on PIC stops working with nested loop in C
Stackoverflow, you've helped me before, I think I need your help again. I'm trying to bit-bang my own serial out using a GPIO on a PIC18F2550. This connects to some shift registers (3x74LS595), where ...
2
votes
1
answer
1k
views
Why ROM String is not being passed correctly?
I am trying to pass a String to a function. I have read a lot about RAM/ROM Strings in C18 and my code seems ok but it is not working. My function is like this:
int setBluetoothName (static const ...
1
vote
0
answers
928
views
PIC 18F87J50 USART Configuration and ISR Troubles
I'm having trouble with a project using a PIC 18F87J50, specifically in my coordination with its 2 USART channels.
There are 2 main problems.
1.) Unable to set target Baud Rate:
I'm using the ...
1
vote
2
answers
1k
views
How to have more than one source file with C18 in MPLAB?
In many languages, such as C++, having lots of different source files is normal, but it doesn't seem like this is the case very often with PIC microcontroller programs -- at least not with any of the ...
3
votes
1
answer
3k
views
Pointer for ROM variable in a RAM variable?
I'm doing a project using the Microchip C18 compiler. I have a struct called a block that points to other blocks (north east south west). These blocks will make me a map.
I then have a pointer that I ...
2
votes
1
answer
796
views
sprintf is outputting some strange data
I am working an embedded project which involves reading/writing a struct into EEPROM. I am using sprintf to make it easy to display some debugging information.
There are two problems with this code ...
0
votes
2
answers
388
views
ORG Function assembly block in C18
Hi there stackoverflow.
I'm working with pic 18f4550 with bootloader.
Because of the bootloader i need to start de code in a specifed address in the memory.
In this case 0x1000 because i dont have ...
1
vote
2
answers
2k
views
C18 Microchip compiler and strcmp function
I want to compare two strings:
The first string is declared above my main:
char _newState[] = "AVAILABLE";
When I want to compare with a const string, i put the line:
if(strcmppgm2ram((const char *)...
11
votes
2
answers
40k
views
Use external header files in MPLAB X IDE
I have a folder with some .h and .c files and I want to use header files in my projects.
I have included them in "Header Files" folder of my project using "Add Existing Item" but when i try to "#...
2
votes
1
answer
2k
views
Linker error in USB HID Code for Microchip PIC (MPLAB/C18)
I'm trying to compile some code for basic USB HID functionality. I'm using a PIC18F14K50 with MPLAB 8.43 and the Microchip C18 compiler.
I'm using some standard files from Microchip's website. Here is ...
2
votes
4
answers
2k
views
Why is this C macro causing syntax error?
This is the first time I'm using macros in C and I'm trying to replace a large section of code that I'd normally place into a function with a macro. This is a part of an interrupt which will be used ...
2
votes
0
answers
771
views
Microchip C18 naked function
Someone knows a way to declare a naked function on C18 compiler?
By naked function I mean function without any epilogue and prologue.
in gcc I use:
__attribute__((naked)) int func(int par1)
Maybe a ...
3
votes
2
answers
296
views
C18: Do unused library functions consume space in EPROM?
Library.h
void Foo1(void); // Unused
int Foo2(int, int); // Used
char Foo3(char); // Unused
main.c
// ...
#include "Library.h"
// ...
void main(void)
{
int ret;
// ...
...
0
votes
1
answer
1k
views
C18: Representation of LONG and FLOAT constants in code
Is a special representation needed for long and float numbers in the code?
In computer programming with C/C++ we put an f letter after a float typed constant number to distinguish it from double type....
2
votes
4
answers
27k
views
parsing ip adress string in 4 single bytes
I'm programming on a MCU with C and I need to parse a null-terminated string which contains an IP address into 4 single bytes. I made an example with C++:
#include <iostream>
int main()
{
...
0
votes
3
answers
2k
views
PIC C18: Converting double to string
I am using PIC18F2550. Programming it with C18 language.
I need a function that converts double to string like below:
void dtoa( char *szString, // Output string
double ...
2
votes
2
answers
3k
views
PIC C18: Reading bits from a byte
I have a very elementary question. However, what ever I tried, I couldn't successfully implement this.
I have a shift register (74LS164) connected to PIC18F2550 with the following hardware ...