All Forums
 Microsoft Windows CE
 General CE
 Spawning Threads
 Forum Locked
 Send Topic to a Friend
 Printer Friendly
Author Topic  

rbhalla

13 Posts

Posted - 06 Jun 2002 :  13:04:02  Show Profile  Email Poster
I am trying to create a highest priority thread. Here's the code
HANDLE hThread = CreateThread(NULL, NULL, toggleTask, NULL, 0, &toggleID);
CeSetThreadPriority(hThread, 0); // highest priority
CeSetThreadQuantum(hThread, 1); // 1ms quantum

The function toggleTask simply toggles an IO pin at 50ms

But the task can not keep up. The scope output which should be a nice square wave is awful. The task is pre-emptied by everyone, running internet explorer, doing a dir on the cmd window or simply closing a window.

Am I missing something?

ctacke

877 Posts

Posted - 06 Jun 2002 :  13:56:03  Show Profile  Email Poster
Raj,

While the thread you are creating is a high-priority thread, it is calling into the ADSmartIO AVR code, which is not designed for high speed or high precision data work.

You can get significantly better results using one of the I/Os available through a port like this:

HANDLE hPort;
BYTE state;
DWORD dwSize = 1;

// open port
hPort = CreateFile(_T("IOA1:"), GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);

state = 0;
WriteFile(hPort, &state, 1, &dwSize, NULL);

while(true)
{
// toggle port
state ^= 1;
WriteFile(hPort, &state, 1, &dwSize, NULL);

// sleep
Sleep(50);
}


Though this will be far more deterministic than using the ADSmartIO libraries, it will still be subject to fluctuation due to preemptive system calls.

Depending on what your specific needs, an IST or even a hardware solution may be necessary to get the precision you are after.

-----------------
Chris Tacke, eMVP
Applied Data Support
Go to Top of Page

ctacke

877 Posts

Posted - 06 Jun 2002 :  14:05:24  Show Profile  Email Poster
In a quick test on my bench, it looks like typical jitter for the WinCE port code is 5-10ms. For the ADSmartIO, it can be even upward of 200ms.

-----------------
Chris Tacke, eMVP
Applied Data Support
Go to Top of Page

rbhalla

13 Posts

Posted - 06 Jun 2002 :  15:19:10  Show Profile  Email Poster
5-10 Millisecond jitter is definetly nowhere close to real time.
Go to Top of Page

ctacke

877 Posts

Posted - 13 Jun 2002 :  10:04:11  Show Profile  Email Poster
If you require less variance than what you are seeing using the WinCE port, then you must use some other method for handling your toggle. You can achieve much better results (like those seen in the the real-time white paper) by writing an ISR using the Board Support Package and Platform Builder.

Additionally, the ADSmartIO controller code could be re-written to handle your needs.

If you contact us directly and give us a better idea of your exact requirements, we can help you determine which path will provide the best solution.

-----------------
Chris Tacke, eMVP
Applied Data Support
Go to Top of Page

Tim

39 Posts

Posted - 08 Aug 2002 :  11:21:04  Show Profile  Email Poster
Is the Board Support Package and Platform Builder available? I understood that ADS does not make this available?

Go to Top of Page

ctacke

877 Posts

Posted - 08 Aug 2002 :  12:10:30  Show Profile  Email Poster
ADS typically does not provide the BSP to our customers. We promote our products as being "application-ready" and feel that for a vast majority of our customers a sBSP is unnecessary.

Using Platform Builder is not always a simple and straightforward process, and we take on that process ourselves, sparing customers the problems and expense of doing so. However, for production-level customers, we can provide object-level or even source-level BSPs if it is necessary. Contact our Sales department if you feel you may need a BSP for your project.

Additionally, we are not a Platform Builder reseller. To get Platform Builder, visit this site.

-----------------
Chris Tacke, eMVP
Applied Data Support
Go to Top of Page
  Topic  
 Forum Locked
 Send Topic to a Friend
 Printer Friendly
Jump To:
Eurotech Support Forums © Eurotech Inc. Go To Top Of Page
This page was generated in 0.03 seconds. Snitz Forums 2000