We are doing some experiments with QNX where we want to setup a timer to
fire every 600Hz. With the 1 millisecond timing resolution this seems to be
impossible. Even when we simulate a 500Hz process (2 ms), and we have
nothing else running except procnto, the system will occassionally fire a
late pulse (3 ms between pulses).
Is there anyway to improve this besides designing a hardware timer to go on
the bus?
“Chris Rose” <chris.rose@viasat.com> wrote in message
news:a21prf$oh3$1@inn.qnx.com…
We are doing some experiments with QNX where we want to setup a timer to
fire every 600Hz. With the 1 millisecond timing resolution this seems to
be
impossible. Even when we simulate a 500Hz process (2 ms), and we have
nothing else running except procnto, the system will occassionally fire a
late pulse (3 ms between pulses).Is there anyway to improve this besides designing a hardware timer to go
on
the bus?
Increasing priority of process/pulse will help. Also read the 2 timer
articles
on qdn.
Getting 600Hz is a problem since thats 1.66666666 ms. The minimum resolution is 500us. You could try to set the timer resolution via ClockPeriod to 1.666 but I
m not sure how out will get round up by the kernel & hardware
resolution.
Hi,
this is possible with the Real-Time-Clock (RTC → IRQ8) of your PC.
Below are the setup routines … you have just to write an interrupt
handler for the IRQ8. That interrupt thread should return a pulse which
can trigger your thread every 244us e.g.
Regards
Armin
http://www.steinhoff-automation.com
/*
- SetupRTC()
*/
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();
}
/*
- RestoreRTC()
*/
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();
}
Chris Rose wrote:
We are doing some experiments with QNX where we want to setup a timer to
fire every 600Hz. With the 1 millisecond timing resolution this seems to be
impossible. Even when we simulate a 500Hz process (2 ms), and we have
nothing else running except procnto, the system will occassionally fire a
late pulse (3 ms between pulses).
Is there anyway to improve this besides designing a hardware timer to go on
the bus?