Jump to content

BagascuW

EstablishedMember
  • Content Count

    10
  • Joined

  • Last visited

Community Reputation

0 Neutral

About BagascuW

  • Rank
    Newbrie
  1. Ok, I get that. But what is this memory location? Is there a way to get its address and use it? Thanks alot. I knew the simplest way, but I want to have button specific code in my button .c and .h files. So the second solution is use-able! I hoped there was a better solution than splitting the defines in port, and number. Just by using 1 define (e.g. #define button portc.5). I quess I'm making things to difficult for myself here. Baga
  2. Hi, I can't find how bitfields are processed by the compiler. How are they stored, and how can I seperate them from its port. I've got the following: /* Button.c */ ... unsigned char buttonPressed(unsigned short port) /* NOT SURE WHAT DATATYPE TO USE */ { unsigned char portName = ?; unsigned char bitNumber = ?; return test_bit(portName, bitNumber); } /* Main.c */ #define button1 portc.5 #define button2 portc.6 .... if(buttonPressed(button1)) { /* Do something */ } So I want to use button names and then check the button to be pressed in de buttonPressed function. But I don't know what datatype to use for containing things like portc.5. Nor do I know how to seperate the portc from the 5th bitfield, so I can use the values for test_bit. I know portc = 0x0007, but what about portc.5? Baga
  3. Bill, Thanks for your reaction. It wasn't clear from my previous post(s), but I'm actually using GNU Make for building my project. I only had a hard time adding the compile $(CC) and link $(LD) commands. Which was basically caused by wrong code in a header file. Thanks for your input anyway, I'm sure other users find this to be usefull and it sure gives me some ideas to improve my makefiles! Baga
  4. Oh, my bad. I didn't know that. I might indeed be mixing up features of different languages This is why we keep learning every day. Thanks for your time and explanation! Baga
  5. Pavel, Thanks for helping me out! I was unaware of the fact function bodies can't be in header files. Some compilers do support that. I've got it all figured out now. Baga
  6. OK, but the o.bj files are compiled to the project directory, so i shouldn't be a problem. But does that means I have to compile *.c files or the *.pp files? When compiling the *.c files I get the error about redefining functions. So it didn't get notice about the #ifndef in Standard_Functions.h. When compiling the *.pp files I get the error: Couldn't find function/label by name:main Baga
  7. Ok, I tried to compile my project in SourceBoost IDE, but I get the error I had before about redefining functions. This is the output. Does it have anything todo with the fact I'm using multiple (sub)folders? (BTW. The PP is invoked automatically in SourceBoost IDE, right?) Building... BoostC Optimizing C Compiler Version 6.85 (for PIC16 architecture) http://www.sourceboost.com Copyright(C) 2004-2008 Pavel Baranov Copyright(C) 2004-2008 David Hobday Single user Lite License (Unregistered) for 0 node(s) Limitations: PIC12,PIC16 max code size:2048 words, max RAM banks:2, Non commercial use only Main.c success BoostC Optimizing C Compiler Version 6.85 (for PIC16 architecture) http://www.sourceboost.com Copyright(C) 2004-2008 Pavel Baranov Copyright(C) 2004-2008 David Hobday Single user Lite License (Unregistered) for 0 node(s) Limitations: PIC12,PIC16 max code size:2048 words, max RAM banks:2, Non commercial use only Button\Buttons.c success BoostC Optimizing C Compiler Version 6.85 (for PIC16 architecture) http://www.sourceboost.com Copyright(C) 2004-2008 Pavel Baranov Copyright(C) 2004-2008 David Hobday Single user Lite License (Unregistered) for 0 node(s) Limitations: PIC12,PIC16 max code size:2048 words, max RAM banks:2, Non commercial use only RGBLed\RGBLeds.c success BoostLink Optimizing Linker Version 6.85 http://www.sourceboost.com Copyright(C) 2004-2008 Pavel Baranov Copyright(C) 2004-2008 David Hobday failure "C:\Program Files\SourceBoost\boostc.pic16.exe" Main.c -t PIC16F887 -I RGBLed -I Button -I C:\PROGRA~1\SourceBoost\include "C:\Program Files\SourceBoost\boostc.pic16.exe" Button\Buttons.c -t PIC16F887 -I RGBLed -I Button -I C:\PROGRA~1\SourceBoost\include "C:\Program Files\SourceBoost\boostc.pic16.exe" RGBLed\RGBLeds.c -t PIC16F887 -I RGBLed -I Button -I C:\PROGRA~1\SourceBoost\include "C:\Program Files\SourceBoost\boostlink.pic.exe" /ld "C:\Program Files\SourceBoost\lib" libc.pic16.lib Main.obj Buttons.obj RGBLeds.obj /t PIC16F887 /d C:\svn\PIC_RGB_LED\Implementation\Src /p RGB_LED Exit code was -2. Removing target: RGB_LED.hex Standard_Functions.h function redefinition: porta_flush(void) in Standard_Functions.h Standard_Functions.h function redefinition: portb_flush(void) in Standard_Functions.h Standard_Functions.h function redefinition: portc_flush(void) in Standard_Functions.h Standard_Functions.h function redefinition: portd_flush(void) in Standard_Functions.h Standard_Functions.h function redefinition: porte_flush(void) in Standard_Functions.h Standard_Functions.h function redefinition: porta_flush(void) in Standard_Functions.h Standard_Functions.h function redefinition: portb_flush(void) in Standard_Functions.h Standard_Functions.h function redefinition: portc_flush(void) in Standard_Functions.h Standard_Functions.h function redefinition: portd_flush(void) in Standard_Functions.h Standard_Functions.h function redefinition: porte_flush(void) in Standard_Functions.h Failed to locate output file 'C:\svn\PIC_RGB_LED\Implementation\Src\RGB_LED.hex' Done Failed Baga
  8. Ok, I think I solved the problem. Is it correct to compile the .pp files? I'm now getting an other link time error, which I can't explain: Couldn't find function/label by name:main Does anyone know what causes this error, or how to fix it? Is it actually caused at link time, or are my .obj file not correctly created (compile time)? I just can't get it to work, this is my command: C:\PROGRA~1\SourceBoost\boostlink.pic -ld C:\PROGRA~1\SourceBoost\Lib -p RGB_LED -t PIC16F887 Main.obj RGBLeds.obj Buttons.obj libc.pic16.lib Baga
  9. Hello, I set up a PIC project, using eclipse. Don't ask me why, but I simply prefer this IDE above others. This means I try to compile and link my files using the commandline (via GNU Make). I'm trying to compile and link my project .c files to a .hex file. I'm using multiple source files (both .c and .h). /* Main.c */ #include <system.h> #include "Standard_Types.h" #include "Standard_Functions.h" #include "RGBLeds.h" ... /*RGBLeds.c */ #include <system.h> #include "Standard_Types.h" #include "Standard_Functions.h" #include "RGBLeds.h" ... /* RGBLeds.h */ #ifndef RGBLED_H #define RGBLED_H #include <system.h> ... #endif /* Standard_Functions.h */ #ifndef STANDARD_FUNCTIONS_H #define STANDARD_FUNCTIONS_H /* defined some functions */ #endif When linking I get an error saying that the functions in Standard_Function.h are being redefined. Which is because I include the Standard_Functions file multiple times. But I think it should be fixed by using the preprocessor statements #ifndef STANDARD_FUNCTIONS_H and #define STANDARD_FUNCTIONS_H. I think the problem is that i'm not actually using the .pp files from the preprocessor. But I don't now how to use them or where and when to use them. At link time? BagascuW
×
×
  • Create New...