This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Cannot get KBD interrupt to work - 89LPC922

Hi, can someone help point me in the right direction. I have a simple program that takes push button inputs and then sends them by IR led link to a receiver. It uses the printf function to drive the LED and the KBI on P0 for the p/button inputs.

The program compiles ok and the printf works if I do a printf("rtrt") just before entering the main loop where the program is supposed to sit until a KBI is detected. Problem is I cannot trigger the interrupt. Additionally, I get an L16 'unused code, ignored for . . . etc' message for the interrupt service routine. So, I think that the compiler or linker is not seeing the isr. I don't think its a hardware issue. I've checked wiring and voltage level changes on the P0 pins.

Any thoughts on this?

thanks

Jason

Parents
  • Do not print in the ISR - just do the absolute minimum you can get away with there.

    You define a constant here:

    #define bat 32
    

    How many bits are you extracting here?

      command = (P0 & 32); /* save the button status and
    

    Remember how many bits you extracted before - how many case statements are possible?

      switch (command) /* one of the input buttons was pushed - execute the command */
      {
         case power: printf ("pwr\n");
         case mute: printf ("mute\n");
         case vup: printf ("vup\n");
         case vdn: printf ("vdn\n");
         case sel: printf ("sel\n");
         case test: printf ("test\n");
      }
    

    And what do you think happen after printf("pwr\n") - if we ignore the fact that you should not use printf() in the ISR unless someone have proven to you that printf() is reentrant and that your processor is fast enough to take a detour through one of the largest functions in the RTL.

Reply
  • Do not print in the ISR - just do the absolute minimum you can get away with there.

    You define a constant here:

    #define bat 32
    

    How many bits are you extracting here?

      command = (P0 & 32); /* save the button status and
    

    Remember how many bits you extracted before - how many case statements are possible?

      switch (command) /* one of the input buttons was pushed - execute the command */
      {
         case power: printf ("pwr\n");
         case mute: printf ("mute\n");
         case vup: printf ("vup\n");
         case vdn: printf ("vdn\n");
         case sel: printf ("sel\n");
         case test: printf ("test\n");
      }
    

    And what do you think happen after printf("pwr\n") - if we ignore the fact that you should not use printf() in the ISR unless someone have proven to you that printf() is reentrant and that your processor is fast enough to take a detour through one of the largest functions in the RTL.

Children
No data