Message-Id: <3.0.1.32.19970427155949.0068c0b0@giasmd01.vsnl.net.in> Date: Sun, 27 Apr 1997 15:59:49 +0500 To: forum@philipsmcu.com From: "K. Sheker" Subject: 8031-PC Keyboard interface in C What is done: A PC keyboard is interfaced to 8031. The clock line is connected to the interrupt line and data is connected to the data line. On every interrupt (ie clock going low) the data is read and assembled. This is working fine. The program is written in assembly language. What is required: The same program to be written in C. The problem: The clock period is about 60 micro seconds. (It can be anywhere between 50-100 microseconds). When the interrupt is defied in C like Set Vector (This has to be done regardless of whether the actual interrupt service routine is coded in assembly or C) the overhead is about 40 micro seconds leaving only about 20 micro seconds for the actual interrupt processing. What the C does is it pushes and pops psw, Accumulator, DPH, DPL and all the registers R0-R7. This is causing the over head of 40 microseconds. Has anybody done this interface in C. Would greatly appreciate details. Sheker. From: Scott May To: "Philips Forum (E-mail)" Subject: Re: 8031-PC Keyboard interface in C Date: Mon, 28 Apr 1997 08:55:06 +1000 > The same program to be written in C. > The problem: > What the C does is it pushes and pops psw, Accumulator, DPH, DPL > and all the registers R0-R7. This is causing the over head of 40 > microseconds. I've come across this, and what you have to do is have a look at the macro that is defined by set_vector() and replace it with some optimised code. A trivial example follows. In it, Hitech would push only the ACC and PSW, but had the code used other registers, they would have been pushed as well. With Hitech C I replaced the following: ========================= interrupt void timer0_intr(void) { asm(" cpl P1.1"); } ========================== with: ========================== extern void timer0_intr(void); #asm PSECT text,class=CODE GLOBAL _timer0_intr SIGNAT _timer0_intr,88 _timer0_intr: cpl P1.1 reti #endasm ========================== I saved quite a few cycles that way. WARNING: Be very careful about what registers get used in your ISR, now that you're not saving anything!!! sam. ----------------------------------------------------------------- Scott May ( scott@smartdata.com.au ) Smart Data Systems http://www.smartdata.com.au Ph +61 7 3281 8841. Fax +61 7 3281 8114 ----------------------------------------------------------------- Message-Id: <199704281340.IAA27651@serv.brookings.net> From: "Chris Bates" To: "Phillips Microcontroller Forum" Subject: Re - 8031-PC Keyboard interface in C Date: Mon, 28 Apr 1997 08:48:10 -0500 I have done several interfaces with a keyboard in "C". I utilized the DS87C520 microcontroller realizing that I would need the speed. I also cranked up the crystal to 32 MHz. I have tons of info on this subject. Anyone let me know if you need some help. Christopher G. Bates Design/Applications Engineer Daktronics, Inc. cbates@daktronics.com Date: Mon, 28 Apr 1997 03:14:07 +0200 To: forum@philipsmcu.com (Philips Microcontroller) From: Peter Ullrich Subject: Re:8031-PC Keyboard interface in C Subject : 8031-PC Keyboard interface in C From : "K. Sheker" >What is done: > >A PC keyboard is interfaced to 8031. The clock line is connected to the >interrupt line and data is connected to the data line. On every interrupt >(ie clock going low) the data is read and assembled. This is working fine. >The program is written in assembly language. > >What is required: > >The same program to be written in C. > >The problem: > >The clock period is about 60 micro seconds. (It can be anywhere between >50-100 microseconds). When the interrupt is defied in C like Set Vector >(This has to be done regardless of whether the actual interrupt service >routine is coded in assembly or C) the overhead is about 40 micro seconds >leaving only about 20 micro seconds for the actual interrupt processing. >What the C does is it pushes and pops psw, Accumulator, DPH, DPL and all >the registers R0-R7. This is causing the over head of 40 microseconds.> > >Has anybody done this interface in C. Would greatly appreciate details. > >Sheker. You can find the asm-interface in the Philips applications book: Connecting a PC keyboard to the I2C-Bus - just throw away the I2C-routines... Ciao Peter