nanosleep compiler error

Technical questions regarding the xTIMEcomposer, xSOFTip Explorer and Programming with XMOS.
tank_zinatra
Member
Posts: 8
Joined: Fri Mar 26, 2010 2:46 am

nanosleep compiler error

Postby tank_zinatra » Fri Mar 26, 2010 3:15 am

Hi,

I'm using nanosleep from <time.h> and it's generating a linker error.

I tested other functions from <time.h> and they work just fine.


Building target: nokia6100.xe
Invoking: XMOS Mapper
xcc -L/Applications/XMOS_9.9.2/target/lib/xs1b -o "nokia6100.xe" ./bitmap.o ./main.o ./nokia6100.o ./pcf8833.o ./sync.o ../XC-1.xn
../sync.c: Error: Undefined reference to 'nanosleep'
xmake: *** [nokia6100.xe] Error 1

Code: Select all

#include <time.h>
#define SAMPLE_DELAY 41.6666667

void sync_xmos_bb()
{
	struct timespec t = {0, SAMPLE_DELAY};
	nanosleep( &t, NULL );
}
Any help appreciated!
User avatar
paul
XCore Addict
Posts: 169
Joined: Fri Jan 08, 2010 12:13 am

Postby paul » Fri Mar 26, 2010 6:39 pm

Using time.h for delays is probably not the way to go when using an XS-1 device (though I don't know why it doesn't seem to be implemented!).

Delays can very easily implemented in XC like this:

Code: Select all

void delay(unsigned ticks) // 1 tick = 10 ns with default device settings
{
   timer t;
   unsigned ts;

    t :> ts; // get time
    t when timerafter(ts+ticks) :> int _;

}
This function can easily be called from C files if you need.

Hope that helps!
Paul

On two occasions I have been asked, 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question.
tank_zinatra
Member
Posts: 8
Joined: Fri Mar 26, 2010 2:46 am

Postby tank_zinatra » Fri Mar 26, 2010 6:46 pm

Thanks Paul.

I'd prefer to do that, but the delay I have is fractional (e.g. 41.6667 ns). I'm working with embedded LCDs and I need that exact timing.

I noticed that the configure_clock_rate() takes two ints to specify a fractional frequency. Maybe I'll try to figure out how it's doing that.
User avatar
paul
XCore Addict
Posts: 169
Joined: Fri Jan 08, 2010 12:13 am

Postby paul » Fri Mar 26, 2010 7:04 pm

You won't be able to get that level of resolution. I would expect that the LCD would have a working tolerance that would allow a delay of 40ns or maybe even 50ns. Working to that sort of picosecond margin is largely impractical with anything that is not incredibly expensive!

I don't know the specifics of your device, but would advise you checking through the datasheets for the maximum and minimum tolerances.

Also, 40ns sounds like a clock - so I would suggest not generating the signal in this way. The XS-1 XCore architecture has the ability to generate clock signals using the clock blocks.

An example of driving LCDs using clock ports is available in the Programming in XC book which available as a PDF.

Also, I notice from your XE file name you are attempting to drive a Nokia 6100 screen. A project doing this is available here: http://www.xcore.com/projects/nokia-610 ... controller
Paul

On two occasions I have been asked, 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question.
tank_zinatra
Member
Posts: 8
Joined: Fri Mar 26, 2010 2:46 am

Postby tank_zinatra » Fri Mar 26, 2010 7:23 pm

hey paul,

thanks for all your help. I ended up discovering the clocking functions last night. Like you said, makes much more sense to use them.

The nokia6100 project is what I'm using. It's been really helpful as I was previously driving these LCDs with arduino/atmel. Apart from the XS specifics, the code is identical to what I was using before.

I'm building a prototype of a semi-flexible mobile phone. 8 Nokia screens arranged in a 2x8 grid on a flexible substrate. We do a lot of work with new types of interfaces. http://hml.queensu.ca

david

Who is online

Users browsing this forum: No registered users and 0 guests