• AVR Freaks

Hot!Question re banked RAM in enhanced midrange PIC

Author
John P
Starting Member
  • Total Posts : 17
  • Reward points : 0
  • Joined: 2009/11/23 10:19:30
  • Location: 0
  • Status: offline
2020/09/18 13:42:35 (permalink)
0

Question re banked RAM in enhanced midrange PIC

I'm using a PIC16F18345, and the spec sheet says it has 1K of general purpose RAM. You can use this in banked mode with 80 bytes per bank, or as a linear space accessed via memory pointers FSR0and FSR1. If there really is 1K (1024 bytes) of RAM I'm wondering how this works in banked mode. There are 32 banks with 80 general-purpose bytes in each bank, so that would work out to 2560 bytes, which is more than the spec sheet says the chip has. If it really has 1024 bytes, there would be 80 bytes in each of banks 0-11, then 64 bytes in bank 12, and beyond that it would be "Unimplemented memory will read as ‘0’." Is this actually the way it works? The data sheet just doesn't say. I suppose I could write a program to test the upper RAM and see what's readable and writeable, but does someone already know what the chip has available?
#1

10 Replies Related Threads

    1and0
    Access is Denied
    • Total Posts : 11325
    • Reward points : 0
    • Joined: 2007/05/06 12:03:20
    • Location: Harry's Gray Matter
    • Status: offline
    Re: Question re banked RAM in enhanced midrange PIC 2020/09/18 13:59:49 (permalink)
    0
    John P
    I'm using a PIC16F18345, and the spec sheet says it has 1K of general purpose RAM. You can use this in banked mode with 80 bytes per bank, or as a linear space accessed via memory pointers FSR0and FSR1. If there really is 1K (1024 bytes) of RAM I'm wondering how this works in banked mode. There are 32 banks with 80 general-purpose bytes in each bank, so that would work out to 2560 bytes, which is more than the spec sheet says the chip has. If it really has 1024 bytes, there would be 80 bytes in each of banks 0-11, then 64 bytes in bank 12, and beyond that it would be "Unimplemented memory will read as ‘0’." Is this actually the way it works? The data sheet just doesn't say. I suppose I could write a program to test the upper RAM and see what's readable and writeable, but does someone already know what the chip has available?

    For 1024 bytes of RAM, that would be 1008 bytes banked RAM and 16 bytes common RAM. 1008/80 = 12.6 so there should be 80 bytes each for Bank 0 to Bank 11, and 48 bytes in Bank 12.
    #2
    upand_at_them
    Super Member
    • Total Posts : 681
    • Reward points : 0
    • Joined: 2005/05/16 07:02:38
    • Location: Pennsylvania
    • Status: offline
    Re: Question re banked RAM in enhanced midrange PIC 2020/09/18 15:17:59 (permalink)
    +1 (1)
    Wow, the datasheets keep getting worse.
     
    If it's like the PIC16F1825, there are 80 bytes in banks 0-11.  48 bytes in bank 12.  And 16 common bank bytes.
    #3
    John P
    Starting Member
    • Total Posts : 17
    • Reward points : 0
    • Joined: 2009/11/23 10:19:30
    • Location: 0
    • Status: offline
    Re: Question re banked RAM in enhanced midrange PIC 2020/09/18 15:52:46 (permalink)
    0
    I assumed the common RAM wasn't part of the 1K, but maybe that's wrong. Either way, Microchip is just being unclear about this issue.
    #4
    1and0
    Access is Denied
    • Total Posts : 11325
    • Reward points : 0
    • Joined: 2007/05/06 12:03:20
    • Location: Harry's Gray Matter
    • Status: offline
    Re: Question re banked RAM in enhanced midrange PIC 2020/09/18 16:02:39 (permalink)
    0
    John P
    I assumed the common RAM wasn't part of the 1K, but maybe that's wrong. Either way, Microchip is just being unclear about this issue.

    The 1024 is the total bytes of RAM -- banked and common.  The common RAM is NOT part of the linear data memory.
     
    #5
    ric
    Super Member
    • Total Posts : 28660
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: Question re banked RAM in enhanced midrange PIC 2020/09/18 16:38:26 (permalink)
    +1 (1)
    When the first lot of ehanced midrange chips came out, the datasheet showed all the RAM and how it was used.
    See: from page 24 in the PIC16F1829 datasheet
     http://ww1.microchip.com/downloads/en/DeviceDoc/40001440E.pdf#page=24 

    I guess there's just too much RAM and SFRs to show it all now. The latest datasheets spend many pages just showing the SFRs in each bank.
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #6
    NorthGuy
    Super Member
    • Total Posts : 6350
    • Reward points : 0
    • Joined: 2014/02/23 14:23:23
    • Location: Northern Canada
    • Status: online
    Re: Question re banked RAM in enhanced midrange PIC 2020/09/18 17:11:37 (permalink)
    0
    Memory maps are very handy. I've seen full memory maps in the datasheets for newer parts. PIC16F18877 shows the whole map even though there are lots of banks. Perhaps, my datasheet is too old (DS40001825B) and newer versions have been improved.
    #7
    ric
    Super Member
    • Total Posts : 28660
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: Question re banked RAM in enhanced midrange PIC 2020/09/18 18:24:03 (permalink)
    +1 (1)
    They are still present in version D
     http://ww1.microchip.com/downloads/en/DeviceDoc/PIC16LF18857-77-Data-Sheet-40001825D.pdf#page=40 

     

    and newer versions have been improved.

    I find that later versions tend to have been "prettied up" by graphic designers, which often means discarding messy "information" ...
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #8
    upand_at_them
    Super Member
    • Total Posts : 681
    • Reward points : 0
    • Joined: 2005/05/16 07:02:38
    • Location: Pennsylvania
    • Status: offline
    Re: Question re banked RAM in enhanced midrange PIC 2020/09/18 18:33:48 (permalink)
    0
    ricI find that later versions tend to have been "prettied up" by graphic designers, which often means discarding messy "information" ...

     
    Like an index!
     
    #9
    John P
    Starting Member
    • Total Posts : 17
    • Reward points : 0
    • Joined: 2009/11/23 10:19:30
    • Location: 0
    • Status: offline
    Re: Question re banked RAM in enhanced midrange PIC 2020/09/18 20:38:23 (permalink)
    0
    Thanks for the responses, guys. Ric, you were right. The PIC16F1829 datasheet does show grayed-out blocks in the diagrams of many of the banks, showing which blocks of RAM are not implemented. For the PIC16F18345, they don't do this, and only show the SFR registers in the lowest 32 bytes of each bank, with no indication of which banks have active RAM.
     
    Well, I couldn't resist making the experiment. I set up a write-read to each byte of RAM in sequence, using the banked method, and it turned out exactly as you said, 1and0. The memory was functional up to byte 0x4F in bank 12, and above that it just read zeroes. That would be 80 bytes in each of banks 0-11, i.e. 960 bytes. Then from 0x20 to 0x4F in bank 12, for another 48 bytes. Add the 16 bytes of common RAM, and the total is 1024, just as they promise.
     
    Mystery solved. Thanks again.
     
    NorthGuy, I use a bootloader with the PIC16F18345 chips, but of course the bootloader itself has to be installed (and re-installed, if it has an accident). For that I use the programmed PIC16F1454 chip I bought from your company several years ago--it's still working fine.
    post edited by John P - 2020/09/18 20:42:17
    #10
    NorthGuy
    Super Member
    • Total Posts : 6350
    • Reward points : 0
    • Joined: 2014/02/23 14:23:23
    • Location: Northern Canada
    • Status: online
    Re: Question re banked RAM in enhanced midrange PIC 2020/09/19 20:26:55 (permalink)
    0
    John P
    NorthGuy, I use a bootloader with the PIC16F18345 chips, but of course the bootloader itself has to be installed (and re-installed, if it has an accident). For that I use the programmed PIC16F1454 chip I bought from your company several years ago--it's still working fine.



    Great! Thank you for sharing.
    #11
    Jump to:
    © 2020 APG vNext Commercial Version 4.5