Mplab help!!!

AlexR

Joined Jan 16, 2008
732
As I said, the code is for PIC16F628.
True, but the OP is using a PIC16F84a so lets give him some code he can use.
I'm using the above configuration words in my PIC16F628.
Using which compiler and which version?

It certainly does not compile under HiTecC V9.81, all the config bit names are wrong, even for the PIC16F628a. See the relevant HiTec header files (pic16f628a.h or pic16f84a.h) for the correct config bit names.
 

t06afre

Joined May 11, 2009
5,934
True, but the OP is using a PIC16F84a so lets give him some code he can use
The example from Nerdegutta was a good example. Not many are using the obsolete, and antiquated 16f84. The OP must by him self bring him up to data by reading the needed documentation. Like data sheet. And familiarize him self with the header file content
 

AlexR

Joined Jan 16, 2008
732
The OP is perfectly capable of writing code that fails to compile without any help from us. How about we give him an example that work so that he can confirm that the compiler is working correctly then he can go and de-bug his own code with the knowledge that any mistakes are his rather than a problem with the compiler installation.
 

Thread Starter

Rk17

Joined Apr 23, 2011
43
ive tried your code. everything seemed right however there was this one error message



[CODE:]Error [139] ; . end of file in comment
Rich (BB code):
what does it mean sir?

im still learning how to compile using hi-tech c with the link sent to me. 

tnx again
 

Thread Starter

Rk17

Joined Apr 23, 2011
43
ive also tried your code sir but got this error message

Rich (BB code):
 Warning [176] C:\Documents and Settings\Administrator\My Documents\pic16F84 projects\16F84A_delay (100)\srv.c; 32.0 missing newline
Warning [361] C:\Documents and Settings\Administrator\My Documents\pic16F84 projects\16F84A_delay (100)\srv.c; 25.1 function declared implicit int
Warning [337] C:\Documents and Settings\Administrator\My Documents\pic16F84 projects\16F84A_delay (100)\srv.c; 31.0 line does not have a newline on the end
Error   [800] ; 0. undefined symbol "FOSC_XT"
Error   [800] ; 0. undefined symbol "CP_OFF"
Error   [800] ; 0. undefined symbol "PWRTE_ON"
Error   [800] ; 0. undefined symbol "WDTE_OFF"

********** Build failed! **********
 

AlexR

Joined Jan 16, 2008
732
According to the documentation error 139 would seem to mean that the compiler is seeing the closing brace "}" of main function inside a comment field. HiTechC is not my normal compiler so I'm not familiar with all its quirks and I don't know why that is happening on your machine but the file compiles without any errors when I run it.
It could be that you missed a closing "*/" on one of the comment fields.

I'm confused now. Which file works which doesn't and which file threw up those last error messages?
 
Last edited:

t06afre

Joined May 11, 2009
5,934
The code from AlexR works just fine (or at least compile fine). Compiled with version 9.81. You can post your current code here and I can test it
 

Thread Starter

Rk17

Joined Apr 23, 2011
43
your right maybe my compiler does not suit the file. Where can you get the update version of mplab? is V 9.81 free? im using V8.66 and got it for free. i think what im going to do is upgrade my software for it to work. By the way what compiler do you use?
 

t06afre

Joined May 11, 2009
5,934
your right maybe my compiler does not suit the file. Where can you get the update version of mplab? is V 9.81 free? im using V8.66 and got it for free. i think what im going to do is upgrade my software for it to work. By the way what compiler do you use?
The version of MPLAB is not that critical I run version 8.60 no problem. From your postings I can see that you use HI-TECH C version 9.81 which is the latest. Have you created a project as shown in the quickstart.pdf I pointed your to. In MPLAB Always use a project.
 

Thread Starter

Rk17

Joined Apr 23, 2011
43
THANKS FOR ALL THE HELP GUYS!! Ive done it! i used mikroC v4.60 and it worked
here is the image file of the compilation

http://img694.imageshack.us/i/delayo.jpg/

I have a question though. im thinking which is better mplab of mikroC? and if they do have different codes? if so then you have to learn all the codes in programing when choosing one of them?
>>for example if i choose to use mplab. then i have too learn all of the codes when creating a program using mplab? and so as to mikroC? but they have different codes used? isnt it a bit confusing when shifting from 1 software to the other? because of numerous codes used? and how bout the compilers; does each compiler has its own code to? like hi-tech c, css c compiler?

im just a bit confused..:(
 

nerdegutta

Joined Dec 15, 2009
2,684
I'm happy the OP got what he wanted, but this has been on my mind all day, so I had to check it when I got home from work...

True, but the OP is using a PIC16F84a so lets give him some code he can use.
Agreed, but this was what I had at hand at the time, and I figured the PIC's was not so different.

Using which compiler and which version?
I'm using MPLAB 8.63, HI-TECH C V9.80.

It certainly does not compile under HiTecC V9.81, all the config bit names are wrong, even for the PIC16F628a. See the relevant HiTec header files (pic16f628a.h or pic16f84a.h) for the correct config bit names.
Here are some copy paste from some of the header files:

From the file pic16f62xa.h
Rich (BB code):
// Configuration Mask Definitions 
#define CONFIG_ADDR    0x2007 
// Protection of flash memory  
#define PROTECT        0x1FFF 
#define UNPROTECT    0x3FFF 
// Protection of EEPROM data memory  
#define CPD        0x3EFF 
#define UNPROTECT    0x3FFF 
// Low voltage programming enable  
#define LVPEN        0x3FFF 
#define LVPDIS        0x3F7F 
// Brown out detection enable  
#define BOREN        0x3FFF 
#define BORDIS        0x3FBF 
// Master clear reset pin function 
#define MCLREN        0x3FFF 
#define MCLRDIS        0x3FDF 
// Power up timer enable  
#define PWRTEN        0x3FF7 
#define PWRTDIS        0x3FFF 
// Watchdog timer enable  
#define WDTEN        0x3FFF 
#define WDTDIS        0x3FFB 
// Oscillator configurations  
#define RCCLK        0x3FFF 
#define RCIO        0x3FFE 
#define INTCLK        0x3FFD 
#define INTIO        0x3FFC 
#define EC        0x3FEF 
#define HS        0x3FEE 
#define XT        0x3FED 
#define LP        0x3F
Since htc.h refers to pic.h and pic.h refers to pic1684.h, I include the configuration words from that file:
Rich (BB code):
#define CONFIG_ADDR    0x2007 
 
/*osc configurations*/ 
#define RC        0x3FFF        // resistor/capacitor 
#define HS        0x3FFE        // high speed crystal/resonator 
#define XT        0x3FFD        // crystal/resonator 
#define LP        0x3FFC        // low power crystal/resonator 
 
/*watchdog*/ 
#define WDTEN        0x3FFF        // enable watchdog timer 
#define WDTDIS        0x3FFB        // disable watchdog timer 
 
/*power up timer*/ 
#if defined (_16C84) 
#define PWRTEN        0x3FFF        /* enable power up timer*/ 
#define PWRTDIS        0x3FF7        /* disable power up timer */ 
#else 
#define PWRTDIS        0x3FFF        /* disable power up timer */ 
#define PWRTEN        0x3FF7        /* enable power up timer */ 
#endif 
 
#if defined (_16CR83) || defined(_16CR84) 
#define DP        0x3F7F        // data code is protected 
#define PROTECT        0x008F        // program code is protected 
// alternative definition 
#define DATPROT        0x3F7F        // use DP 
#define DATUNPROT    0x3FFF        // use UNPROTECT 
#elif defined (_16C84) 
#define PROTECT        0x3FEF        // program code is protected 
#elif defined (_16F83) || defined(_16F84) || defined(_16F84A) 
#define PROTECT        0x000F        // program code is protected 
#endif 
 
#define UNPROTECT    0x3FFF        // do not protect the code
Just had to get it out of my head.:)
Now I can carry on.
 

t06afre

Joined May 11, 2009
5,934
I can add that it has been many major changes in the header file system from version 9.80 to 9.81. If you are not aware of this. It will give you some trouble then you recompile a 9.80 file in 9.81
this is from HI-tech C release notes
New header file generation (9.81) Header files in the 9.81 version are now generated from a central database rather than being hand crafted. This may mean that the names of some SFRs or bits within SFRs in the new header files may be different to those in the header files that were previously used by the compiler. The header files that were previously shipped with the compiler are no longer maintained, but are supplied with this version of the compiler and can be used by defining the macro _LEGACY_HEADERS. Ideally, this macro should be defined using the compiler’s -D option, or in the Define macros field in the Compiler tab
of the MPLAB IDE Build Options dialog. If you use a
#define to define this, make sure you place this above the line which includes <htc.h>. The legacy include files are located in the legacy directory, inside the include directory of the compile

 
Last edited:

Thread Starter

Rk17

Joined Apr 23, 2011
43
:) tnx nerdegutta for everything!

can you please guide me through my journey through programming? if its ok with you i really need some help regarding the basics of programming. Ill help my self by researching some more and by practicing. im really interested,

Ive started with the quickstart guide of hi-tech c. Ive copied the code

Rich (BB code):
#include <htc.h>
__CONFIG(XT & WDTDIS & PWRTDIS & BORDIS & LVPEN & WRTEN &
DEBUGEN & DUNPROT & UNPROTECT);
void init(void)
{
// port directions: 1=input, 0=output
TRISB = 0b00000000;
}
char counter;
void main(void)
{
counter = 0;
init();
while (1){
PORTB = counter;
_delay(10000);
counter++;
}
}
but again i get an error message:

Rich (BB code):
Error   [499] ; . undefined symbol:
    __delay (tutorial1.obj)
this should work right? because it says on the manual and besides ive only copied the code . is it the code itself that is wrong? or do i have some settings in mplab which is inappropriate?
 

nerdegutta

Joined Dec 15, 2009
2,684
Hi.

I think that there are plenty of others that are better than me to teach you programming.

Stay here and ask questions, and read the documents that are recommended to you, and you will learn.

Did you follow the steps in the tutorial/quick start guide, or did you just write the code in the editor.

If you read the text, you will see that the quick start guide is using the PIC16F877A micro-controller.

To change the PIC: Configure -> Select device -> select the proper pic

But as t06afre said:

In MPLAB Always use a project.
About the changing in the headerfiles from V9.80 to V9.81 I was not aware of that. Thanks for the "heads-up" :)
 

t06afre

Joined May 11, 2009
5,934
About the changing in the headerfiles from V9.80 to V9.81 I was not aware of that. Thanks for the "heads-up" :)
They have also changed the __config settings. Almost every config word name has been changed. The __config settings are now in the start of the header file not the end.
 

nerdegutta

Joined Dec 15, 2009
2,684
... and here I sat, happy, with my Hi-Tech C V9.80, and all the other guys are playing with V9.81... :(

I guess the version number says it all...
 

AlexR

Joined Jan 16, 2008
732
Rk17:
Something strange is going on with your compiler efforts.

You are getting errors that I would not expect yet at the same time you are not getting the error messages I would expect to see.

Are you sure you have MPLAB set up to use the HiTechC compiler?

Can you post the complete compile dialogue from the MPLAB "build" window so we can see what exactly is going on.
 

AlexR

Joined Jan 16, 2008
732
Part of the problem is that you are using an ancient version of HiTechC (9.60) whereas we have been assuming that you would have the latest version (9.81).
I would strongly recommend upgrading to the latest version as some of the older versions (not sure if 9.60 was one of them) had some very serious bugs.
 
Top