From: Nik Rim on
Trying to learn some C with PICs and I've fallen over before I've even
started.

I'm running MPLAB with PICC18 (lite student version). When I try to compile
I get an error:

"Error - could not find definition of symbol 'TRISD' in file './01 Hello
LED.o'.
Errors : 1
Link step failed."



In the project I have "p18f45k20.h" included under header files, TRISD is
defined in this file but the compiler seems to be looking for the definition
in "01 Hello LED.o".


Anyone tell me what I've missed?

thanks
Nik





// PIC18F46K20 Starter Kit Lesson 1 - Hello LED
// This lesson turns on LED 7 on the demo board.

#pragma config FOSC = INTIO67
#pragma config WDTEN = OFF, LVP = OFF, MCLRE = OFF

#include "p18f45k20.h"


void main (void)
{

TRISD = 0b01111111; // PORTD bit 7 to output (0); bits 6:0 are inputs (1)

LATDbits.LATD7 = 1; // Set LAT register bit 7 to turn on LED

while (1)
;

}


From: don on
Nik Rim wrote:
> Trying to learn some C with PICs and I've fallen over before I've even
> started.
>
> I'm running MPLAB with PICC18 (lite student version). When I try to compile
> I get an error:
>
> "Error - could not find definition of symbol 'TRISD' in file './01 Hello
> LED.o'.
> Errors : 1
> Link step failed."
>
>
>
> In the project I have "p18f45k20.h" included under header files, TRISD is
> defined in this file but the compiler seems to be looking for the definition
> in "01 Hello LED.o".
>
>
> Anyone tell me what I've missed?
>
> thanks
> Nik
>
>
>
>
>
> // PIC18F46K20 Starter Kit Lesson 1 - Hello LED
> // This lesson turns on LED 7 on the demo board.
>
> #pragma config FOSC = INTIO67
> #pragma config WDTEN = OFF, LVP = OFF, MCLRE = OFF
>
> #include "p18f45k20.h"
>
>
> void main (void)
> {
>
> TRISD = 0b01111111; // PORTD bit 7 to output (0); bits 6:0 are inputs (1)
>
> LATDbits.LATD7 = 1; // Set LAT register bit 7 to turn on LED
>
> while (1)
> ;
>
> }
>
>


MPLAB -> Project -> Set Language Tool Locations -> MicroChip C18
ToolSuite ->
Default Search Paths & Directories -> Library Search Path, $(LIBDIR)
C:\<Fill in where ever you installed the compiler> \lib -> OK

don

From: Nik Rim on

<don> wrote in message
news:3u-dnXmoueSvuTzXnZ2dnUVZ_jhi4p2d(a)forethought.net...
> Nik Rim wrote:
>> Trying to learn some C with PICs and I've fallen over before I've even
>> started.
>>
>> I'm running MPLAB with PICC18 (lite student version). When I try to
>> compile I get an error:
>>
>> "Error - could not find definition of symbol 'TRISD' in file './01 Hello
>> LED.o'.
>> Errors : 1
>> Link step failed."
>>
>>
>>
>> In the project I have "p18f45k20.h" included under header files, TRISD is
>> defined in this file but the compiler seems to be looking for the
>> definition in "01 Hello LED.o".
>>
>>
>> Anyone tell me what I've missed?
>>
>> thanks
>> Nik
>>
>>
>>
>>
>>
>> // PIC18F46K20 Starter Kit Lesson 1 - Hello LED
>> // This lesson turns on LED 7 on the demo board.
>>
>> #pragma config FOSC = INTIO67
>> #pragma config WDTEN = OFF, LVP = OFF, MCLRE = OFF
>>
>> #include "p18f45k20.h"
>>
>>
>> void main (void)
>> {
>>
>> TRISD = 0b01111111; // PORTD bit 7 to output (0); bits 6:0 are inputs
>> (1)
>>
>> LATDbits.LATD7 = 1; // Set LAT register bit 7 to turn on LED
>>
>> while (1)
>> ;
>>
>> }
>
>
> MPLAB -> Project -> Set Language Tool Locations -> MicroChip C18
> ToolSuite ->
> Default Search Paths & Directories -> Library Search Path, $(LIBDIR)
> C:\<Fill in where ever you installed the compiler> \lib -> OK
>
> don
>


I checked as suggested, the paths were as follows and the directories
appeared to contain the .inc & .lib files

Include search path: C:\MCC18\mpasm
Library search path: C:\MCC18\lib


Thanks for the suggestion - it must be something else simple like that, I'll
go look some more.

cheers
Nik




From: Nobody on
On Fri, 04 Sep 2009 15:55:19 +0800, Nik Rim wrote:

> Trying to learn some C with PICs and I've fallen over before I've even
> started.
>
> I'm running MPLAB with PICC18 (lite student version). When I try to compile
> I get an error:
>
> "Error - could not find definition of symbol 'TRISD' in file './01 Hello
> LED.o'.
> Errors : 1
> Link step failed."
>
>
>
> In the project I have "p18f45k20.h" included under header files, TRISD is
> defined in this file

I suspect that TRISD will only be *declared* in that file, not defined
there.

For Microchip's MCC18, the definitions are in p18f45k20.lib. This is
normally linked in by an entry in the linker script (.lkr), e.g.:

FILES p18f45k20.lib

If you aren't using a linker script, you'll need to add the library to
the project.

From: Nik Rim on

"Nobody" <nobody(a)nowhere.com> wrote in message
news:pan.2009.09.05.00.28.39.719000(a)nowhere.com...
> On Fri, 04 Sep 2009 15:55:19 +0800, Nik Rim wrote:
>
>> Trying to learn some C with PICs and I've fallen over before I've even
>> started.
>>
>> I'm running MPLAB with PICC18 (lite student version). When I try to
>> compile
>> I get an error:
>>
>> "Error - could not find definition of symbol 'TRISD' in file './01 Hello
>> LED.o'.
>> Errors : 1
>> Link step failed."
>>
>>
>>
>> In the project I have "p18f45k20.h" included under header files, TRISD is
>> defined in this file
>
> I suspect that TRISD will only be *declared* in that file, not defined
> there.
>
> For Microchip's MCC18, the definitions are in p18f45k20.lib. This is
> normally linked in by an entry in the linker script (.lkr), e.g.:
>
> FILES p18f45k20.lib
>
> If you aren't using a linker script, you'll need to add the library to
> the project.
>


Thanks - just tried making that change & unfortunately it didn't work.

I've changed the lib path directory as suggested by don. Didn't fix it but
now having played with all the paths, it progresses further and spits out a
syntx error from the first line in the .inc file. Its reporting the ";"
which makes sense as I assume it should be "//" for C. Surely I must be
doing something fundamental wrong here! It's a pain being a noob!