View previous topic :: View next topic |
Author |
Message |
Arakel
Joined: 06 Aug 2016 Posts: 107 Location: Moscow
|
How to use additional "'c" files with 1 header |
Posted: Fri Apr 05, 2019 11:45 pm |
|
|
Hi to everyone! Long time no see.
I tried, but I get "device required before this line" in the header file.
Compiler version 5.81
Windows 7 Pro. _________________ Yo! I love learning and technology! I just do not have experience so do not be angry if I ask a stupid question about a detail! From so much to remember sometimes I forget the details in order to remember the big problems! |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
Re: How to use additional "'c" files with 1 header |
Posted: Sat Apr 06, 2019 1:17 am |
|
|
Arakel wrote: |
I tried, but I get "device required before this line" in the header file.
|
Don't add additional C files to the "Source Files" section of the MPLAB X
project window. Only your main C file should be in that section.
If you add more files that way, you will get the "Device required" error.
To add more C source files, just #include them in your main C file.
Example: I want to add flex_lcd.c to my project. So I just add an
#include line for it in my main C file, as shown below. I also want
a ds1307 driver and an eeprom driver, so I #include them too.
See below:
Code: | #include <18F46K22.h>
#fuses INTRC_IO, NOWDT, BROWNOUT, PUT, NOPBADEN
#use delay(clock=4M)
#use rs232(baud=9600, UART1, ERRORS)
#include "flex_lcd.c"
#include "ds1307.c"
#include "24256.c"
//==========================
void main()
{
lcd_init();
while(TRUE);
} |
|
|
|
Arakel
Joined: 06 Aug 2016 Posts: 107 Location: Moscow
|
|
Posted: Sat Apr 06, 2019 7:30 am |
|
|
Its working. I tried it on CCS directly. I don't use MPLAB because its very heavy.
No header file and don't add the source file in the files list on the left and its ok.
Thank you very much for the help! _________________ Yo! I love learning and technology! I just do not have experience so do not be angry if I ask a stupid question about a detail! From so much to remember sometimes I forget the details in order to remember the big problems! |
|
|
|