Page 2 of 2

Re:Delay

Posted: Wed Oct 02, 2002 1:46 pm
by beyondsociety
I have a question about tim robinsons C code he provided.

When I try to compile the example, I get a

'out' : undeclared identifier

What is the problem?

Heres the code:

/*! \brief Sets up the PC's programmable timer to issue interrupts at HZ
* (100 Hz) instead of the default ~18.2 Hz.
* \param hz The required clock frequency, in hertz
*/
void i386PitInit(unsigned hz)
{
unsigned short foo = (3579545L / 3) / hz;

/* Reprogram the 8253 timer chip to run at 'HZ', instead of 18 Hz */

out(0x43, 0x36); /* Channel 0, LSB/MSB, mode 3, binary */
out(0x40, foo & 0xFF); /* LSB */
out(0x40, foo >> 8); /* MSB */
}

Re:Delay

Posted: Wed Oct 02, 2002 1:56 pm
by Tom
you need this in your code before the delay:

__inline__ void out(unsigned port, unsigned val)
{
   __asm__ __volatile__("outb %b0,%w1"
      :
      : "a"(val), "d"(port));
}