Why do I get an error using a microcontroller library with S-function builder?

9 views (last 30 days)
Hello every one, I am currently working with a microcontroler (dsPIC33) and I am trying to programm it with SIMULINK.
I would like to use the S-function Builder block. I already read the associated documentation and found several examples.
I wish to import a library used by MPLAB for microcontroler's programming. I made a copy of it and managed to import it with the S-function Builder but when I try to use one of the functions (__delay32 for example) I have the following error :
error LNK2001: unresolved external symbol __delay32
Does anyone have tried to do something similar?
Thanks for your help. Helene

Answers (2)

Kaustubha Govind
Kaustubha Govind on 21 Mar 2013
Where is __delay32 defined? Assuming that it is in an external library/source file, you need to add that file to the 'Library/Object/Source files' textbox in the Libraries pane of the S-function Builder Dialog Box.

Helene
Helene on 25 Mar 2013
Thanks for the answer .
Maybe I should explain a little bit more what I am trying to achieve. As I said I am proggramming a microcontroller. I already worked with MPLAB by typing my code and I was using the library libpic30 without any problem. I am now working with Simulink and Lubin Kerhuel "Simulink Blockset Embedded Target microchip devices" . I would like to do my delay instruction without to have to edit the generated code.
I already tried the Taped delay anec Transport delay blocks. They work almost fine BUT I have to enter an initial value for the output. I am more looking for something that just memorized the current value of the signal and pause for a specific amount of time. That is what brought me to the S-function builder bloc.
__delay32 is defined indeed in a external library file, libpic30.h.
I already imported it as you suggested. I found this library file in the XC16 compiler folder from MPLAB but I am programing with simulink on another computer which does not have this version of the compiler.
If it helps the __delay32 function is defined as follow :
extern void __delay32(unsigned long cycles);
But there are no more precisions about the function or about the cycles parameter.
The comments about this .h file does say that: "This file defines useful exports from libpic30.a".
Thanks, Helene
  1 Comment
Kaustubha Govind
Kaustubha Govind on 25 Mar 2013
So it appears that __delay32 is only defined for the microcontroller, but not for a host/PC target? Since the Simulink model runs the S-function on the host machine during simulation, you may want to use an OS-equivalent for __delay32 (or make it a no-op) in the S-function Builder. Then, modify the generated TLC file to call __delay32 instead of its replacement, so that the generated embedded code calls __delay32, but not the S-function itself.

Sign in to comment.

Categories

Find more on Simulink Coder in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!