Subj : Library built but Not working To : borland.public.cpp.borlandcpp From : D Kat Date : Wed Oct 13 2004 02:32 pm Well I managed to put a library together that links into a program and the program happily compiles and runs. Problem is that the program no longer works with the ISR and associated programs in the library. I should be getting displays on an LCD board which I'm not and rather than speech I'm getting just garbage played out. In addition the program will not escape as it should. I have not a clue how I would debug a ISR or a Library..... I suspect that it has something to do with the file opening and reading being done in the main program. Any suggestions? This is using Borland C 3.1F and running on DOS. //*************************Library Routines for Daq802 board plus others #include //disable getvect setvect enable #include #include #include "daq.h" void __interrupt far(*ibmvec)(...); void __interrupt i_service(...); /***********************************************************************/ //======================================================================= // INIT DAQ801 //======================================================================= void daq_init(unsigned short rate) // Daq801 initialize/interrupt set routine { int old_index; // temp index register storage inp(B_EN); // disable DAQ801 & reset all registers! outp(B_EN,0); // enable board by writing to 'B_EN' //============================= old_index=inp(INDEX_REG)&7; // save current contents of index reg. outp(INDEX_REG,INT_SEL); // setup interrupt level outp(INDEX_DAT,IRQ3); // outp(INDEX_REG,old_index); // restore original contents old_index=inp(INDEX_REG)&7; // temporarily disable all interrupts outp(INDEX_REG,INT_CTL); outp(INDEX_DAT,0); outp(INDEX_REG,old_index); //============================= outp (INDEX_REG,TCP); // load Daq801 index reg. with addr. // of the 8254 control port outp (INDEX_DAT,T0_MODE); // load 8254 CP with timer#0 mode outp (INDEX_REG,T0); // point to timer#0 outp (INDEX_DAT,RATE_LB[rate]); outp (INDEX_DAT,RATE_UB_HR); outp (INDEX_DAT,0); //============================== old_index=inp(INDEX_REG)&7; outp(INDEX_REG,INT_CTL); // point to interrupt control register outp(INDEX_DAT,GLOBAL_ENABLE_T0); // enable board,timer#0 interrupts outp(INDEX_REG,old_index); } //========================================================================== // INTERRUPT INITIALIZATION //========================================================================== void interrupt_init(void) { disable(); ibmvec=getvect(DAQ_IRQ3); // get original IRQ3 vector and save it setvect(DAQ_IRQ3,i_service); // set vector to new service routine int temp; temp=inp(0x21); // enable irq7 on 8259 by writing // old mask w/bit#7 anded w/zero outp(0x21,(temp & IRQ3_MASK)); // 0x7f for irq#7 outp(0x20,EOI_IRQ3); // clear any pending 8259 interrupts outp (CP,CW); // write control word to 8255 control port enable(); // re-enable interrupts } //========================================================================== // check if interupt is still running //========================================================================== void check_interupts(void) //check the interrupts { timer[0]=1; while(timer[0]) { delay(1); //gives the timer a count of 1ms (10) before error and reset if(timer[0]) { daq_reset(); } //error! reset DAQ board! } } //========================================================================== // DAQ RESET IF DAQ TIMER HAS STOPPED //=========================================================================== void daq_reset(void) // Daq801 interrupt reset routine { int old_index; // temp index register storage old_index=inp(INDEX_REG)&7; // temporarily disable all interrupts outp(INDEX_REG,INT_CTL); outp(INDEX_DAT,0); outp(INDEX_REG,old_index); //%%%%%%%%%%%%%% old_index=inp(INDEX_REG)&7; outp(INDEX_REG,INT_CTL); // point to interrupt control register outp(INDEX_DAT,GLOBAL_ENABLE_T0); // enable board,timer#0 interrupts outp(INDEX_REG,old_index);//============================== } //========================================================================== // restore original IRQ3 vector routine //========================================================================== void restor_vec(void) { disable(); // temporarily disable interrupts int temp; temp=inp(0x21); // set bit#7 in 8259 mask=1 to disable outp(0x21,(temp | IRQ3_OR)); outp(0x20,EOI_IRQ3); // clear any pending interrupt setvect(DAQ_IRQ3,ibmvec); // restore original vector enable(); // re-enable interrupts } //========================================================================== //interrupt routine with play and button catch //======================================================================= void __interrupt i_service(...)// Daq801 interrupt service routine { disable(); // disable the interrupts int button,i; // button iterator unsigned char PA_buttons,PC_buttons; // temp holding register for current buttons inp(I_STATUS); // read the interrupt status register and clear interrupt for (i=0;i fill buffer } } if (BUTTONFLAG) { PA_buttons=(inp(PA)); // freeze data if (PA_buttons != MASK)// process following path only if one or more { // buttons were pressed! for (button=0;button num) { cout << "y index " << y << " func stimn"; return(0); } temp = ndx[y]; ndx[y] = ndx[x]; ndx[x] = temp; } return(1); } /***********************************************************************/ int r01()//randomly return 0/1 { float ftemp,fr; ftemp = rand(); fr = ftemp/32767; return(fr > .5 ? 0:1); } int stop() { char answer[2]; cout << "\nTERMINATE? "; cin >> answer; if (answer[0] == 'y' || answer[0] == 'Y') return 1; return 0; } .