Quantcast

Maximum PC

It is currently Mon Sep 01, 2014 10:28 am

All times are UTC - 8 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Blinking LED project in Assemply language for PIC18f4520
PostPosted: Tue Sep 01, 2009 2:20 pm 
8086
8086

Joined: Tue Sep 01, 2009 2:09 pm
Posts: 1
Hello everybody currently I am taking a microprocessors class in college which is part of my major, Electronics Technology. I have stumbled upon a problem when compiling my code to burn onto the chip.

I am using the MPLAB IDE suite.

When i do a build all, my source code seems to be fine except one thing I get an error that says,

Code:
Error - file './BLED2.o', section 'RESET_VECTOR', Symbol '_RESET_VECTOR_0046' is not word-aligned.
It can not be used as the target of a call or goto instruction.


Here is my source,

Code:
   LIST P=18F4520, F=INHX32 ;directive to define processor and file format
   #include <P18F4520.INC>    ;processor specific variable definitions

;******************************************************************************
;Configuration bits
;Microchip has changed the format for defining the configuration bits, please
;see the .inc file for futher details on notation.  Below are a few examples.

    CONFIG   OSC = INTIO67   ;Oscillator Selection:
   CONFIG   WDT = OFF       ;turns watch dog counter off     

;******************************************************************************
;Reset vector
; This code will start executing when a reset occurs.
RESET_VECTOR   CODE   0x00000
   GOTO   START      ;go to start of main code

;******************************************************************************
;Start of main program
; The main program code is placed here.

   cblock
      d1
      d2
      d3
   endc


START      
         
   movlw      0x00            ;Loads literal value of hex 0 into working registry
   movwf       TRISB            ;Defines port b as output
   movlw      B'00000010'         ;Loaded a value of one
   movwf      PORTB            ;Moves the value of one to port b
   movlw      0x08            ;move hex 8 to wreg
   movwf      d1               ;cblock d1
   movlw      0x2F            ;move hex value 215
   movwf      d2               ;cblock d2
   movlw      0x03            ;move hex value 3
   movwf      d3               ;cblock d3
   call      Delay_0            ;delay
   movlw      0x00            ;moves literal value of hex 0 into working registry
   movlw      0x08            ;move hex value 8
   movwf      d1               ;cblock d1
   movlw      0x2F            ;move hex 215
   movwf      d2               ;cblock d2
   movlw      0x03            ;hex 3
   movwf      d3               ;cblock d3   
   call      Delay_0                  
   movwf      PORTB            ;moves contents of file registry to port b
   goto      START

Delay_0
   
   decfsz      d1, f            ;decrement f if zero for d1
   goto      $+2               ;go up two lines
   decfsz      d2, f            ;decrement f if zero for d2
   goto      $+2               ;move up 2 lines
   decfsz      d3, f            ;decrement d3
   goto      Delay_0            ;go to Delay_0 line

         
   goto   $+1                  ;go up one line
   nop                        ;does nothing, wastes 1 uS

   return

   END                        ;end of program


Any help is appriciated.


What really gets at me is I had everything working and the professor looked at it burnt it to the PIC and it would light up the LED but my delay didn't delay long enough so any human could not see it blink. I verified that it was indeed blinking by hooking it up to an oscilloscope. So my professor just changed my delay statements and then bang we get this error and cannot figure it out to save our lives.

Thank you


Top
  Profile  
 
 Post subject:
PostPosted: Mon Sep 14, 2009 3:55 pm 
Team Member [Top 500]*
Team Member [Top 500]*
User avatar

Joined: Thu Jun 24, 2004 2:22 pm
Posts: 8722
Location: Cleveland, Ohio
Since your post has gone sometime without a reply I'll suggest THIS FORUM as it has a strong PIC crowd. They focus on electronics (Nuts & Volts) and have a section devoted to PIC. Hopefully that will help with your course.

Ron


Top
  Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 8 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group