/* CLK source = 4 MHz */
pio_da16_c1(0x76,0x90,0x01);
/* COUNTER1, mode3, div 400 */
pio_da16_c2(0xb6,0x10,0x27);
/* COUNTER2, mode3, div 10000 */
/* program Cout2 1Hz */
/* note : the 8254 need extra 2-clock for initialization */
for (;;)
{
if ((inportb(wBase+7)&2)==2) break;
/* wait Cout2 = high */
}
/* note : Cout2 = high, INV1 must select the inverted Cout2 */
/* --> INT_CHAN_1 = !Cout2 = init_low, active_high */
outportb(wBase+0x2a,0);
/* INV1 = 0, inverted Cout2 */
now_int_state=1;
/* now Cout2 is high */
outportb(wBase+5,2);
/* EN1 = 1, enable INT_CHAN_1 */
/* as interrupt source */
enable();
}
/* ------------------------------------------------------------------------*/
void interrupt irq_service()
{
if (now_int_state==1)
/* now INT1(Cout2) changed to low */
{
/* --> INT_CHAN_1=!INT1=high now */
+;
/* find a low pulse (INT1) */
if((inportb(wBase+7)&2)==0)
/* INT1 is still fixed in low -> */
{
/* need to generate a high pulse */
outportb(wBase+0x2a,2);
/* INV1 select non-inverted input */
/* INT_CHAN_1=INT1=low --> */
/* INT_CHAN_1 generate high pulse */
now_int_state=0;
/* now INT1=low */
}
else now_int_state=1;
/* now INT1=high */
/* don't have to gen. high pulse */
}
else
/* now INT1(Cout2) changed to high */
{
/* --> INT_CHAN_1=INT1=high now */
+;
/* find a low pulse (INT1) */
if((inportb(wBase+7)&2)==2)
/* INT1 is still fixed in high -> */
{
/* need to generate a high pulse */
outportb(wBase+0x2a,0);
/* INV1 select inverted input */
/* INT_CHAN_1=!INT1=low --> */
/* INT_CHAN_1 generate high_pulse */
now_int_state=1;
/* now INT1=high */
}
else now_int_state=0;
/* now INT1=low */
/* don't have to gen. high pulse */
}
if (wIrq>=8) outportb(A2_8259,0x20);
outportb(A1_8259,0x20);
}
/* -------------------------------------------------------------- */
void pio_da16_c0(char cConfig, char cLow, char cHigh)
/* COUNTER0 */
{
outportb(wBase+0xcc,cConfig);
outportb(wBase+0xc0,cLow);
outportb(wBase+0xc0,cHigh);
}
PIO-DA/PISO-DA Series User Manual (Ver.2.9, Feb. 2011, PMH-009-29 )
65