Re: Is it possibe to generate interrupts from OS timers ?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Well, using a timer interrupt specifically assigned on your hardware to that
operation is the best you can do, then. To assure that the overall system
is going to be real-time with respect to what your control system needs,
you, in my opinion of course, absolutely need to build a custom OS for the
device and have control over the interrupt handling process yourself. I'd
say, again in my opinion, that you can't build a successful system without
the information from the BSP vendor.

Remember that, if the BSP doesn't allow installable ISRs, you can't do them
on your own. In that case, you'll have to fall back on multimedia timers
and live with any skew over time. This is not the right way to start
building a system that is going to control mechanical systems. It may be
time to take a step back and think about changing boards, too. At least you
have all the source for the CEPC BSP (from Microsoft, of course, which you
may not like), so that would be one possibility. VIA also has BSPs for many
x86-based boards from them. Other vendors would certainly be able to tell
you if their BSP for a given board supports installable ISRs.

I think you've just made a bad choice of board vendor (or you've not tried
very hard to get answers to your questions)...

Paul T.

"CY" <CY@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:4FA3F71C-FF01-4A2A-B0D7-72BC419F5F48@xxxxxxxxxxxxxxxx
Hi,

Thanks for the advice. Actually, my motors cant generate interrupts, but i
need to send them signals to tell them what position to move to every
15ms.
This is the part which is quite critical for the functioning of my
manipulator.
The problem is that i am on a tight budget so i cant afford the support
from
the makers of the bsp, guess i have to look into installable ISRs for my
solution.

Cheers

"Paul G. Tobey [eMVP]" wrote:

Then why don't your motors generate interrupts at suitable times? It
sounds
to me like your hardware design is flawed. I don't think that you can
safely expect the software to make up for that. If it were me, I'd get
the
source code for the BSP and take suitable steps to add code to the ISR to
actually handle the motor interrupts, least interrupt latency, best
real-time performance. If this is a really important project, then you
should be working closely with whomever did the BSP for your hardware, so
that should not be a problem. You can't expect to build a hard real-time
system by cobbling together bits and pieces that were not specifically
designed to do what you're after, particularly if you don't even have the
code to make changes to the interrupt structure.

As previously mentioned, you may be able to use an installable interrupt
handler to do the interrupt handling, but whether or not you can do that
depends on support from your BSP developer, so you *MUST* be in contact
with
them to accomplish this or at least decide if you can accomplish it.

Paul T.

"CY" <CY@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:B6ADAED5-F5D3-4CC1-B977-A6A26FA6640F@xxxxxxxxxxxxxxxx
Hi,

Sorry about not saying what i am trying to do. Basically, i am trying
to
implement a controller for a manipulator using the PXA270. I need
thread
that
run 10ms/15ms to read some sensors and send signals to my motors. This
is
why
i am so concerned about getting hard real time performance.

I think i read before that the Windows Multimedia timer cannot
guarantee
realtime behavior....but not sure how true that is...

Cheers,
CY

"Paul G. Tobey [eMVP]" wrote:

What is your specification, then? And, why are you concerned by the
absolute time accuracy of repeated calls?

Remember, it's a *multimedia* timer, so it's designed to be used in
situations where you'd hear and/or see problems, if they occurred. No
doubt, if you're going to use it to make an atomic clock, it's not the
right
method, but we really know nothing at all about what you're trying to
do,
so
about all you can expect is the throwing out of various possibilities.
If
you tell us *what* you're trying to do, rather than how, you'll get an
answer that doesn't require so much back and forth for us to learn
what
you're actually after.

Paul T.

"CY" <CY@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:3D8B52DF-223F-43DD-9CE6-34DB78BDCD2C@xxxxxxxxxxxxxxxx
Hi,
Dean --
I am a bit worried that the 1ms resolution would mean that we would
have
error accumulated as the application runs. From what i see, the
other
way
to
implement what i want would be to use Sleep(), which doesnt seem
very
real
time to me. The use of timer interrupts seems to give the best
guarantee
for
my real time application.


<ctacke> --
Thanks for the suggestion. What would the implementation be like if
i
use
a
multimedia timer ? Why would it be less risky ?

Cheers,
CY

"<ctacke/>" wrote:

With your requirements I'd think a multimedia timer would do what
you
want
with a lot less work and a lot less risk.


--

Chris Tacke, eMVP
Join the Embedded Developer Community
http://community.opennetcf.com


"CY" <CY@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:323E0B94-D464-4AB3-9BAA-98E7FC0F8492@xxxxxxxxxxxxxxxx
Hi,

After taking your advice and looking at the source codes, i
managed
to
get
a
simple 10 second timer from the OS timers with the code below.
(Going
to
make
it 10ms later)
Is this the right way to do it ? Is there a better way to do it ?

Cheers,
CY


if(pOSTIMER_Regs=MapRegister(OSTIMER_BASE))
{
pOSTIMER_Regs->oier|=0x020;
//set bit in OSSR on match for timer 5

pOSTIMER_Regs->osmr2[1]=0x0A;
//set the match register as 2

pOSTIMER_Regs->omcr[1]=0x00CB;
//settings for counter 5

pOSTIMER_Regs->oscr[1]=0x00;
//initialize counter to start the counter


//Settings for timer 5
}


//************************************
// General Interrupt Handling Section


// Create an Event to wait on
hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
if ( hEvent == NULL)
printf("Failed to create event\n");
else
printf("Create event successful\n");


dwIrq = 7;
// 7 is the peripheral id for OS Timers

// Get the SYSINTR that corresponds to dwIrq

if (!KernelIoControl(IOCTL_HAL_REQUEST_SYSINTR, &dwIrq,
sizeof(DWORD),
&dwSysIntr, sizeof(DWORD), NULL))
printf("Failed to get SYSINTR\n");
else
printf("Get SYSINTR successful\n");

printf("SYSINTR:%p\n",dwSysIntr);
printf("dwIRQ:%p\n",dwIrq);

// Link our Event with the SYSINTR
if ( !InterruptInitialize(dwSysIntr, hEvent, NULL, 0) )
printf("Failed to link event with SYSINTR\n");
else
printf("Link Event with SYSINTR successful\n");

while(running)
{
// Wait for Event (Interrupt)
if (WaitForSingleObject(hEvent, INFINITE) == WAIT_OBJECT_0)
{

pOSTIMER_Regs->ossr|=0x020;
//Set the bit to reenable the interrupt

printf("Done %d\n",count);
count++;
if(count>2)
break;
InterruptDone(dwSysIntr);
}
}

InterruptDisable(dwSysIntr);

if (!KernelIoControl(IOCTL_HAL_RELEASE_SYSINTR, &dwSysIntr,
sizeof(DWORD),
NULL, 0, NULL))
printf("Failed to release SYSINTR\n");
else
printf("Release SYSINTR successful\n");


UnMapRegister((void*)pOSTIMER_Regs);



"Bruce Eitman [eMVP]" wrote:

Try using WaitForSingleObject or Sleep and give you thread a
very
high
priority. See if that doesn't satisfy your requirements.

--
Bruce Eitman (eMVP)
Senior Engineer
beitman AT applieddata DOT net

Applied Data Systems
www.applieddata.net
An ISO 9001:2000 Registered Company
Microsoft WEP Gold-level Member

"CY" <CY@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:CB46E425-E62C-40F1-B2D4-73B01A0FC98F@xxxxxxxxxxxxxxxx
Well....i am trying to use the OS Timers to generate timed
interrupts
so
that
i can have my threads to run exactly every 15 ms/20ms (in real
time). I
cant
seem to find other ways to do this in real time for windows
ce.
Secondly i think i need to figure out the interrupts to use
other
stuff
like
DMA and I2C.
Regarding the support....unfortunately i m a very poor
developer
who
is
unable to afford it....thus i have to figure stuff out for
myself
=(

Cheers.

"Bruce Eitman [eMVP]" wrote:

Maybe we should back up and ask what are you really trying
to
do?
Why
do
you have to this yourself? Toradex offers support and BSPs
for
their
boards, are they unwilling or unable to assist you?

I know of other board vendors, like Applied Data Systems,
that
can
provide
you with APIs to use the timer interrupts. But first, we
should
figure
out
if you really need them, so again what are you really trying
to
do?

--
Bruce Eitman (eMVP)
Senior Engineer
beitman AT applieddata DOT net

Applied Data Systems
www.applieddata.net
An ISO 9001:2000 Registered Company
Microsoft WEP Gold-level Member

















.



Relevant Pages