Page 1 of 1

assign output from C?

Posted: Thu Nov 08, 2018 2:52 pm
by jsaksris
How can we assign pin output from .c file?

As the <: syntax is not available.
as well as 'port' / 'on tile[]'

Re: assign output from C?

Posted: Thu Nov 08, 2018 4:37 pm
by mon2
Hi. Rename your source code file to .xc and try again.

Which hardware kit are you using for this testing?

Which port pins are you attempting to drive with an output?

You can review the following:

http://www.xcore.com/viewtopic.php?f=3& ... led#p31562

if using the XCORE Audio board. Hope this helps.

Re: assign output from C?

Posted: Thu Nov 08, 2018 5:03 pm
by jsaksris
What I have found out that if I use a global variable between XC, and C by using extern keyword..
The variable end-up in a different address somehow(found this while debugging).

I have wrote an interface that would change the LEDs based on this value.
Since it's not the in the same address, the change in the value in C does not effect the one in XC.

I was desperate enough to try to change the LEDs directly from C file.. which is the part of the module_usb_audio > endpoint0 > endpoint0.c
I'm using the XCORE Audio board.. I'll dig into your thread tomorrow.

For those ran into this thread look for a way to interact between XC and C file.
you might find this useful.
http://www.xcore.com/viewtopic.php?t=1721

Re: assign output from C?

Posted: Thu Nov 08, 2018 9:09 pm
by akp
If you can rewrite your code in XC or make an XC wrapper for your C code I think you will be happier in the long run. Maybe your XC code can call a C function that returns the LED state or something, rather than using a global variable to talk between XC and C.