This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Access violation

I'm relatively new to Keil and C167. I got an error: "error 65: access violation" while debugging an assembly program using simulator. I tried these 2 sets of assembly code

1) Using EXTS

EXTS #4, #3
mov r1, #0x0A
mov r2, #0x1000
mov [r2], r1

2) Using DPP
mov DPP2, #0x0010
mov r1, #0x0A
mov DPP2:0x1000, r1

But both gives me the error: "error 65: access violation: addr=0x00041000".

In the project settings, I had mentioned 40000 to 90000 as External RAM.

Would be grateful if you can correct me and provide me some guidance.

Thanx in advance...!!!

  • I've just tried a similar thing to see how it works. It looks as though debugger maps memory ranges in sections which can be seen in linker map file. The external memory ranges in target options only give instructions to linker, they are not passed on to debugger.
    If you need to allocate a section, use the user sections part of the target options dialog.
    - Mike

  • Hi Mike,

    I'm afraid that even after entering the memory locations for the respective the user classes(in User Classes in target options), it hasn't worked out. Can you provide me the command line syntax of using the User Sections in the Target Options?

    Is the assembly code, which i had posted, correct?

    Thanx again...

  • To be honest, I didn't have to do anything like that before because I let the C compiler and the linker do all those things. I think Keil\C166\hlp\A166.PDF contains all the details about sections, classes and so on. The file Keil\C166\LIB\START167.A66 defines sections like system stack and user stack, so you can take the correct syntax from there.
    As for the assembler code, I would change only one thing.
    You wrote:

    EXTS #4, #3
    mov r1, #0x0A
    mov r2, #0x1000
    mov [r2], r1
    
    The EXTS instruction locks interrupts, PEC, and hardware traps. If interrupt latency is an issue, this code is better:
    mov r1, #0x0A
    mov r2, #0x1000
    EXTS #4, #1
    mov [r2], r1
    
    - Mike

  • You can always use the map command in the debugger to make all memory read, write, and exec'able.

    The debugger automatically maps your program code and variables. However, if you just want to access a big buffer in memory AND if you don't create a variable (array) for the space, the area is not mapped. And you'll get this access violation error.

    Jon

  • Have you reconfigured and rebuilt the monitor to match your application mapping during debugging? The config.h file in the monitor directory contains the memory mapping macros. I always have a separate monitor project with each application project so the two are always in sync.
    Best luck
    Scott

  • Hi Scott,

    How do you create a separate monitor project with each application project? What I have been trying to do is, perhaps, something very simple, but I haven't been successful yet. All I'm trying to do is write some data into memory locations from 0x30000 onwards. I tried using EXTS and DPP. Maybe the way I'm doing is wrong...

    Can u suggest me what would the things I would have to do(in the assembly code and in the project settings) so that I can access(read from and write to) any part of the 1MB memory provided on the MCB167 Net board. It is very urgent now.

    Thanks.
    Deepak.

  • Deepak,
    I create a 'monitor' subdirectory under the application subdirectory, with version subdirectories if needed. In 'monitor' are the following 'source' files:
    BOOT167.A66 Boot code
    INST167.A66 Installation code
    CONFIG.INC Configuration macros
    BOOT.BAT Make
    BOOTCOPY.BAT Output distribution
    ABSTRACT.TXT Documentation

    These are all copied from C:\Keil\c166\monitor where there are instructions for their use/modification and a number of pre-built monitors for different development boards.
    I have a UV2 project which runs the boot.bat file which assembles and links everything.
    The bootcopy.bat then copies the output files back to the keil\c166\monitor subdirectory where the toolchain expects them to be. The abstract.txt file is displayed under the UV2 project options menu in the debugger monitor window. I make certain it describes the address map accurately.
    I find it very helpful to formalize the memory map in a separate document which shows the address ranges, monitor data and code areas and any block 'mirrors' which occur. This is often the first thing I do in the project. Once it is done and the config.inc matches it along with the project startup code (start167.166) I seldom have to change them or worry about addressing problems.
    Best luck,
    Scott