View Single Post
  #7   Spotlight this post!  
Unread 03-02-2005, 15:38
PVC Pirates PVC Pirates is offline
Programmer
#1058 (PVC Pirates)
Team Role: Programmer
 
Join Date: Sep 2004
Rookie Year: 2004
Location: Londonderry, NH
Posts: 7
PVC Pirates is an unknown quantity at this point
Send a message via AIM to PVC Pirates Send a message via MSN to PVC Pirates
Re: strange warning when build program

Adding the "void" in the parentheses prevented all but one of the warnings. Before the addition, every time a function from user_common.c was called, I would get the warning. Now i only get the warning when I call the initialization function.

I am going to post the code on the assumption that I can trust the users of this site to not steal my ideas unless they have already thought of it on their own. Please do not make this assumption incorrect.

The user_common.h is as follows:

#ifndef __user_common_h_
#define __user_common_h_
/************************************************** *************/
extern unsigned char rc_dig_in03last;
extern long tmpcount;
extern int inturrupt;
/************************************************** *************/
void init_HallEffect(void);
void updateSpeed(int pwmL, int pwmR);
void setLastPWM(void);
void handleHallEffect(void);
long getCountLeft(void);
long getCountRight(void);
/************************************************** *************/
#endif

I tried using extern before each function but it had no effect.
Here is user_common.c:

#include "user_common.h"
#include "ifi_aliases.h"
#include "ifi_default.h"

int prevL, prevR, currL, currR; /*used when determining
which direction to count when changing the count in update speed,
init_hallEffect and setLastPWM */

unsigned char lastPWMLeft, lastPWMRight, lastPORTB; /*used to find
change in sensors, and keep track of direction*/

long countLeft, countRight; /*used to keep track of increments
sensed by the hallEffect sensors*/

unsigned char rc_dig_in03last;
long tmpcount;
int inturrupt = 0;
/************************************************** *************/
void init_HallEffect(void)
{
/*init wheel counts to 0 each*/
countLeft = 0;
countRight= 0;
/*first initialization of PORTB*/
lastPORTB = PORTB;
/*init for prev left and right pwm values*/
prevL = 129;
prevR = 129;
digital_io_03 = 1;
digital_io_04 = 1;
INTCON2bits.RBPU = 0;
tmpcount = 5;
rc_dig_in03 = 0;
rc_dig_in03last = rc_dig_in03;

/*inti inturrupt flag bit enabled*/
INTCONbits.RBIE = 1;
}
/************************************************** *************/

/************************************************** *************/
/*here comes the code to set lastPWMLeft/Right.*/
void updateSpeed(int pwmL, int pwmR)
{
currL = pwmL;
currR = pwmR;
}
/************************************************** *************/

/************************************************** *************/
void setLastPWM(void)
{
if (currL != 128)
{
lastPWMLeft = currL;
prevL = currL;
}
else
{
if (prevL > 128)
{
lastPWMLeft = 200;
}
else if (prevL < 128)
{
lastPWMLeft = 50;
}
}
if (currR != 128)
{
lastPWMRight = currR;
prevR = currR;
}
else
{
if (prevR > 128)
{
lastPWMRight = 200;
}
else if (prevR < 128)
{
lastPWMRight = 50;
}
}
}
/************************************************** *************/

/************************************************** *************/
/*inturrupt code*/
void handleHallEffect(void)
{/*left sensor = rc_dig_in03, right = rc_dig_in04: left = bit 4,
right = bit 5*/
unsigned char thisPortB, change;
thisPortB = PORTB & 0b00011000;
change = thisPortB ^ lastPORTB;
switch(change)
{
case 0: break;
case 48:
{
if (lastPWMLeft > 128)
{
countLeft ++;
}
else if (lastPWMLeft < 128)
{
countLeft --;
}
if (lastPWMRight > 128)
{
countRight ++;
}
else if (lastPWMRight < 128)
{
countRight --;
}
break;
}
case 16:
{
if (lastPWMLeft > 128)
{
countLeft ++;
}
else if (lastPWMLeft < 128)
{
countLeft --;
}
break;
}
case 32:
{
if (lastPWMRight > 128)
{
countRight ++;
}
else if (lastPWMRight < 128)
{
countRight --;
}
break;
}
}

}
/************************************************** *************/

/************************************************** *************/
long getCountLeft(void)
{
return countLeft;
}
/************************************************** *************/

/************************************************** *************/
long getCountRight(void)
{
return countRight;
}
/************************************************** *************/

I apologize if it is difficult to read. Code does not paste well into these windows.

Here is where the functions are used:

In user_routines.c:
in User_Initialization:
{
...
init_HallEffect();
}

in Default_Routine
{
inside the #if and #else statements where the pwm values are set...
right at the end of each block: updateSpeed();
after that for testing purposes: I put a printf displaying the count values recieved from getCountLeft() and getCountRight();
}


in user_routines_fast.c
in InturruptHandlerLow()
{
inside the section that checks INTCONbits.RBIF and INTCONbits.RBIE...
setLastPWM();
handleHallEffect();
}


Even with the void in the parentheses, I still get the warning about init_HallEffect(); at the location where it is called.
Besides that, the display is always zero for both sensor counters. Does anyone see a problem that I missed? user_common.h and user_common.c are direct copy and paste. The locations of the calls are description mostly. If anyone has any questions, feel free to ask. I will try to answer them.

Thank you all.

P.S. I am sorry about the length of this post.

Last edited by PVC Pirates : 03-02-2005 at 15:41. Reason: added apology