View previous topic :: View next topic |
Author |
Message |
Jerry I
Joined: 14 Sep 2003 Posts: 96 Location: Toronto, Ontario, Canada
|
Undefined Identifiers |
Posted: Thu Jun 11, 2015 7:25 pm |
|
|
Hi Pic Programmers;
Thanks for any help in advance.
Ver 5.045 PCWH
PIC18F96J60
I created a new project using the project wizard. I defined all parameters including TCPIP code.
Appeared to generate all code but getting errors on compile. Undefined Identifiers.
The errors start from the TCPIP stack file helpers.c
Lines that give errors are where its using the hardware SFRS register definitions of the chip.
example:
Code: |
ADCON0SAVE = ADCON0;
ADCON2SAVE = ADCON2;
T0CONSAVE = T0CON;
TMR0LSAVE = TMR0L;
TMR0HSAVE = TMR0H;
ADCON0 = 0x01;
ADCON0BITS.GO = 1;
TMR0H = 0x00;
TMR0L = 0x00;
all lines of code above, give Undefined Identifiers error
|
Everything looks defined correctly.
What happened to the definitions of the SFRS registers.
Do I have to add an include for them. I thought compiler included the defines of the SFRS registers.
Thanks again for any help.
Jerry |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Jun 11, 2015 8:25 pm |
|
|
You can make the register definitions file. In the CCS IDE, open up
the Device Table Editor window. Set it for your PIC. Then click on the
menu for Make Include File. You can see it to the right of the PIC's
name in this screenshot. It's near the top:
http://www.datadynamics.co.jp/ccscc/images/device_table_editor.gif
If you want the file in your program you will have to add an #include for it. |
|
|
RF_Developer
Joined: 07 Feb 2011 Posts: 839
|
Re: Undefined Identifiers |
Posted: Fri Jun 12, 2015 5:17 am |
|
|
Jerry I wrote: | Do I have to add an include for them. I thought compiler included the defines of the SFRS registers. |
CCS C effective deprecates the SFRs by such direct means. For almost all purposes, CCS C provides better (i.e. more portable and better self-documenting, as well as less error-prone) methods of controlling the hardware. I mean, who needs to know where ADCON0BITS.GO is when you've got read_adc() and start_adc()?
On occasions there may be a good reason to directly access a bit or a SFR, for instance to implement some workaround for an errata issue, or to fix a problem with a new PIC with poor or partial support in the cissue of the compiler (later issues may well NOT need such fixes, so they are best to thought of as temporary fixes). For this CCS C provides a more portable and convenient (as in don't need to go through four levels of somewhat obscure, to me at least, method of defining the SFRs. This is to use getenv.
So, CCS does provide the old assembler style low level SFR support you're looking for, but it doesn't make it easy, and not by default: you have to deliberately enable it. Personally, I have never used it, nor can I see any likelyhood of me ever using it. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19513
|
|
Posted: Fri Jun 12, 2015 9:11 am |
|
|
Yes. Agree wholeheartedly. However the reason here is that the TCP/IP stack, is a port from Microchip C, which does use the registers a lot, so needs the definitions. One of those 'need to know' things... |
|
|
Jerry I
Joined: 14 Sep 2003 Posts: 96 Location: Toronto, Ontario, Canada
|
Undefined Identifiers (Solved) |
Posted: Fri Jun 12, 2015 6:44 pm |
|
|
Hi
Thank you the helpful answers/clues to the problem
I found that the project wizard created a code error as below.
Code: |
#if getenv("DEVICE") == "PIC18F97J60"
#define __18F97J60
#include "PIC18F87J60_registers.h"
#elif getenv("DEVICE") == "PIC18F96J65"
#define __18F96J65)
#elif getenv("DEVICE") == "PIC18F96J60"
#define __18F96J60
#elif getenv("DEVICE") == "PIC18F87J60"
#define __18F87J60
#include "PIC18F87J60_registers.h"
#elif getenv("DEVICE") == "PIC18F86J65"
#define __18F86J65
#elif getenv("DEVICE") == "PIC18F86J65"
#define __18F86J65
#elif getenv("DEVICE") == "PIC18F86J60"
#define __18F86J60
#elif getenv("DEVICE") == "PIC18F67J60"
#define __18F67J60
#include "PIC18F67J60_registers.h"
#elif getenv("DEVICE") == "PIC18F66J65"
#define __18F66J65
#elif getenv("DEVICE") == "PIC18F66J60"
#define __18F66J60
#elif getenv("DEVICE") == "PIC18F67K22"
#define __18F67K22
#include "PIC18F67K22_registers.h"
#elif getenv("DEVICE") == "PIC18F4620"
#define __18F4620
#include "PIC18F4620_registers.h"
#else
#include "PIC18F97J60_registers.h"
#endif
|
I am using the PIC18F97J60.
If you look at the 3rd line of code -> #include "PIC18F87J60_registers.h"
is where the error occurred.
should have been -> #include "PIC18F97J60_registers.h"
Compiles Now
Thanks again for helo |
|
|
|