Problem with ASM IRQ using FSR0 on PIC18F252


Closed Thread
Results 1 to 11 of 11

Hybrid View

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


    Did you find this post helpful? Yes | No

    Default

    SWEET, I'm glad that worked for you.

    Let's see here, LFSR. It stands for "Load File Select Register" or Load FSR.

    It takes a 12-bit constant and loads the low byte in FSRxL and the highbyte in FSRxH. It does it in 2 instruction cycles, and doesn't care what bank of memory is selected by BSR at the time.

    Using the "old way" movf / movwf you first need to select the proper bank (or use the "a" option to select the access bank) then use 4 instruction cycles to accomplish the same thing.

    While your program wasn't large enough to worry about bank switching, sometimes is has to be handled manually.

    The 18F's have several new Opcodes that can make life easier. MOVFF is one of the best. For a complete list, see the "Instruction Set Summary" towards the end of the datasheet for the device you are using. I know..., I hate being told to RTFM too, but sometimes ya gotta do it.

    regards,
       Darrel

  2. #2
    mytekcontrols's Avatar
    mytekcontrols Guest


    Did you find this post helpful? Yes | No

    Thumbs up

    The 18F's have several new Opcodes that can make life easier. MOVFF is one of the best. For a complete list, see the "Instruction Set Summary" towards the end of the datasheet for the device you are using. I know..., I hate being told to RTFM too, but sometimes ya gotta do it.
    Your right, I found the reference in the data sheet (Stupid me I guess I just got a litle lazy). Thanks again for all the help.

  3. #3
    jmen's Avatar
    jmen Guest


    Did you find this post helpful? Yes | No

    Unhappy using the code at a pic 18f452

    I have tried to use the code on a 18f452 - but it dont works... At the beginnig there were many error messages from the Compiler.
    Therefore I´ve done the following modifications:
    1.changed the rrf instructions to rrcf
    2.changed the rlf instructions to rrcf
    3.at "enc_exit" I changed
    "bsf _AUTOdispNEW ; flag that encoder value has changed"
    to
    "bsf _AUTOdispNEW,0 ; flag that encoder value has changed"
    4. I defined the following Variables:

    TMR1ON VAR BIT
    TMR1IF Var BIT
    TMR1IE VAR BIT
    TMR1IP VAR BIT
    IPEN VAR BIT

    TMR1ON = T1CON.0
    TMR1IF = PIR1.0
    TMR1IE = PIE1.0
    TMR1IP = IPR1.0
    IPEN = RCON.7
    Now it compiles well, but do not work :-(
    To tell the truth I have no expirience with assembler but I have to decode the quadencoder and with PBP I´m loosing counts.

    Thanks in advance
    Jan

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


    Did you find this post helpful? Yes | No

    Default

    Hi Jan,

    Those variables aren't working the way you think. For instance:

    TMR1ON VAR BIT
    TMR1ON = T1CON.0

    Creates a separate BIT variable, and then puts the value of T1CON.0 in it. It doesn't assign T1CON.0 the the name TMR1ON.

    Try doing it this way.

    TMR1ON VAR T1CON.0
    TMR1IF Var PIR1.0
    TMR1IE VAR PIE1.0
    TMR1IP VAR IPR1.0
    IPEN VAR RCON.7<br><br>
    DT

  5. #5
    jmen's Avatar
    jmen Guest


    Did you find this post helpful? Yes | No

    Talking working!

    I´m realy a fool! I changed the wrong variable declaration to aliases as you suggested - now it´s working!!
    thanks a lot, you´ve saved my life!!
    Another short question...
    When i have declared a variable as word - how do I assign a value like 1000 to it or better a value from anoter variable or constant?

    In PBP I would do:
    <pre>resetValue CON 1000
    counter = resetValue</pre>
    or:
    <pre>resetValue VAR WORD
    resetValue = 1000
    counter = resetValue</pre>
    In ASM: ??
    <pre>MOVFF _resetValue, _counter</pre>
    You see I´m a real beginner in ASM :-(

    regards,
    Jan

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


    Did you find this post helpful? Yes | No

    Default

    Hey, don't worry about it Jan. I think I made the same mistake in the beginning.

    To move 1 word var to another using movff might look like this ...

    MOVFF _resetValue, _counter
    MOVFF _resetValue+1, _counter+1

    but that will only work with 2 variables. movff won't work with constants.

    The easiest way to copy things from 1 place to another is using the MOVE?xx macro's. Take a look at this post for more info.

    https://www.picbasic.co.uk/forum/showthread.php?p=2009

    The MOVE?xx macro's will take care of all the bank switching (if required) the same way that PBP does it. <br><br>
    DT

Similar Threads

  1. Instant Interrupts - Revisited
    By Darrel Taylor in forum Code Examples
    Replies: 772
    Last Post: - 17th February 2016, 22:14
  2. PBP, ASM and LST files
    By HenrikOlsson in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 12th January 2010, 13:43
  3. Problem using ASM instruction
    By ewandeur in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 3rd April 2008, 15:26
  4. pic18f252 hserout problem
    By edysan in forum Serial
    Replies: 4
    Last Post: - 16th June 2006, 20:46
  5. problem with asm interrupt
    By servo260 in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 20th December 2004, 17:02

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