Questions tagged [xc16]

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

58 questions
7
votes
2 answers

GCC error " causes a section type conflict"

Why is there a compiler error when attempting to place two (RAM) variables, which only differ by their initialisation values, into the same section? Problem The C source: int __attribute__((section(".in_my_data"))) _foo = 1; int…
Evil Dog Pie
  • 2,300
  • 2
  • 23
  • 46
6
votes
5 answers

Is the letter "f" necessary if the decimal point is written?

What is the difference between the 2 following code lines? #define F_SAMP 10000.0f #define F_SAMP 10000.0 Aren't both float? (By the way, in this particular case compiler is XC16 but I do not think that matters too much) Thanks for the attention
Guille
  • 326
  • 2
  • 10
6
votes
2 answers

Why is the XC16 compiler removing inline function if the definition comes after use?

In the manual for the XC16 compiler, it says the following: The compiler will only eliminate inline functions if they are declared to be static and if the function definition precedes all uses of the function. At the top of foo.c I declared …
user2211907
6
votes
2 answers

Array doubles in size if a struct defines both its uint16_t words and uint8_t bytes

I have an array each of whose elements could be either uint16_t or a pair of uint8_t. Its elements are defined as a union of a uint16_t and a sub-array of 2 uint8_t. Unfortunately, the compiler (MicroChip XC16) allocates twice as much memory as it…
Davide Andrea
  • 1,357
  • 2
  • 15
  • 39
4
votes
1 answer

What causes this missing whitespace after the macro name error?

I am working on a project in MPLAB X v3.35 for a PIC24F. At some point in the last few weeks the compiler has started giving the following warnings for every line in the compilation. What in the compiler line could be causing this? The column number…
RobbG
  • 371
  • 5
  • 14
3
votes
3 answers

mplab xc8/16 builtin_constant_p

I was searching for this in the mplab compiler users guide but haven't found anything. I am asking it here to confirm that I am not blind or anything: The GCC compiler provides some very interesting and useful built-in functions like…
jwsc
  • 867
  • 8
  • 15
3
votes
2 answers

C: Minimising code duplication using functions in a header file

this is a bit of a strange use case so searching for existing discussion is difficult. I'm programming for embedded systems (Microchip PIC24 using XC16 compiler) and am currently implementing a communication protocol identically across 3 separate…
Zac Soden
  • 31
  • 3
2
votes
1 answer

How to remove unwanted data padding from custom sections on XC16

I am currently trying to dev a firmware for a PIC24F using the whole microchip stack (xc16, mcc, mplab X IDE, etc ...) (not necessarily relevant but i work on a debian 22) Doesn't really matter why but i want to place some data on a specific section…
gokasor
  • 41
  • 5
2
votes
0 answers

Compare and Swap/Exchange on an dsPIC33F with CPSNE instruction

Is there a better way to implement an interlocked variant of "compare and exchange" on a dsPIC33F? unsigned int InterlockedCompareExchange(volatile unsigned int* Destination, unsigned int Exchange, unsigned int Compare) { register unsigned int…
bkausbk
  • 2,740
  • 1
  • 36
  • 52
2
votes
1 answer

What is the limit for delay function we can add for _delay_ms in xc16 in mplab for dspic33ep256mu814 controller?

Can anyone pls explain the max limit to be given for delay "_delay_ms()" identifier in xc16 compiler in MPLAB for dspic33ep256mu814 controller? Thanks in advance.
maxy
  • 31
  • 1
  • 6
2
votes
1 answer

c lang if condition 1 or condition 2 and condition 3 or condition 4

Trying to formulate the correct if condition test. I want to take action only if both floor locks are online (not reporting eStatusLockUnknown). The two tests I've tried are below. When debugging, I can see that both floor locks are reporting…
kward
  • 21
  • 2
2
votes
0 answers

CDC USB on dspic33EP

I'm trying to get my pic to communicate via USB with my PC (MacBook Pro). Here is the schematic for my homemade board, using a dsPIC33EP256MU806: I've adapted microchip's MLA Library, specifically, the cdc_basic firmware. Following are the changes…
tsuo euoy
  • 129
  • 3
  • 10
2
votes
1 answer

GCC extended asm differentiating literal vs register

I find myself extensively using inline asm, and very often want to be able to use a register or a literal in a given bit of asm, however I cannot see how to make this an option with the Microchip XC16 suite. As far as I can tell, you need to…
Mania
  • 1,718
  • 14
  • 16
2
votes
3 answers

Is malloc() under Microchip XC16 guaranteed to produce word-aligned addresses?

The dsPic30/33 and 18E/F parts will produce memory faults if 16-bit accesses are made to memory on odd addresses. When allocating heap memory using malloc(), is the return address guaranteed to be word-aligned? (i.e. even) malloc, you will recall,…
EBlake
  • 735
  • 7
  • 14
2
votes
1 answer

Can't initialize PWM on dsPIC33F

I'm probably just having a can't-see-the-forest-for-the-trees moment with one of these registers, but I can't get the PWM working on the dsPIC33FJ32MC102 microcontroller (warning: big PDF) I'm playing around with. I've followed both the datasheet…
BB ON
  • 251
  • 1
  • 3
  • 15
1
2 3 4