MPLAB help

Thread Starter

chrischristian

Joined Feb 22, 2008
43
I want to start programming (simmulation) of PIC by MPLAB but evry time I get this error .....

"
Clean: Deleting intermediary and output files.
Clean: Done.
Executing: "C:\Program Files\MPLAB IDE\MCHIP_Tools\MPASMWIN.EXE" /q /p18F452 "f452tmpo.asm" /l"f452tmpo.lst" /e"f452tmpo.err" /o"f452tmpo.o"
Executing: "C:\Program Files\MPLAB IDE\MCHIP_Tools\mplink.exe" "18f452i.lkr" "C:\Documents and Settings\CHRISTIAN\My Documents\FIRST PROJECT\f452tmpo.o" /o"MY PROJECT.cof"
MPLINK 3.80.02, Linker
Copyright (c) 2004 Microchip Technology Inc.
Errors : 0

MP2COD 3.80.02, COFF to COD File Converter
Copyright (c) 2004 Microchip Technology Inc.
Error - Source file 'C:\Documents and Settings\CHRISTIAN\My Documents\FIRST PROJECT\f452tmpo.asm' name exceeds file format maximum of 62 characters.
Errors : 1

Loaded C:\Documents and Settings\CHRISTIAN\My Documents\FIRST PROJECT\MY PROJECT.cof
BUILD SUCCEEDED: Mon Mar 17 20:17:51 2008

"
any solution !!:confused:
 

hgmjr

Joined Jan 28, 2005
9,027
I think what the compiler is complaining about is that the total character count in the pathname is greater that the 62 character limit aloowed by MPLAB. You can try renaming your folder from FIRST PROJECT to PIC PROJECT and see if that overcome the problem.

hgmjr
 

Thread Starter

chrischristian

Joined Feb 22, 2008
43
Thanks! hjmgr that has solved the problem but, here I struck with another one , I have uDEV simmulator which simmulates PIC graphically with the target circuit (for that it uses MPLAB templets) now, for that I have found a progamme on http://www.mstracey.btinternet.co.uk/pictutorial/progtut4.htm (it is about lighting an LED) which I have rewritten in the follwwing form .............



include 16F84

;*****Set up the Constants****

STATUS equ 03h
TRISA equ 85h
PORTA equ 05h
COUNT1 equ 08h
COUNT2 equ 09h

bsf STATUS,5
movlw 00h
movwf TRISA
bcf STATUS,5



Start:
movlw 02h
movwf PORTA



Loop1:
decfsz COUNT1,1
goto Loop1
decfsz COUNT2,1
goto Loop1


movlw 00h
movwf PORTA


Loop2:
decfsz COUNT1,1
goto Loop2 ;
decfsz COUNT2,1
goto Loop2;


goto Start;

;****End of the program****

end loop


which indicates many errors but I don't understand a single of them so if anyone can please help me !!!
 

AlexR

Joined Jan 16, 2008
732
I'm not an expert at assembler so won't comment on your actual program but you will drastically cut down the number of errors MPLab reports if you indent your commands by at least one character.

For some reason known only to Microchip only labels are allowed to start at the beginning of a line, everything else must be indented by at least one character.
 

Thread Starter

chrischristian

Joined Feb 22, 2008
43
Actually I made some progress after posting the thread now, the main problem is that I don't know how to add 16f84.inc file from MPLAB to uDEV.
 

Reshma

Joined Mar 11, 2007
54
Thanks! hjmgr that has solved the problem but, here I struck with another one , I have uDEV simmulator which simmulates PIC graphically with the target circuit (for that it uses MPLAB templets) now, for that I have found a progamme on http://www.mstracey.btinternet.co.uk/pictutorial/progtut4.htm (it is about lighting an LED) which I have rewritten in the follwwing form .............



include 16F84

;*****Set up the Constants****

STATUS equ 03h
TRISA equ 85h
PORTA equ 05h
COUNT1 equ 08h
COUNT2 equ 09h

bsf STATUS,5
movlw 00h
movwf TRISA
bcf STATUS,5



Start:
movlw 02h
movwf PORTA



Loop1:
decfsz COUNT1,1
goto Loop1
decfsz COUNT2,1
goto Loop1


movlw 00h
movwf PORTA


Loop2:
decfsz COUNT1,1
goto Loop2 ;
decfsz COUNT2,1
goto Loop2;


goto Start;

;****End of the program****

end loop


which indicates many errors but I don't understand a single of them so if anyone can please help me !!!
Can you post the copy of the build report?
However, these are the errors I could make out from your code:
1. There is no syntax called "end loop". It is just "end".
2. You have written decfsz COUNT1,1 which is wrong. The decrement is always done by subtracting '1', there is no need to specify '1'. Instead the correct syntax is: decfsz COUNT1,f where f is any register, in your case it is variable COUNT1 itself.

Good luck!
 

n9352527

Joined Oct 14, 2005
1,198
2. You have written decfsz COUNT1,1 which is wrong. The decrement is always done by subtracting '1', there is no need to specify '1'. Instead the correct syntax is: decfsz COUNT1,f where f is any register, in your case it is variable COUNT1 itself.

decfsz COUNT1, 1 is equivalent to decfsz COUNT1, F.
decfsz COUNT1, 0 is equivalent to decfsz COUNT1, W.

F is declared as 1 in the inc file, and W is declared as 0. So, it is a valid instruction and has nothing to do with the decrement step.
 

Thread Starter

chrischristian

Joined Feb 22, 2008
43
Well thanks both of you it has reduced some of the errors but, there are still 2 of them ...... :(:confused:



;**********************************************************************
; This file is a basic code template for assembly code generation *
; on the PICmicro PIC16F84A. This file contains the basic code *
; building blocks to build upon. *
; *
; If interrupts are not used all code presented between the ORG *
; 0x004 directive and the label main can be removed. In addition *
; the variable assignments for 'w_temp' and 'status_temp' can *
; be removed. *
; *
; Refer to the MPASM User's Guide for additional information on *
; features of the assembler (Document DS33014). *
; *
; Refer to the respective PICmicro data sheet for additional *
; information on the instruction set. *
; *
; Template file built using MPLAB V4.00 with MPASM V2.20 and *
; MPLINK 1.20 as the language tools. *
; *
;**********************************************************************
; *
; Filename: xxx.asm *
; Date: *
; File Version: *
; *
; Author: *
; Company: *
; *
; *
;**********************************************************************
; *
; Files required: *
; *
; *
; *
;**********************************************************************
; *
; Notes: *
; *
; *
; *
; *
;**********************************************************************


#include <p16F84.inc> ; processor specific variable definitions

__CONFIG _CP_OFF & _WDT_ON & _PWRTE_ON & _RC_OSC

; '__CONFIG' directive is used to embed configuration data within .asm file.
; The lables following the directive are located in the respective .inc file.
; See respective data sheet for additional information on configuration word.




;***** VARIABLE DEFINITIONS (examples)

; example of using Uninitialized Data Section
INT_VAR UDATA 0x0C
w_temp RES 1 ; variable used for context saving
status_temp RES 1 ; variable used for context saving

; example of using Overlayed Uninitialized Data Section
; in this example both variables are assigned the same GPR location by linker
G_DATA UDATA_OVR ; explicit address can be specified
flag RES 2 ; temporary variable (shared locations - G_DATA)

G_DATA UDATA_OVR
count RES 2 ; temporary variable (shared locations - G_DATA)




;**********************************************************************
RESET_VECTOR CODE 0x000 ; processor reset vector
goto start ; go to beginning of program


INT_VECTOR CODE 0x004 ; interrupt vector location
movwf w_temp ; save off current W register contents
movf STATUS,w ; move status register into W register
movwf status_temp ; save off contents of STATUS register


; isr code can go here or be located as a call subroutine elsewhere


movf status_temp,w ; retrieve copy of STATUS register
movwf STATUS ; restore pre-isr STATUS register contents
swapf w_temp,f
swapf w_temp,w ; restore pre-isr W register contents
retfie ; return from interrupt



MAIN CODE
start

nop ; code starts here (example)
banksel flag ; example
clrf flag ; example
; remaining code goes here
;*****Set up the Constants****

STATUS equ 03h ;Address of the STATUS register
TRISA equ 85h ;Address of the tristate register for port A
PORTA equ 05h ;Address of Port A
COUNT1 equ 08h ;First counter for our delay loops
COUNT2 equ 09h ;Second counter for our delay loops

;****Set up the port****

bsf STATUS,5 ;Switch to Bank 1
movlw 00h ;Set the Port A pins
movwf TRISA ;to output.
bcf STATUS,5 ;Switch back to Bank 0

;****Turn the LED on****

Start
movlw 02h ;Turn the LED on by first putting
movwf PORTA ;it into the w register and then ;on the port

;****Start of the delay loop 1****

Loop1
decfsz COUNT1,1 ;Sbtract 1 from 255
goto Loop1 ;If COUNT is zero, carry on.
decfsz COUNT2,1 ;Subtract 1 from 255
goto Loop1 start of our loop. This delay counts down from ;255 to zero, 255 times

;****Delay finished, now turn the LED off****

movlw 00h ;Turn the LED off by first putting
movwf PORTA ;it into the w register and then on ;the port

;****Add another delay****

Loop2 decfsz COUNT1,1 ;This second loop keeps the
goto Loop2 ;LED turned off long enough for
decfsz COUNT2,1 ;us to see it turned off
goto Loop2 ;

;****Now go back to the start of the program

goto Start ;go back to Start and turn LED ;on again

;****End of the program****










END ; directive 'end of program'






THESE ARE THE ERRORS:

Line 116: REGISTER IN OPERAND NOT IN BANK 0. ENSURE THAT BIT BANKS ARE CRRECT

Line 121 ADDRESS LABLE DUPLICATE OR DIFFERENTIN SECOND PASS (START)




I'm a layman and don't know what these error means, I know that AAC is not an online class room but, if you please clear these two erros then I can start my first programme at least in simmulation so can understand how actually progarmming MCU. :confused:
 

n9352527

Joined Oct 14, 2005
1,198
First error:
This is actually not an error, just a warning, to ensure that you use the correct bank. For example switching to bank 1 before accessing TRIS registers. The assembler does not exactly check that you've done that, it automatically issues a warning. You can turn this warning off if you want by including the following line in your source code:

errorlevel -302


Second error:
You have two address labels called start, one under the MAIN CODE and the other under the Turn the LED on. It is not allowed. In assembly, there is no differentiation based on the case. So, Start and start are the same.
 

Thread Starter

chrischristian

Joined Feb 22, 2008
43
THANK YOU !:):) n9352527 but, I still have an error saying ...

ERROR : FILE COULD NOT FOUND F84atempo.o

I think it has something to do with including the file 16f84.inc as in an example given in uDEV there shows an included file for respective PIC, but don't know how to do that.
 

Reshma

Joined Mar 11, 2007
54
THANK YOU !:):) n9352527 but, I still have an error saying ...

ERROR : FILE COULD NOT FOUND F84atempo.o

I think it has something to do with including the file 16f84.inc as in an example given in uDEV there shows an included file for respective PIC, but don't know how to do that.
I think it is asking for the linker file. As n9352527 said, you can search for it in the MPLAB installation files. The linker file converts the object file to hex file. Before building your project, I hope you included the linker file along with the .asm file.
 

Thread Starter

chrischristian

Joined Feb 22, 2008
43
Though, this is my first MCU project,I think the linker file has allready there as the simmulator (MICRO DEV) I am using opens automaticaly the MPLAB template, and in the file inclusion window it shows support only for .asm file so,can't include any other file NOT THIS f84atempo.o thing,even though when I build the project there appears f84atempo.o file along with f84atempo.err and f84atempo.LST files in C:\Program Files\MPLAB IDE\MCHIP_Tools\TEMPLATE\Object and also in my TC directory (I don't get that what C/C++ has to do with this:mad:),SO, what is this f84atempo is all about ........Actually I'dont know that either I should laugh at this or feel confused about but one thing is quite certain, IT IS GIVING ME HEADACHE! any way, thank you very much for your time (does'nt mean you give up helping me:))
 

Reshma

Joined Mar 11, 2007
54
Though, this is my first MCU project,I think the linker file has allready there as the simmulator (MICRO DEV) I am using opens automaticaly the MPLAB template, and in the file inclusion window it shows support only for .asm file so,can't include any other file NOT THIS f84atempo.o thing,even though when I build the project there appears f84atempo.o file along with f84atempo.err and f84atempo.LST files in C:\Program Files\MPLAB IDE\MCHIP_Tools\TEMPLATE\Object and also in my TC directory (I don't get that what C/C++ has to do with this:mad:),SO, what is this f84atempo is all about ........Actually I'dont know that either I should laugh at this or feel confused about but one thing is quite certain, IT IS GIVING ME HEADACHE! any way, thank you very much for your time (does'nt mean you give up helping me:))
Umm...have you selected the device properly? Your program code uses the device 16f84 but the error is about 16f84a. Just check if the correct device has been selected or recheck the configuration (fuse) settings.
This is the format normally used:
Rich (BB code):
               PROCESSOR 16F84,  F=INHX8M
               include "P16f84.inc"
             __CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC
 

Thread Starter

chrischristian

Joined Feb 22, 2008
43
I still recive the error so, I decieded to build the same file ( with 16f84a) in MPLAB insted of MICRO DEV this time I have selected the right device but there is an error:........

Error - section 'INT_VECTOR' can not fit the absolute section. Section 'INT_VECTOR' start=0x00000004, length=0x00000010
Errors : 1


what is this mean?

By the way, I searched for 16f84.asm (not 16f84a) and .lik files in MPLAB directory but, could'nt find it, I even tried re - installation of MPLAB but there is no such file!!!, don't know what's the problem. I'm not a supertitious person but now, my MPLAB has no file for 16f84 one of the most widely used PICs:eek:. I think I really struck with BAD LUCK!
 

n9352527

Joined Oct 14, 2005
1,198
The object files are f84tmpo.asm or f84atmpo.asm, without 16. The linker files are 16f84.lkr or 16f84a.lkr.

You have to modify the linker file to get rid of that INT_VECTOR error, for an example see the MPLIB help and search for this topic: Sample Application 1 - Modifying the Linker Script.
 

Thread Starter

chrischristian

Joined Feb 22, 2008
43
I found linker script cavities in MPLAB help but, don't understand how to use it , it says something about spliting the memory pages as my codes contain goto instruction but don't understand what it means.
 

Thread Starter

chrischristian

Joined Feb 22, 2008
43
Need not to reply the previous post I got it, just it needed more space in registors (not 0*000*4 but,0*0010):) now, I have some quaries:

What if I want to programme PIC(any!) without these MPLAB templets is it possible?
Can I simmulate the project graphically ? i.e.: visual indication of LED blinking with target circuit , Like MICRO DEV does.
 

Reshma

Joined Mar 11, 2007
54
Need not to reply the previous post I got it, just it needed more space in registors (not 0*000*4 but,0*0010):) now, I have some quaries:

What if I want to programme PIC(any!) without these MPLAB templets is it possible?
Can I simmulate the project graphically ? i.e.: visual indication of LED blinking with target circuit , Like MICRO DEV does.
I hope you were able to solve the linker file problem.

If you want to simulate a PIC programme, you must generate a hex file which is loaded into the simulator. For creating the hex file your PIC project must include the header files, library functions, linker file, etc. There are various simulators available but most require the hex file.
 

Thread Starter

chrischristian

Joined Feb 22, 2008
43
First, let me thank all of you specialy, n9352527 and Reshma for helping me with getting started with PIC project now, it shows bit reciving at desired port in MPLAB SIM and I start understanding how to handel data for programing PIC:). As far as the visual simmulation is concerend, I do know that, it requires to add header files, Library files and Object files but , I don't understand how to do that, there are no such files in MAPLAB directory , there are folders named Lib, Object but the lib folder is empty and Object folder contains only .asm files, and there is no folder specifying header files at all !
 
Top