Continue to Site

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.

  • 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 building codes from nigel tutorial

Status
Not open for further replies.

folarinv

New Member
1) I copied some codes from Nigel tutorial page onto the MPLAB code editor and I tried to run it but I keep getting an error complain from the assembler:

MPLINK 3.94, Linker
Copyright (c) 2005 Microchip Technology Inc.
Error - section 'INT_VECTOR' can not fit the absolute section. Section 'INT_VECTOR' start=0x00000004, length=0x00000010
Errors : 1

BUILD FAILED: Thu Jul 12 01:33:03 2001

2) According to the MPLAB tutorial, if I double click on the error the editor should take me to the line responsible for the error but that did not happen when I tried to build these codes.


Below is the code:

;Tutorial 1.1 - Nigel Goodwin 2002
LIST p=16F628 ;tell assembler what chip we are using
include "P16F628.inc" ;include the defaults for the chip
__config 0x3D18 ;sets the configuration settings (oscillator type etc.)

org 0x0000 ;org sets the origin, 0x0000 for the 16F628,
;this is where the program starts running
movlw 0x07
movwf CMCON ;turn comparators off (make it like a 16F84)

bsf STATUS, RP0 ;select bank 1
movlw b'00000000' ;set PortB all outputs
movwf TRISB
movwf TRISA ;set PortA all outputs
bcf STATUS, RP0 ;select bank 0

Loop
movlw 0xff
movwf PORTA ;set all bits on
movwf PORTB
nop ;the nop's make up the time taken by the goto
nop ;giving a square wave output
movlw 0x00
movwf PORTA
movwf PORTB ;set all bits off
goto Loop ;go back and do it again

end
 
The code assembles fine using MPASM, the MicroChip assembler, I never use MPLAB (which simply calls MPASM to assemble anyway).

There's no interrupt vector in the program, because it doesn't use interrupts, you may have MPLAB configured incorrectly?, or be using it incorrectly?, someone who uses MPLAB should be able to advise you.
 
If you remove the linker script from the project I suspect this problem will go away...

Good luck... Regards, Mike
 
linker script and MPLAB

Mike said:
If you remove the linker script from the project I suspect this problem will go away...

Good luck... Regards, Mike

Thanks very much mike.

I removed the linker script, opened a new page on the assembler then copied nigel's codes to the page and it build successfully.

..but just for sake of knowing. what could be the function of the linker. why would microchip put it there when i dont need it
 
Trust me, it is very important. Nigel is simply not using it (due to simplicity or just a habit of using MPASM only).
MPLINK linker performs many functions:

Locates Code and Data. The linker takes as input relocatable object files. Using the linker script, it decides where the code will be placed in program memory and where variables will be placed in RAM.

Resolves Addresses. External references in a source file generate relocation entries in the object file. After the linker locates code and data, it uses this relocation information to update all external references with the actual addresses.

Generates an Executable. Produces a .hex file that can be programmed into a PICmicro MCU or loaded into an emulator or simulator to be executed.

Configures Stack Size and Location. Allows MPLAB C18 to set aside RAM space for dynamic stack usage.

Identifies Address Conflicts. Checks to ensure that program/data do not get assigned to space that has already been assigned or reserved.

Provides Symbolic Debug Information. Outputs a file that MPLAB IDE uses to track address labels, variable locations, and line/file information for source level debugging
 
If you're authoring 'absolute' code instead of 'relocatable' code, the Linker is not required...

Regards, Mike
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top