Delay

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
beyondsociety

Re:Delay

Post 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 */
}
Tom

Re:Delay

Post 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));
}
Post Reply