Nnamdi Kohn wrote:
Hello,
we are about to develop a demonstrator for a motion control system on a QNX
PC. In this system we have to set up a control cycle with a much higher
cycle frequency than 1/10ms (100Hz), which seems to be the default timebase
using QNX.
-
As it is the case that increasing basetime-ticks per second leads to
greater operation system overhead (reduction of user application
performance), what basetime resolution range would be reasonable on a 3GHz
Pentium processor? Is a timebase with a resolution of e.g. 10 or 100
microseconds conceivable using the ClockPeriod() function and PULSEs or
SIGNALs?
-
Is there any other possibility to get a “tick” in the user application,
apart from using the QNX timers together with the standard timebase?
Yes, use the RTC (IRQ8).
Here is the code for the RTC handling:
const struct sigevent *
IRQ8handler(void *area, int id)
{
InterruptDisable();
(void) out8(CMOS_ADDR, 0x0c); // Prepare to read register C
(void) in8(CMOS_DATA); // Read register C to clear interrupts
InterruptEnable();
return (&TimerEvent); // TimerEvent triggers the application …
}
/*
void SetupRTC( unsigned short tr )
{
int reg ;
InterruptDisable(); // hopefully no NMIs …
(void) out8( CMOS_ADDR, 0x0A ) ; /* init to read RTC status register A /
reg = in8( CMOS_DATA ) ; / Read RTC status register A */
InterruptEnable();
reg &= CMOS_ADDR; /* save bit 6… bit 4 of status register A */
reg |= tr; /*tr 3 = 122us /
/ 4 = 244us /
/ 5 = 488us /
/ 6 = 976us /
/ 7 =1953us /
/ 8 =3906us */
InterruptDisable();
(void) out8( CMOS_ADDR, 0x0A ); /* init to update RTC status register A /
(void) out8( CMOS_DATA, reg ) ; / set tick intervall */
InterruptEnable();
InterruptDisable();
(void) out8( CMOS_ADDR, 0x0B ) ;/* init to read register B /
reg = in8( CMOS_DATA ) ; / Read it */
InterruptEnable();
reg |= 0x40 ; /* enable IRQ 8 */
InterruptDisable();
(void) out8( CMOS_ADDR, 0x0B ) ;/* init to update register B /
(void) out8( CMOS_DATA, reg ) ; / Update register B */
InterruptEnable();
/*
- On some machines there may be dangling interrupts following
- the POST test. Clear any dangling interrupts here.
*/
InterruptDisable();
(void) out8( CMOS_ADDR, 0x0c ) ;/* Prepare to read register C /
(void) in8( CMOS_DATA ) ; / Read register C to clear interrupts */
InterruptEnable();
}
/*
void RestoreRTC( void )
{
int reg ;
InterruptDisable();
(void) out8( CMOS_ADDR, 0x0B ) ;/* init to read register B /
reg = in8( CMOS_DATA ) ; / Read register B */
InterruptEnable();
reg &= 0xBF ; /* Clear interrupt enable bit of IRQ 8*/
InterruptDisable();
(void) out8( CMOS_ADDR, 0x0B ) ;/* init to update register B /
(void) out8( CMOS_DATA, reg ) ;/ Update register B */
InterruptEnable();
InterruptDisable();
(void) out8( CMOS_ADDR, 0x0C ) ;/* init to read register C /
(void) in8( CMOS_DATA ) ; / Read reg. C to clear any interrupts */
InterruptEnable();
}
Regards
Armin Steinhoff
http://www.steinhoff-automation.com
E.g. is
the ClockCycles() function somehow usable for cyclic notification of a user
application?
Thank you.
Nnamdi