• AVR Freaks

Hot!SFR Banked and Aceess issues for Newbie to PIC18f

Author
tonycarbon
New Member
  • Total Posts : 5
  • Reward points : 0
  • Joined: 2020/01/14 03:00:13
  • Location: 0
  • Status: offline
2020/01/17 05:20:08 (permalink)
0

SFR Banked and Aceess issues for Newbie to PIC18f

Hello
 
My first post, appolgies in advance if my question is not in the right sub-forum.
 
I have been programming PIC16F883 for quite some years, and have a fairly good understanding of
programming this the PIC16 range.
But I have now had to upgrade to a PIC18f27K42 for various reasons [ more storage RAM ]
 
I am now in the process of re-writing my assembler code for the PIC18f series.
The problem I am coming against is the the Banking and Access bank aspect of SFRs
Previoulsy I have used BANKSEL for my PIC16f code, but having read and re-read the
PIC18f data sheet, I have seen that the PIC18f has an ACCESS bank to make life easier, or so I thought.
 
My understanding is that some SFRs such as ADRESH or T2PR are mapped into the ACCESS bank,
and that I will not need to set a BANKSEL or MOVLB command for instructions involving these registers.
 
When using MPLABx IDE V5.1, I seem to be getting inconsistant results with instructions involving
registers that are mapped to the ACCESS bank.
 
I have two subroutines that write to ADPCH and PWM6DCH SFRs which are both in the ACCESS bank.
When I run my code in the Simulator, the first routine does not update ADPCH, but does
update PWM6DCH.
But both SRFs are in the ACCESS bank, so I am not sure where I am going wrong.
 
Is the MPLABX Assembler not good to trust for chosing Banked or Access ?
Should I add lots of BANKSEL/MOVLB to my code instead ?
 
Appologies for not formatting this to Code, but I cant seem to find how to do that.
 
 
temporead  
    MOVLW        b'00001000'        ; Select input ANBO TEMPO
    MOVWF       ADPCH
    CALL           DoADConversion  
    MOVF         ADRESH,w       
    MOVWF      CVTEMP
    RETURN
 
pwamwait3   
    MOVF        TEMP,w
    MOVWF     PWM6DCH        ; set MSB duty cycle 
    MOVF        TEMP2,w
    MOVWF      PWM6DCL        ; set LSB duty cycle
    RETURN
 
Thanks for any light on this.
 
#1

4 Replies Related Threads

    GeorgePauley
    Moderator
    • Total Posts : 1268
    • Reward points : 0
    • Joined: 2009/12/01 13:59:30
    • Location: Chandler AZ
    • Status: offline
    Re: SFR Banked and Aceess issues for Newbie to PIC18f 2020/01/17 10:54:23 (permalink)
    0
    Reading the datasheet (DS40001919B-page47) it would appear that ADRESH at address 0x3EF1 is NOT in the access bank (0x3F60-0x3FFF)

    Attached Image(s)

    #2
    tonycarbon
    New Member
    • Total Posts : 5
    • Reward points : 0
    • Joined: 2020/01/14 03:00:13
    • Location: 0
    • Status: offline
    Re: SFR Banked and Aceess issues for Newbie to PIC18f 2020/01/17 11:29:36 (permalink)
    0
    Hello

    Thanks for the reply.
    But what is ADRESH_M1 in the DMA Access map on page 48 ?
    Isn’t that the mapped version of ADRESH ?
    #3
    GeorgePauley
    Moderator
    • Total Posts : 1268
    • Reward points : 0
    • Joined: 2009/12/01 13:59:30
    • Location: Chandler AZ
    • Status: offline
    Re: SFR Banked and Aceess issues for Newbie to PIC18f 2020/01/17 13:07:02 (permalink)
    0
    Note 1 from page 48:  Addresses in Bank 64 are accessible ONLY through DMA Source and Destination Address Registers.  CPU does not have access to registers in Bank 64.

    So it would appear that these registers are only accessible via the DMA peripheral.  You would have to set up the DMA by writing appropriate values to the DMA registers.  This would certainly be more work than just doing a BANKSEL.  And, to be honest, I'm not sure the simulator "knows" about bank 64 and it's relationship to DMA.
    #4
    tonycarbon
    New Member
    • Total Posts : 5
    • Reward points : 0
    • Joined: 2020/01/14 03:00:13
    • Location: 0
    • Status: offline
    Re: SFR Banked and Aceess issues for Newbie to PIC18f 2020/01/17 13:53:18 (permalink)
    0
    Hello

    Thanks very much for the help.

    I was confusing the DMA to be the Access Bank.

    Now I understand.
    Thanks
    #5
    Jump to:
    © 2020 APG vNext Commercial Version 4.5