0

I am wondering if anyone could help me with my 'Undefined Reference' error using XC16 please?

I am including my dsPIC.h file into my main .h file to be brought in to define my chips registers. However when I try and build my code I get the 'Undefined Reference' error on the Registers I try to write to in my .c file.

Error Code

From searching this sub I have seen that it is a linker issue that usually causes this. I am wondering if there is anything obvious I am missing or if anyone has any experience on where I am going wrong!

Any help would be greatly appreciated, thanks!

Here are the compiler and chip options I am given on Simulink from MPLAB blocks:

dsPIC Code Generation Config

Custom Code Import Config

Code Generation Config 2

Compiler Option 1

Compiler Option 2

Gitlab Repository:

https://gitlab.com/poley1/dspic_can.git

If you need the model saving in any other MATLAB release then let me know and I'll add it!

I have also added a build log of a successful build to show what my linker is calling. I think it is:

-Wl,--script="F:\Users\Matt\Documents\MATLABworking\dsPIC33EV_CAN_TEST\p33EV256GM106.gld",-t,--report-mem,-Map=info.map,-cref,-lq-dsp,--memorysummary,memoryfile.xml

Thank you for the help!

the busybee
  • 10,755
  • 3
  • 13
  • 30
  • "Undefined Reference" means that the linker needs a symbol (variable, function) but cannot find it in the libraries or object modules it tries to link into the executable. Solution: locate the symbol and add it (the library or object module) to the linker command line or script. – Paul Ogilvie Jun 25 '20 at 13:37
  • Thanks for the reply, so what I have is a dsPIC header file (p33EV256GM106.h) full of extern declarations and a .gld file that contains a value for all of the declarations in the .h. In "dsPIC Code Gen" pic above I have this gld set as my linker script. I'm just not sure what i'm missing. I will add the .gld and .h to the gitlab to see what I mean... Also what is a .inc file that seems to be alongside the .gld and .h chip file? – user3433445 Jun 25 '20 at 13:47
  • That .inc file is probably an include file for assembler sources, with the same usage as a header file for C sources. You might like to look into it and compare it the the .h file. – the busybee Jun 25 '20 at 14:51
  • @thebusybee Yep just seen that it was the same just for assembler, thanks! – user3433445 Jun 25 '20 at 15:02

0 Answers0