How to write to specific memory address?

ISA2823
2008-09-02
2013-03-12
  • ISA2823
    ISA2823
    2008-09-02

    MCU: pic18F97J60

    I noticed some registers aren't defined in SDCC (e.g. CONFIG1L at 0x3000000, CONFIG2L at 0x300002, ...etc...).

    Does anyone know what the best way to reference a memory address would be so I can change these registry values?
    I image this is a fairly simple task. I figure pointers would be handy.

    Here's what I've got:
    ...
    #define CONFIG1L (volatile unsigned char *)(0x3000000) //set location of register
    ...
    CONFIG1L = 0x00; //set content at register to zero
    ...

    Here's what I get:
    ...
    error 10: 'lvalue' required for 'assignment' operation.
    ...

    Thanks in advance

     
    • Maarten Brock
      Maarten Brock
      2008-09-03

      Allthough I don't know much about the pic's, your method is definately wrong. You define CONFIG1L as a pointer and then try to assign a value to it. Shouldn't you instead assign to the pointed object? So either use:

      #define CONFIG1L   *(volatile unsigned char *)(0x3000000)
      CONFIG1L = 0x00;

      Or use:

      #define CONFIG1L   (volatile unsigned char *)(0x3000000)
      *CONFIG1L = 0x00;

      HTH,
      Maarten

       
    • ISA2823
      ISA2823
      2008-09-03

      Maarten,
      Thanks for the reply

      I realized shortly after my post that I wasn't de-referencing the pointer (like you demonstrated). However, I am still unable to successfully read/write to a defined address

      Has anyone else come across this issue or have any other methods of accessing specific memory addresses?

      Thanks,
      ISA2823