View Single Post
  #10   Spotlight this post!  
Unread 08-03-2006, 18:50
gnormhurst's Avatar
gnormhurst gnormhurst is offline
Norm Hurst
AKA: gnorm
#0381 (The Tornadoes)
Team Role: Programmer
 
Join Date: Jan 2004
Location: Trenton, NJ
Posts: 138
gnormhurst will become famous soon enoughgnormhurst will become famous soon enough
Re: SONAR Sensor Software Driver

Quote:
Originally Posted by MikeDubreuil
I'm glad you like the software. Please let us know how your testing turns out.
A couple of quick questions. I'm installing the code without the benefit of hardware to try it on (that will be in a couple of days).

In your README it says
Quote:
4. Add the following code to the if block in user_routines_fast.c/InterruptHandlerLow()

else if (PIR2bits.TMR3IF && PIE2bits.TMR3IE)
{
Timer_Interrupt_Sonar();
}
I did, and I think I did it correctly (code is below).

But step 3 puzzles me.
Quote:
3.) Add Hardware_Interrupt_Sonar() to the if statement that handles the INT2 pin
in user_routines_fast.c/InterruptHandlerLow()
My attempt to interpret step three also appears in the code below.

Here is my modified InterruptHandlerLow (). The mods are in color.
Code:
#pragma code
#pragma interruptlow InterruptHandlerLow save=PROD /* You may want to save additional symbols. */

void InterruptHandlerLow ()     
{                               
  unsigned char int_byte;       
  if (INTCON3bits.INT2IF && INTCON3bits.INT2IE)       /* The INT2 pin is RB2/DIG I/O 1. */
  { 
    Hardware_Interrupt_Sonar();  ////// <--- added to support sonar
    INTCON3bits.INT2IF = 0;
  }
  else if (INTCON3bits.INT3IF && INTCON3bits.INT3IE)  /* The INT3 pin is RB3/DIG I/O 2. */
  {
    INTCON3bits.INT3IF = 0;
  }
  else if (INTCONbits.RBIF && INTCONbits.RBIE)  /* DIG I/O 3-6 (RB4, RB5, RB6, or RB7) changed. */
  {
    int_byte = PORTB;          /* You must read or write to PORTB */
    INTCONbits.RBIF = 0;     /*     and clear the interrupt flag         */
  }                                        /*     to clear the interrupt condition.  */
  
  // the following added to support sonar:
  //
  else if ( PIR2bits.TMR3IF && PIE2bits.TMR3IE )
  {
      Timer_Interrupt_Sonar();
  }
  else
  { 
    CheckUartInts();    /* For Dynamic Debug Tool or buffered printf features. */
  }
}
Comments appreciated.... including comments on i/o pin conflicts that I'm not noticing... Thanks!
__________________
Trenton Tornadoes 381
2004 Philadelphia Regional Winners
2006 Xerox Creativity Award
---
My corner of the USPTO.
My favorite error message from gcc: main is usually a function
My favorite error message from Windows: There is not enough disk space available to delete this file.