Home>

I used to do WEB-related programs in the past,
I recently got a job using C language and a microcomputer.

I usually use GHS Green hills at work for my compiler.
I've never used anything other than Green Hills,
Make extensive use of C volatile and structure casting
Data in memory is accessed from the address value.

(* ((volatile My_structure *) (0x40520000))). child.register = 0

I want to cast from the address value and input the value like

.
Honestly for personal reasons, I don't think the above code is correct from experienced people,
Is it possible to access the above structure from the header file or the address value defined in define?

Once you have a model and simple declaration and access,
I would like to know the compilers that I confirmed for the exercise.

Thanks for your professor.
Please reply because anything is fine.

In

  • Answer # 1

    That is normal, there is no mistake or anything.
    For example, the peripheral device address definition file provided by the manufacturer of Renesas RX microcontrollers is as follows:

    (Partial excerpt)

    iodefine.h
    #define AD (* (volatile struct st_ad __evenaccess *) 0x89800)
    #define BSC (* (volatile struct st_bsc __evenaccess *) 0x81300)
    #define CAN0 (* (volatile struct st_can __evenaccess *) 0x90200)
    #define CAN1 (* (volatile struct st_can __evenaccess *) 0x91200)
    #define CAN2 (* (volatile struct st_can __evenaccess *) 0x92200)
    #define CMT (* (volatile struct st_cmt __evenaccess *) 0x88000)
    #define CMT0 (* (volatile struct st_cmt0 __evenaccess *) 0x88002)
    #define CMT1 (* (volatile struct st_cmt0 __evenaccess *) 0x88008)
    #define CMT2 (* (volatile struct st_cmt0 __evenaccess *) 0x88012)
    #define CMT3 (* (volatile struct st_cmt0 __evenaccess *) 0x88018)
    #define CRC (* (volatile struct st_crc __evenaccess *) 0x88280)

    Now, for example
    CAN0.CTLR.BIT.CANM = 0;

    and you can access the register


    Additional
    The keyword __evenaccess is a keyword specific to the Renesas compiler,

      

    If the __evenaccess qualifier of the extended function is added when declaring a variable, an instruction to access with the declared type size is output.

    It seems to be

    .

  • Answer # 2

    Structure pointer

    Use the arrow operator.