• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Problem with PIC18F46K20 building LED\blinking LED

Status
Not open for further replies.

blinkyu

New Member
I tried PIC18F46K20 C18 Lessons
1 lesson was successful- Build succeeded.
But I still have a problem- LED is not light on. Why?

I did all, what was in C18 lessons instruction, programmed corectly, but I dont see the light. (I tried to load the demo of Pong, it was working).



The second problem is with blinking LED.

Here is the code: (default)







//******************************************************************************
//Software License Agreement
//
//The software supplied herewith by Microchip Technology
//Incorporated (the "Company") is intended and supplied to you, the
//Company’s customer, for use solely and exclusively on Microchip
//products. The software is owned by the Company and/or its supplier,
//and is protected under applicable copyright laws. All rights are
//reserved. Any use in violation of the foregoing restrictions may
//subject the user to criminal sanctions under applicable laws, as
//well as to civil liability for the breach of the terms and
//conditions of this license.
//
//THIS SOFTWARE IS PROVIDED IN AN "AS IS" CONDITION. NO WARRANTIES,
//WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED
//TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
//PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT,
//IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR
//CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
// *******************************************************************
// PIC18F46K20 Starter Kit Lesson 2 - Blink LED
//
// This lesson blinks LED 7 on the demo board by using a delay and
// loop.
//
// *******************************************************************
// * See included documentation for Lesson instructions *
// *******************************************************************

/** C O N F I G U R A T I O N B I T S ******************************/

#pragma config FOSC = INTIO67, FCMEN = OFF, IESO = OFF // CONFIG1H
#pragma config PWRT = OFF, BOREN = SBORDIS, BORV = 30 // CONFIG2L
#pragma config WDTEN = OFF, WDTPS = 32768 // CONFIG2H
#pragma config MCLRE = ON, LPT1OSC = OFF, PBADEN = ON, CCP2MX = PORTC // CONFIG3H
#pragma config STVREN = ON, LVP = OFF, XINST = OFF // CONFIG4L
#pragma config CP0 = OFF, CP1 = OFF, CP2 = OFF, CP3 = OFF // CONFIG5L
#pragma config CPB = OFF, CPD = OFF // CONFIG5H
#pragma config WRT0 = OFF, WRT1 = OFF, WRT2 = OFF, WRT3 = OFF // CONFIG6L
#pragma config WRTB = OFF, WRTC = OFF, WRTD = OFF // CONFIG6H
#pragma config EBTR0 = OFF, EBTR1 = OFF, EBTR2 = OFF, EBTR3 = OFF // CONFIG7L
#pragma config EBTRB = OFF // CONFIG7H


/** I N C L U D E S **************************************************/
#include "p18f46k20.h"
#include "delays.h"

/** D E C L A R A T I O N S *******************************************/


void main (void)
{

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

while (1)
{
LATDbits.LATD7 = ~LATDbits.LATD7; // toggle LATD

Delay1KTCYx(50); // Delay 50 x 1000 = 50,000 cycles; 200ms @ 1MHz
}

}





And in a result:



----------------------------------------------------------------------
Release build of project `C:\Lessons\PIC18F46K20 Starter Kit Lessons\02 Blink LED\02 Blink LED.mcp' started.
Language tool versions: mpasmwin.exe v5.35, mplink.exe v4.35, mcc18.exe v3.35
Sat May 29 21:48:36 2010
----------------------------------------------------------------------
Clean: Deleting intermediary and output files.
Clean: Deleted file "C:\Lessons\PIC18F46K20 Starter Kit Lessons\02 Blink LED\02 Blink LED.o".
Clean: Done.
Executing: "C:\MCC18\bin\mcc18.exe" -p=18F46K20 "02 Blink LED.c" -fo="02 Blink LED.o" -Ou- -Ot- -Ob- -Op- -Or- -Od- -Opa-
Executing: "C:\MCC18\bin\mplink.exe" /l"C:\MCC18\lib" "..\..\..\Users\Igor\Desktop\18f46k20.lkr" "02 Blink LED.o" "C:\MCC18\lib\p18F46K20.lib" /u_CRUNTIME /z__MPLAB_BUILD=1 /o"02 Blink LED.cof" /M"02 Blink LED.map" /W
MPLINK 4.35, Linker
Copyright (c) 1998-2010 Microchip Technology Inc.
Error - could not find definition of symbol 'Delay1KTCYx' in file './02 Blink LED.o'.
Errors : 1

Link step failed.
----------------------------------------------------------------------
Release build of project `C:\Lessons\PIC18F46K20 Starter Kit Lessons\02 Blink LED\02 Blink LED.mcp' failed.
Language tool versions: mpasmwin.exe v5.35, mplink.exe v4.35, mcc18.exe v3.35
Sat May 29 21:48:37 2010
----------------------------------------------------------------------
BUILD FAILED


Please help me.

Thanks.
 

3v0

Coop Build Coordinator
Forum Supporter
The problem is the linker is failing. Did you add or modify a linker command file. The newer versions of the linker do not require that you specify one.

Executing: "C:\MCC18\bin\mplink.exe" /l"C:\MCC18\lib" "..\..\..\Users\Igor\Desktop\18f46k20.lkr" "02 Blink LED.o" "C:\MCC18\lib\p18F46K20.lib" /u_CRUNTIME /z__MPLAB_BUILD=1 /o"02 Blink LED.cof" /M"02 Blink LED.map" /W
MPLINK 4.35, Linker
Copyright (c) 1998-2010 Microchip Technology Inc.
Error - could not find definition of symbol 'Delay1KTCYx' in file './02 Blink LED.o'.
Errors : 1
 
Status
Not open for further replies.

EE World Online Articles

Loading
Top