|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
I have created a pair of files: user_common.c and user_common.h and added them to the workspace. user_common.h includes user_common.c . Inside user_common.c are several functions I use during an interrupt to read a sensor. all functions in user_common.c are stated in user_common.h with the return type and any parameters in () then followed by a semicolon. In each file where any function from user_common.c is used, user_common.h is included. When I make or build everything, the build succeeds but for each function i used that came from user_common.c, I receive the following error:
" file path : line number : Warning [2058] call of function without prototype ". I have no idea what it means, but the functions don't work. Could this error be a side effect of the problem that is preventing the functions from working correctly? Any help would be appreciated. |
|
#2
|
|||||
|
|||||
|
Re: strange warning when build program
Post the two files for us to check out.
|
|
#3
|
||||
|
||||
|
Re: strange warning when build program
Quote:
Code:
#include "user_common.h"
main
{
foo();
}
void foo(void)
{
// Do something
}
Code:
void foo(void); Quote:
|
|
#4
|
||||
|
||||
|
Re: strange warning when build program
Something to also consider...
If you are using the functions in files other than user_common.c, you will probably have to use prepend the prototype with extern and include user_common.h in those files Code:
extern foo(void); |
|
#5
|
|||
|
|||
|
Re: strange warning when build program
Quote:
![]() |
|
#6
|
|||
|
|||
|
Re: strange warning when build program
Thank you all. I will take another look at the code and try your suggestions and see if they work. I'll let you know what happens.
|
|
#7
|
|||
|
|||
|
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 |
|
#8
|
||||
|
||||
|
Re: strange warning when build program
Quote:
Code:
<code]code goes here</code] Quote:
|
|
#9
|
||||
|
||||
|
Re: strange warning when build program
OK, quick probably stupid question once I get a response. How does one upload their program to the robot? Do we use the IFI Loader the same way as for loading the new firmware or whatever it was? I have code and it debugs ok so I would like to load to the robot. I haven't used this program before (I'm using the Mplad IDE), and last year someone else did programming on the other team I was on. I did the programming previously for 3/4 years with basic so I understand the most part, just don't know how to upload!
-Mike |
|
#10
|
||||
|
||||
|
Re: strange warning when build program
Quote:
|
|
#11
|
||||
|
||||
|
Re: strange warning when build program
Quote:
Thank you, I thought that was it but it seemed odd. Thanks alot. now we can complete our robot. ![]() |
|
#12
|
|||
|
|||
|
Re: strange warning when build program
Quote:
|
|
#13
|
||||
|
||||
|
Re: strange warning when build program
Quote:
Quote:
Quote:
Quote:
|
|
#14
|
|||
|
|||
|
Re: strange warning when build program
Ok. Thanks. If that is the case, then I did include user_common.h in user_routines.c and user_routines_fast.c . I also was not typecasting the variables in the printf statement. I will try that.
|
|
#15
|
|||
|
|||
|
Re: strange warning when build program
Thanks to all who contributed suggestions. The problem has been resolved.
Thanks again PVC Pirates |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Where do you actually build your robot and who does the building??? | Elgin Clock | General Forum | 47 | 14-11-2006 17:50 |
| OCCRA Teams - where do you build? | Phil 33 | OCCRA | 7 | 28-10-2004 21:41 |
| how to add steps in the provided encoder program for the edu | Zaramel2002 | Programming | 3 | 11-02-2004 08:35 |
| warning about taxes | robot180 | Chit-Chat | 3 | 16-10-2003 17:36 |
| Ahh! Program trick confusing! | archiver | 2001 | 9 | 24-06-2002 02:26 |