Questions tagged [xc16]

XC16 is Microchip's gcc-based compiler suite for PIC24 and dsPIC targets.

58 questions
1
vote
2 answers

Microchip XC16 dsp.h defines incorrect value of PI?

In the XC16 compiler's DSP routines header (dsp.h) there are these lines: /* Some constants. */ #ifndef PI /* [ */ #define PI 3.1415926535897931159979634685441851615905761718750 /* double */ #endif /* ] */ #ifndef…
EBlake
  • 735
  • 7
  • 14
1
vote
1 answer

Memory map shows space allocated to mystery variables _powers_ and _npowers_

I've been looking at the memory map for my code (written in c and compiled by the XC16 compiler), and see significant space allocated to powers, npowers, and dpowers in the .data segment. Does anyone know what this allocation is used for? My code…
EBlake
  • 735
  • 7
  • 14
1
vote
1 answer

c struct passing itself as an argument into a pointer function

I am trying to create a structure with nested functions, that passes the structure itself as an argument into the nested function for simplification of calling functions. The code will be run on a Pic 24f series mcu using the xc16 compiler. Also, I…
user2419860
  • 101
  • 2
  • 11
1
vote
2 answers

Absolute address of a function in Microchip XC16

Device: dsPIC33FJ128GP802 I have some *.s files as follows .global _D1 .section .speex, code _D1: .pword 0x66C821, 0x1B0090, 0xD96C36, 0x9B60B0, 0xDD4E36, 0xBF4E53 .pword 0xD1098B, 0x719BD9, 0x873989, 0x003B69, 0x279035, 0xED4244 .pword…
0
votes
0 answers

PIC24HJ XC16 Linker Script Interrupt Vector Table

I am working on a bootloader for a PIC24HJ series MCU. While going through the linker script I noticed something, tried a google search, searched documentation, GCC linker documentation, I'm out of ideas. Anyway, going through this tutorial, step 13…
nurchi
  • 770
  • 11
  • 24
0
votes
0 answers

Checksum result destination overlaps with checksum range

I'm trying to configure a project with Microchip 16-bit Bootloader. The target MCU is dsPIC33CK512MP608. Ubuntu 22.10, MPLAB X IDE v6.05, latest versions of MCC and all the libraries. Here the memory configuration: I added the macro to be executed…
Mark
  • 4,338
  • 7
  • 58
  • 120
0
votes
0 answers

__eds__ Extended Data Space qualifier syntax

I am using compiler XC16 from Microchip. Are the following code lines equivalent? __eds__ __attribute__((eds)) short fr[N_WAVE]; __eds__ short fr[N_WAVE] __attribute__((eds)); Thanks for the attention.
Guille
  • 326
  • 2
  • 10
0
votes
2 answers

C compiler (X16) warning, but should be an error

if (_1_HOUR < count_value < _2_HOUR) {...} This code snippet generates a warning in MPLAB X (It apparently compiles with the XC16 compiler). But I feel it should be an Error. The correct code (IMHO) is: if ((count_value >_1_HOUR) &&…
Mudge
  • 1
0
votes
1 answer

Ceedling error when trying to compile/link with xc16-gcc

I am trying to implement test driven development for my Microchip embedded system process and am trying to do that via Ceedling (Unity, CMock, etc.). I have been trying to follow along with this tutorial:…
double01
  • 1
  • 1
0
votes
1 answer

XC16 compiler local variable assignment doesn't work

I'm using PIC30F4011 with compiler XC16. I noticed that the assignment of local variable doesn't work, but if I declare the variables to be global it works. In the following function, after the assignment statement: addr = b_flashStart;, the addr is…
Allan
  • 11
  • 1
  • 4
0
votes
1 answer

XC16 Put a data table in PSV memory (PIC)

I want to put a table in Flash and read it directly from my C program. According to Microchip this is done by __attribute__((space(psv))) However, as the most things around microchip, their own examples doesn't work that well (usually obsolete and…
Max Kielland
  • 5,627
  • 9
  • 60
  • 95
0
votes
1 answer

What C standard does XC16 v1.5 use by default?

I can't find a clear answer to what C standard Microchip's XC16 v1.5 compiler use by default (xc16-gcc -> options = empty). We clearly get a different result if we specify it to -std=C99, but from what?!?
Max Kielland
  • 5,627
  • 9
  • 60
  • 95
0
votes
0 answers

Element of structure pointer points to another address in C

I have a structure in C for a motor control application, the structure have the element for a PID. I created 2 variables with that structure and 2 pointers pointing to those variable. My application is on a microcontroller so I have an other…
Philippe
  • 13
  • 5
0
votes
2 answers

Undeclared (First use in function) error / XC16

When selecting the "Build Main Project" and attempting to compile my project, the compiler keeps bringing up these error messages: Source.c:64:8: error: 'RB6' undeclared (first use in this function) I believe it has something to do with my #define…
user13822146
0
votes
0 answers

XC16 Disassembly for (uint32) & (uint32) operation

I am in the process of trying to figure out how many cycles some uint32 operations will take on a 16bit dsPIC. I started with bitwise AND and wrote the following program: int main(void) { unsigned long var1, var2, var3; var1 =…
ChateauDu
  • 23
  • 4