Readcode in asm


Closed Thread
Results 1 to 4 of 4

Thread: Readcode in asm

Hybrid View

  1. #1
    Join Date
    Nov 2005
    Posts
    10

    Default Readcode in asm

    Hi,
    I try to learn more about picbasicpro and asm.

    I want to read out a byte on location $fff in the program code. The pic I use can do this with
    readcode $fff, adrs ;place byte on location $fff into var adrs

    I htought to do it like this;

    bcf STATUS,RP0
    bsf STATUS,RP1
    MOVLW 0x0F
    MOVWF PMADRH
    MOVLW 0xFF
    MOVWF PMADR
    BSF STATUS, RP0 ; Bank 3
    BSF PMCON1, RD
    NOP
    NOP
    BCF STATUS, RP0 ; Bank 2
    MOVF PMDATA, W
    movwf dmxlowbyte
    MOVF PMDATH, W
    movwf dmxhighbyte

    Does it contain a mistake?
    Last edited by joeri; - 26th January 2008 at 16:26.

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


    Did you find this post helpful? Yes | No

    Default

    That's pretty much just like the datasheet says.

    The only thing I would recommend is to reset PBP's banking system, since you've changed the bank manually.
    Code:
        clrf  STATUS
    PREV_BANK = 0
    DT

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


    Did you find this post helpful? Yes | No

    Default

    Just noticed something else.

    The dmxlowbyte and dmxhighbyte variables will have to be in BANK2 for it to work.
    <br>
    DT

  4. #4
    Join Date
    Nov 2005
    Posts
    10


    Did you find this post helpful? Yes | No

    Smile

    Thank you!
    It was indeed a mistake from me, not to change back to bank0 to write te w into the variables.
    Instead of defining the variables in bank 2, I switch back to bank 0:

    BCF STATUS,RP0 ;bank2
    BSF STATUS,RP1
    MOVLW 0x0F
    MOVWF PMADRH
    MOVLW 0xFF
    MOVWF PMADR
    BSF STATUS, RP0 ; Bank 3
    BSF PMCON1, RD ; EEPROM Read
    NOP
    NOP
    BCF STATUS, RP0 ; Bank 2
    MOVF PMDATA, W
    BCF STATUS,RP1 ;bank0
    movwf dmxlowbyte ; range is [0 255]
    BSF STATUS,RP1 ;bank2
    MOVF PMDATH, W
    BCF STATUS,RP1 ;bank0
    movwf dmxhighbyte
    clrf STATUS ;ga naar bank0

Similar Threads

  1. Quadrature encoder and ASM Interrupts. questions..
    By godfodder in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 17th March 2013, 14:45
  2. PBP, ASM and LST files
    By HenrikOlsson in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 12th January 2010, 13:43
  3. ASM help
    By Charles Linquis in forum mel PIC BASIC Pro
    Replies: 16
    Last Post: - 21st October 2009, 03:08
  4. Message String Table using Readcode
    By mytekcontrols in forum Code Examples
    Replies: 2
    Last Post: - 10th July 2005, 23:17
  5. Can an asm interrupt contain gosub to a picbasic routine?
    By sougata in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 21st April 2005, 19:49

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