CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

error compiling ccs code in mplab x ide
Goto page 1, 2  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
jose_pic16f887



Joined: 06 Sep 2018
Posts: 11

View user's profile Send private message

error compiling ccs code in mplab x ide
PostPosted: Fri Apr 03, 2020 8:00 am     Reply with quote

Hello friends, best regards, good, I tell you I have a problem when compiling a ccs code in mplab x ide. I have installed the ccs plugin in mplab x ide as shown in the video developed by ccs, but when compiling the ccs code in mplab x ide generates a compilation error, I attach the corresponding image.
I share it on google drive.
https://drive.google.com/file/d/1mv66SgxVdmFL93YAkbs_4_3-T4nzyP7d/view?usp=sharing
I hope and can help me thanks Sad
temtronic



Joined: 01 Jul 2010
Posts: 9244
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Fri Apr 03, 2020 8:14 am     Reply with quote

It 'looks' like you don't have the PIC processor type header as the FIRST line in your program....
Without seeing your program. that's my guess.
jose_pic16f887



Joined: 06 Sep 2018
Posts: 11

View user's profile Send private message

PostPosted: Fri Apr 03, 2020 8:26 am     Reply with quote

This is my ccs code to make it compile in mplab x ide.
Code:

#include <30F4013.h>
#Fuses NOWDT,XT,MCLR,NOPROTECT,NOWRT
#device adc=12
#use delay(clock=4000000)
#include <lcd.c>
#include <math.h>
#include <stdlib.h>
#define LCD_ENABLE_PIN PIN_D0
#define LCD_RS_PIN PIN_D1
#define LCD_RW_PIN PIN_D2
#define LCD_DATA4  PIN_F5
#define LCD_DATA5  PIN_F4
#define LCD_DATA6  PIN_F1
#define LCD_DATA7  PIN_F0
float voltage;
float Lect_adc;

void main()
{
 Lect_adc=0;
 voltage=0;
 lcd_init();
 setup_adc_ports(sAN0|VREF_VREF);
 setup_adc(ADC_CLOCK_DIV_32|ADC_TAD_MUL_2);

 while(true)
 {
  set_adc_channel(0);
  Lect_adc=read_adc();
  delay_ms(20);
  voltage=((20.0*Lect_adc)/4095);
  lcd_putc("\f");
  lcd_gotoxy(1,2);
  printf(lcd_putc,"Voltage = %f",Voltage);
  delay_ms(500);
 }
}

Also this code with the ccs compiler does NOT generate any error and compiles without any problem and generates the hex file.
I am trying to compile it in Mplab X ide so that it generates the file with the elf extension. Reason the dspic 30f4013 in Proteus does not have its libraries, and the multi-sim simulator does have this dsPIC, and the multi-sim only accepts files with an elf extension.

The ccs plugin for Mplab X ide has worked for me a little, but now compiling this code is giving me an error.

I hope for your help again and thanks.
Crying or Very sad
temtronic



Joined: 01 Jul 2010
Posts: 9244
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Fri Apr 03, 2020 11:07 am     Reply with quote

re: Reason the dspic 30f4013 in Proteus does not have its libraries,

so you're using PROTEUS and NOT real hardware ?
jose_pic16f887



Joined: 06 Sep 2018
Posts: 11

View user's profile Send private message

PostPosted: Fri Apr 03, 2020 11:15 am     Reply with quote

proteus does NOT have libraries for dspic 30f and pic 32,
I am NOT using Proteus since it does not have these libraries, I am using multisim 14.02 and I do not use real hardware because in my country Colombia is quarantined by the COVID-19 pandemic, also the electronic stores are closed.
watch the video of the ccs plugin in mplab x ide I send you the link
https://www.youtube.com/watch?v=uziNEmDdF3g
to see if you can help me thanks
Question
Ttelmah



Joined: 11 Mar 2010
Posts: 19545

View user's profile Send private message

PostPosted: Fri Apr 03, 2020 11:42 am     Reply with quote

In the IDE.
Project.
You have only this 'main' file in the section for 'source files'?.
It needs to be the only file here.
The other files can be in the 'header files' section, but must not be
in the source files section.
Otherwise the compiler will be asked to compile the other files
separately, which will not work.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Apr 03, 2020 11:43 am     Reply with quote

See my 2nd post in this thread. (It starts with "I got it working".)
http://www.ccsinfo.com/forum/viewtopic.php?t=58593
It explains the #device errors that you are getting.
Ttelmah



Joined: 11 Mar 2010
Posts: 19545

View user's profile Send private message

PostPosted: Fri Apr 03, 2020 12:32 pm     Reply with quote

It's interesting.
The 'automatic inclusion', you seemed to see, I have never seen
happen. However, I always work from a new project, and just specify the
main file and headers myself.
The behaviour here is quite annoying. Like several other 'features'
of the Netbeans platform (it does a similar thing, automatically 'finding'
other compilers, which really costs a lot of time and speed).
This sort of 'feature', makes the platform very annoying at times.... Sad
jose_pic16f887



Joined: 06 Sep 2018
Posts: 11

View user's profile Send private message

PostPosted: Fri Apr 03, 2020 3:57 pm     Reply with quote

Friends, I have followed the instructions as indicated in the manual but it still generates a compilation error, it will be that someone will be able to connect back to my pc through teamviewer to see how to add the respective mplab directories with ccs and thus be able to learn. What do you say?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Apr 03, 2020 7:33 pm     Reply with quote

I don't want to do teamviewer.

Post the complete error message you get in MPLAB X.
You only posted 7 lines in your Google Drive image.
I have the feeling that there are more lines than that.

-----------------------------
Regarding bugs in your program:
If you're changing the default pins used in lcd.c, you need to put the
#define statements above the #include line for the lcd.c file.

Here is the correct way to do it:
Code:

#define LCD_ENABLE_PIN PIN_D0
#define LCD_RS_PIN PIN_D1
#define LCD_RW_PIN PIN_D2
#define LCD_DATA4  PIN_F5
#define LCD_DATA5  PIN_F4
#define LCD_DATA6  PIN_F1
#define LCD_DATA7  PIN_F0
#include <lcd.c>

Now your LCD should work.
jose_pic16f887



Joined: 06 Sep 2018
Posts: 11

View user's profile Send private message

PostPosted: Fri Apr 03, 2020 8:54 pm     Reply with quote

Hello friend, thank you for answering. Through this google drive link, you will find the program folder in mplab with ccs code. You will also find in jpg image the 8 errors that the mplab x ide finds.
I have also changed what you told me and follow the same errors.
Link of google drive:
https://drive.google.com/file/d/1wSZi0BoevzTdlMCfQ6Uu6Ma50MIV5AMp/view?usp=sharing
Code:

#include <30F4013.h>
#Fuses NOWDT,XT,MCLR,NOPROTECT,NOWRT
#device adc=12
#use delay(clock=4000000)
#define LCD_ENABLE_PIN PIN_D0
#define LCD_RS_PIN PIN_D1
#define LCD_RW_PIN PIN_D2
#define LCD_DATA4  PIN_F5
#define LCD_DATA5  PIN_F4
#define LCD_DATA6  PIN_F1
#define LCD_DATA7  PIN_F0
#include <lcd.c>
#include <math.h>
#include <stdlib.h>
float voltage;
float Lect_adc;
void main()

{
 Lect_adc=0;
 voltage=0;
 lcd_init();
 setup_adc_ports(sAN0|VREF_VREF);
 setup_adc(ADC_CLOCK_DIV_32|ADC_TAD_MUL_2);
 while(true)
 {
  set_adc_channel(0);
  Lect_adc=read_adc();
  delay_ms(20);
  voltage=((20.0*Lect_adc)/4095);
  lcd_putc("\f");
  lcd_gotoxy(1,2);
  printf(lcd_putc,"Voltage = %f",Voltage);
  delay_ms(500);
 }
}

Can you help me ? Thanks Question
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Apr 03, 2020 11:40 pm     Reply with quote

For anyone who's interested, I have converted the jpeg of the errors to
text as shown below. To summarize the errors, it says:

It can't open 30F4013.h
It wants a '#device 30F4013' line but that's in the missing 30F4013.h file.
It can't interpret the '#device adc=12' line unless it knows the PIC.
It can't interpret #use delay() unless it knows the the PIC.
It can't open lcd.c
It can't open math.h
It can't open stdlib.h
It want a '#device 30F4013' before it uses stdlib.h
Quote:

"C:\PROGRA~2\PICC\CCSC0N.exe" out="build/default/production" Volt2.c +FD +DF +CC +Y=9 +EA +DF +LN +T +A +M +J +Z -P #__dsPIC30F4013__ =1
Compiling E:\VOLTIMETRO DSPIC 30F\Volt2.X\Volt2 on 03-abr.-20 at 21:32

E:\VOLTIMETRO DSPIC 30F\Volt2.X\Volt2.c:1:9: Error#18 File can not be opened
Not in source "E:\VOLTIMETRO DSPIC 30F\Volt2.X\30F4013.h"
Not in local "30F4013.h"
Not in project "E:\VOLTIMETRO DSPIC 30F\Volt2.X\30F4013.h"
Not in default "E:\VOLTIMETRO DSPIC 30F\Volt2.X\30F4013.h"

E:\VOLTIMETRO DSPIC 30F\Volt2.X\Volt2.c:2:7: Error#128 A #DEVICE required before this line
E:\VOLTIMETRO DSPIC 30F\Volt2.X\Volt2.c:3:9: Error#123 A #DEVICE required before this line
E:\VOLTIMETRO DSPIC 30F\Volt2.X\Volt2.c:4:5: Error#44 Internal Error - Contact CCS PPUSE

E:\VOLTIMETRO DSPIC 30F\Volt2.X\Volt2.c:12:10: Error#18 File can not be opened
Not in source "E:\VOLTIMETRO DSPIC 30F\Volt2.X\lcd.c"
Not in local "Icd.c"
Not in project "E:\VOLTIMETRO DSPIC 30F\Volt2.X\Volt2.c\lcd.c"
Not in default "E:\VOLTIMETRO DSPIC 30F\Volt2.X\Volt2.c\lcd.c"

E:\VOLTIMETRO DSPIC 30F\Volt2.X\Volt2.c:13:10: Error#18 File can not be opened
Not in source "E:\VOLTIMETRO DSPIC 30F\Volt2.X\math.h"
Not in local "math.h"
Not in project "E:\VOLTIMETRO DSPIC 30F\Volt2.X\Math.h"
Not in default "E:\VOLTIMETRO DSPIC 30F\Volt2.X\Math.h"

E:\VOLTIMETRO DSPIC 30F\Volt2.X\Volt2.c:14:10: Error#128 File can not be opened
Not in source "E:\VOLTIMETRO DSPIC 30F\Volt2.X\stdlib.h"
Not in local "stdlib.h"
Not in project "E:\VOLTIMETRO DSPIC 30F\Volt2.X\stdlib.h"
Not in default "E:\VOLTIMETRO DSPIC 30F\Volt2.X\stdlib.h“

E:\VOLTIMETRO DSPIC 30F\Volt2.X\Volt2.c:14:10: Error#128 A #DEVICE required before this line

8 Errors, 0 Warnings.
Build Failed.
nbproject/Makeflle-default.mk:114: recipe for target 'build/default/production/Volt2.o' failed
make[2]: Leaving directory *E:/VOLTIMETRO DSPIC 30F/Volt2.X'
nbproject/Hakefile-default.xak:114: recipe for target 'build/default/producticn/Volt2.c' failed
make[2]: Leaving directory *E:/VOLTIMETRO DSPIC 30F/Volt2.X'
nbproject/Makefile-default-mk:50: recipe for target '.build-ccnf' failed
make[1]: Leaving directory ' 2:/VOLTIMETRO DSPIC 30F/Volt2.X'
nbproject/Makefile-impl.ink:35: recipe for target ' .build-impl' failed
make[2]: *** [build/default/production/Volt2.o] Error 1
make[1]: *** [.build-conf] Error 2
make: ** * [.build-impl] Error 2
BUILD FAILED (exit value 2, total time: 2s)
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Apr 04, 2020 12:00 am     Reply with quote

I took his Volt2.X folder and copied it to this folder in Windows 10:
\This PC\OS (C:)\Users\Home\MPLABXProjects
Then I opened the project in MPLAB X.

I don't have the PCD compiler. I then made it work for PCH.
I clicked on the Project Properties icon in MPLAB X (looks like a wrench
and nuts) and changed the PIC to 18F87K22. I selected the CCS compiler.
I changed the #include line in Volt2.c to 18F87K22.h.
That PIC apparently doesn't have a PIN_F0, so I changed it to PIN_F2.
Then it compiled without errors. Build Successful.

I'm not familiar enough with the MPLAB X to know why it works for me
but fails for him.
Ttelmah



Joined: 11 Mar 2010
Posts: 19545

View user's profile Send private message

PostPosted: Sat Apr 04, 2020 12:56 am     Reply with quote

OK.
As I have PCD, decided to see what happened for me.

Don't know what version of MPLAB-X he has, but my current version
had to 'upgrade' the project file when I loaded it.

I then looked at the project properties as directly imported. Immediately
saw the problem.

Select project.
Right click - Properties.
CCS C Complier
Compiler options.
The 'Include directories' entry here is empty.

This needs to contain the directories where the compiler include files
are contained. So wherever the compiler is\Devices and another line for
\Examples, and finally one for \Drivers. Without these the compiler
cannot find it's includes.....

So added these.

Then selected 'Build', and the code merrily compiled for me.

He has not put the settings for the compiler include paths into the
project.... Sad

ON my copy, I put these in, when I installed the compiler into the
toolchain, and they are always automatically filled in when the compiler
is selected as you create a project.
jose_pic16f887



Joined: 06 Sep 2018
Posts: 11

View user's profile Send private message

PostPosted: Sat Apr 04, 2020 7:24 am     Reply with quote

Friends thanks for answering and trying to help me, I realized that this compiling ccs code in mplab x ide is very complicated. Well my ccs code is compiled without any problem and generates the hex file. My goal was to test the simulator multisim with dspic 30f and pic 32. This simulator requires file with elf extension. The mplab x ide generates it and I don't know why Labcenter has not placed these libraries in its own Proteus simulator for dspic 30f and pic 32.
  I have made digital voltmeter code for low-end pics pic 16f886, etc. and wanted to test how high-end pics like dspic 30f and pic 32 work with the multi-sim simulator.
The other option that remains for me is to make a code in mplab x ide and the c16 compiler and use the dspic 30f and try again, so not to use the ccs plugin with the mplab x ide.

Anyway thank you very much friends for your dedication and your kind responses.
thanks
Wink
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group