Combining two projects

If you have a simple question and just want an answer.
tomshannon
Member
Posts: 10
Joined: Fri Jan 29, 2016 10:00 pm

Combining two projects

Post by tomshannon »

Hey all,

I'm currently working on a project that involves combining two projects together. I'm trying to combine the ADC startKIT example from XMOS and the sc_sdcard project from github. I'm trying to make a data acquisition system, however I have been struggling with combining the two. I've referenced both projects to each other, however whenever ever I try to include a header file at top, it tells me that there are several errors in the header files themselves, even though I have never touched them. All libraries are included, but I am still having trouble when I build. I have attached a compressed folder with the projects together. I was wondering if anyone could help me. I'd appreciate it greatly. I've been struggling with this for a while.

Tom
User avatar
xsamc
Active Member
Posts: 55
Joined: Fri Mar 04, 2011 3:38 pm

Post by xsamc »

tomshannon wrote: I have attached a compressed folder with the projects together.
Hi Tom,

I'm not seeing an attachment on your post, so I'm not sure what you've done so far ;)

Have you modified the par statement of your applications main method to call the sdcard task?

Cheers,
Sam
tomshannon
Member
Posts: 10
Joined: Fri Jan 29, 2016 10:00 pm

Post by tomshannon »

Hey Sam,

Oops, I'm sorry. I have attached it to this message now.

However, yes I have tried including it in the par statement in main for the ADC startkit example. In the file I attached here I was trying to incorporate the header files to the sd_card program. When trying to build this project, it seemed that it was saying that files I included were not able to compile for some reason.

Also, if I were to make the main of the sc_sdcard a function would it work in the ADC main -- I'm not quite sure if that needs to be a combinable function?

I'm sorry if I seem like such a newbie here. I'm quite inexperienced and I'm just trying to learn the ropes. I would appreciate any help you could give.

Thanks so much,

Tom
You do not have the required permissions to view the files attached to this post.
tomshannon
Member
Posts: 10
Joined: Fri Jan 29, 2016 10:00 pm

Post by tomshannon »

I have been playing around with it some more and have come across a similar error. When adding in the "ff.h" header file from the sc_sdcard project in my workspace, I get several pointer type errors. I've attached photos of me putting in the "ff.h" file into the StartKit ADC example and it seems to read in the file fine, but again it just gives me several errors of unsafe pointers.
You do not have the required permissions to view the files attached to this post.
User avatar
xsamc
Active Member
Posts: 55
Joined: Fri Mar 04, 2011 3:38 pm

Post by xsamc »

tomshannon wrote: However, yes I have tried including it in the par statement in main for the ADC startkit example. In the file I attached here I was trying to incorporate the header files to the sd_card program. When trying to build this project, it seemed that it was saying that files I included were not able to compile for some reason.

Also, if I were to make the main of the sc_sdcard a function would it work in the ADC main -- I'm not quite sure if that needs to be a combinable function?
Sorry, I had forgotten that the API for the sc_sdcard component is a set of synchronous functions, rather than an asynchronous task that needs to run in parallel to the application using it - because of this there is no need to add any SD card task to your main par, simply call the SD card functions from one of the tasks already run from the par.

For example, if you were to extend the "AN00177_startKIT_adc_demo" program, you could add the calls to the SD card functionality to the "app()" function.

There is no need to start trying to use combinable functions yet - you should still have plenty of logical cores spare on the startKIT to run more tasks from the par should you need to (each tile has 8 cores, the startKIT has 1 tile that you can use). Combinable functions are an optimisation which allow multiple tasks to share one core on the chip.
tomshannon wrote:I have been playing around with it some more and have come across a similar error. When adding in the "ff.h" header file from the sc_sdcard project in my workspace, I get several pointer type errors. I've attached photos of me putting in the "ff.h" file into the StartKit ADC example and it seems to read in the file fine, but again it just gives me several errors of unsafe pointers.
This sounds like you're heading in the right direction, but you're discovering the differences between C and xC pointer types. sc_sdcard was written before xC had pointer support, hence not supporting the required types.

The quickest way to get around this issue is probably to add a layer of "xC friendly" wrapper functions written in C (these functions should not take any pointer arguments), which then call into the FatFs functions passing the required pointers etc.
If you would prefer a pure xC solution you can look into updating the ff.h header file - either avoid exposing pointers which will not be needed in your xC application (using the #if __XC__ guard), or add xC compatible prototypes which use unsafe pointers (e.g. FRESULT f_open (FIL * unsafe fp, const TCHAR * unsafe path, BYTE mode)). You will then have to call these functions from within an "unsafe { }" block in xC.

Cheers,
Sam
tomshannon
Member
Posts: 10
Joined: Fri Jan 29, 2016 10:00 pm

Post by tomshannon »

Thanks for all the great advice. It seems as though most of my errors are going away, but I have come across one last major obstacle. I included a wrapper function I made into the app() function in main, so that it will be called in the main par, but I am getting two errors that state:

xmap: Error: Symbol SDif[0].ClkBlk1 is a duplicate clock declaration.
xmap: Error: previously declared as gpio_ports.clk.

Do you know what this means? I've tried changing the clock assignment in the main.xc and it still seemed to give me this error.

I've attached some photos below for reference.
You do not have the required permissions to view the files attached to this post.
tomshannon
Member
Posts: 10
Joined: Fri Jan 29, 2016 10:00 pm

Post by tomshannon »

All right, I have compiled this program and everything seemed to work, only with caveat: I got one error stating:

Error: Undefined reference to '_Sadc_task_0'

I'm not quite sure what this error means.

Even after making a function wrapper and inputing this into the "app()" function, I have come to this error. It has something to do with this adc_task function and I am not quite entirely sure why it's having trouble working.

I've attached some photos for reference.
You do not have the required permissions to view the files attached to this post.
User avatar
xsamc
Active Member
Posts: 55
Joined: Fri Mar 04, 2011 3:38 pm

Post by xsamc »

tomshannon wrote:All right, I have compiled this program and everything seemed to work, only with caveat: I got one error stating:

Error: Undefined reference to '_Sadc_task_0'

I'm not quite sure what this error means.

Even after making a function wrapper and inputing this into the "app()" function, I have come to this error. It has something to do with this adc_task function and I am not quite entirely sure why it's having trouble working.

I've attached some photos for reference.
Hi Tom,

Looking at the screenshots I'm not sure what's causing the undefined reference to _Sadc_task_0.
Could you tried removing ".core[0]" from the line that starts the adc_task() in the par to see if it resolves the issue?
I'm happy to have a go at getting it to build if you're OK with attaching your source files.

Cheers,
Sam
tomshannon
Member
Posts: 10
Joined: Fri Jan 29, 2016 10:00 pm

Post by tomshannon »

Hey Sam,

Thanks for all the help! I really appreciate it.

I have attached a zip files with all the files and build modules that I am using in my program. The "tom.h" header file is the wrapper function for the sd_card.

Thanks for taking a look!

Tom
You do not have the required permissions to view the files attached to this post.
User avatar
xsamc
Active Member
Posts: 55
Joined: Fri Mar 04, 2011 3:38 pm

Post by xsamc »

tomshannon wrote:Hey Sam,

Thanks for all the help! I really appreciate it.

I have attached a zip files with all the files and build modules that I am using in my program. The "tom.h" header file is the wrapper function for the sd_card.

Thanks for taking a look!

Tom
Hi Tom,

Did removing ".core[0]" from the line that starts the adc_task() in the par help?

The source as supplied in the zip won't build for me because of the duplicate module_FatFs at the top level btw.