problem writing to PCL PIC16f877


Closed Thread
Results 1 to 6 of 6

Hybrid View

  1. #1
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    It's OK to ask about Assembly language questions, especially when it's in the General category like you've posted it.
    Quote Originally Posted by quentin View Post
    Hi

    For some reason I am unable to write to PCL when simulating the most basic code in MPLAB.
    A computed goto should also set PCLATH before changing PCL.

    In your case, PCLATH has not been set, and when you add 10h to PCL, instead of jumping forward 16 addresses (0x0121), it will jump to (0x0021) which is in the middle of the bootloader.

    But when simulating it in MPLAB, there is no bootloader, so that range of addresses is outside the range of compiled code.

    Still not sure what you want to do ... a computed goto or a Table lookup, but if it's the latter, this might help ...
    Code:
    	list p = 16f877a
    	include <p16f877a.inc>
    
    
    ;******Vectors***********************************
    
    	org 0x0100	;reset vector address
    	goto Main
    	org 0x0110	; start writing program from this address
    
    ;******Main Program******************************
    
    Main
        movlw   high(table)
        movwf   PCLATH
        movlw   010h
        call    table
        goto    Main
    
    table
        addwf   PCL,f
        retlw   .0
        retlw   .1
        retlw   .2
        retlw   .3
        retlw   .4
        retlw   .5
        retlw   .6
        retlw   .7
        retlw   .8
        retlw   .9
        retlw   .10
        retlw   .11
        retlw   .12
        retlw   .13
        retlw   .14
        retlw   .15
        retlw   .16
        retlw   .17
        retlw   .18
        retlw   .19
        retlw   .20
        retlw   .21
        retlw   .22
    
        end
    DT

  2. #2
    Join Date
    Sep 2009
    Posts
    3


    Did you find this post helpful? Yes | No

    Default

    I get it thank you.

Similar Threads

  1. PIC KIT 2 writing problem ?
    By KaanInal in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 3rd January 2010, 13:59
  2. pic16f877 problem repeating serial data
    By TomRiddle in forum Serial
    Replies: 2
    Last Post: - 6th February 2008, 14:56
  3. Mutliple ADC problem with PIC16F877
    By andyto in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 3rd October 2007, 18:47
  4. Problem on writing EEPROM in Winpic800 with picbasic pro
    By selimkara in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 4th May 2007, 17:33
  5. Writing / Reading EEPROM 24LC256 Problem
    By schmoddel in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 27th February 2004, 19:55

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts