• AVR Freaks

PIC16F630 - Read from Flash and do a checksum.

Author
evalmode
New Member
  • Total Posts : 4
  • Reward points : 0
  • Joined: 2012/08/28 04:03:20
  • Location: 0
  • Status: offline
2020/06/02 18:33:00 (permalink)
0

PIC16F630 - Read from Flash and do a checksum.

Hi Guys,
I have been try to use Hitech C to read from the flash but not able to read the contents. I can do it for RAM without a problem.
RAM location starts from 20h and end at 5Fh and its 64 bytes. E.g. I set a pointer at ROM location 0E0h like the following
 
unsigned int *rom_addr, rom_value;
rom_addr = 0xE0h;
rom_value = *rom_addr;
 
Compiles just fine. Does not give me the opcode/value in the flash. However, if the value of the rom_addr is changed to 0x20H it works just fine.
 
I need to know how to read the the ROM area so that I can do a checksum for PIC16F630
 
Any Help is much appreciated., Also if you tell me its not possible...that is bad, but also if you can share why would be helpful as well.
 
Thanks.
#1

5 Replies Related Threads

    ric
    Super Member
    • Total Posts : 27629
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: PIC16F630 - Read from Flash and do a checksum. 2020/06/02 19:22:06 (permalink)
    +2 (2)
    I think you have forgotten that the PIC uses "Harvard Architecture", so RAM and ROM are on seperate busses each with their own address space. You can't just load a pointer with an arbitrary value and expect to access ROM.
    Some PICs are able to read ROM space via the EEPROM access registers, but not the PIC16F630.
    This chip simply does not have the hardware to permit you to read arbitrary addresses in ROM.
     
    Do you really have to stick with this old PIC? Newer devices are more powerful, and cheaper.
     

    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!
    #2
    evalmode
    New Member
    • Total Posts : 4
    • Reward points : 0
    • Joined: 2012/08/28 04:03:20
    • Location: 0
    • Status: offline
    Re: PIC16F630 - Read from Flash and do a checksum. 2020/06/02 22:08:03 (permalink)
    0
    Hi ric,
     
    Thanks for the reply. It seems Microchip has a newer device which is a drop in for PIC16F18324. However, it seems to be also only allow access to data memory. Does this mean ALL of microchip 8-bit devices because of its architecture will ONLY allow reading of DATA memory and NEVER code memory. Would you say that is a fair statement?
     
     
     
    Really appreciate your help here. It will and has saved me ALOT of time.
     
    Thanks!,
    #3
    ric
    Super Member
    • Total Posts : 27629
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: PIC16F630 - Read from Flash and do a checksum. 2020/06/02 22:19:48 (permalink)
    +2 (2)
    A PIC16F18324 can read its own code memory.
    You can't simply do it via a C pointer though. You must use the "NVM" peripheral.
    See: "11.4 NVMREG Access" in the datasheet.
     

    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!
    #4
    ric
    Super Member
    • Total Posts : 27629
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: PIC16F630 - Read from Flash and do a checksum. 2020/06/02 22:22:30 (permalink)
    +3 (3)
    n.b. It is possible to read the lower 8 bits of ROM data via a pointer (which is how "const" arrays are implemented by the compiler), but NVM is the only way to access all 14 bits of each location.
     
     
    post edited by ric - 2020/06/02 22:43:33

    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!
    #5
    evalmode
    New Member
    • Total Posts : 4
    • Reward points : 0
    • Joined: 2012/08/28 04:03:20
    • Location: 0
    • Status: offline
    Re: PIC16F630 - Read from Flash and do a checksum. 2020/06/02 22:56:58 (permalink)
    0
    Hi ric,
     
    This has been really helpful and I appreciate your answer. Thanks!
     
    Have a good one.
     
    Cheers!
    Samuel
    #6
    Jump to:
    © 2020 APG vNext Commercial Version 4.5