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

Accessing SFR

Hi
Please, How i implement this code in CARM?
/////////////////////////////////////////////
typedef struct _AT91S_RTC {
AT91_REG RTC_CR; // Control Register
AT91_REG RTC_MR; // Mode Register
AT91_REG RTC_TIMR; // Time Register
AT91_REG RTC_CALR; // Calendar Register
AT91_REG RTC_TIMALR; // Time Alarm Register
AT91_REG RTC_CALALR; // Calendar Alarm Register
AT91_REG RTC_SR; // Status Register
AT91_REG RTC_SCCR; // Status Clear Command Register
AT91_REG RTC_IER; // Interrupt Enable Register
AT91_REG RTC_IDR; // Interrupt Disable Register
AT91_REG RTC_IMR; // Interrupt Mask Register
AT91_REG RTC_VER; // Valid Entry Register
} AT91S_RTC, *AT91PS_RTC;

#define AT91C_BASE_MC ((AT91PS_MC) 0xFFFFFF00) // (MC) Base Address
#define AT91C_BASE_RTC ((AT91PS_RTC) 0xFFFFFE00) // (RTC) Base Address
/////////////////////////////////////////////
I need access SFR whit structures

For example
I tried this:
//////////////////////////////////
typedef struct
{
at91_reg PS_CR; /* Control Register */
at91_reg PS_PCER ; /* Peripheral Clock Enable Register */
at91_reg PS_PCDR ; /* Peripheral Clock Disable Register */
at91_reg PS_PCSR ; /* Peripheral Clock Status Register */
}StructPS;

StructPS *PS_BASE __at 0xFFFF4000;
////////////////////////////
When i try change the PS_PCER value:

PS_BASE->PS_PCER = 0x04;

The 0xFFFF4004 (PS_PCER) value not is affected (I saw this in Simulator).
What's wrong?
can you help me?

Thank's
Eduardo

Parents
  • "I'm trying this because i'm converting GNU code to Keil code. Some places in my GNU code use that pointer."

    In my opinion, this would be an area that does not require porting. Knowing that AT91_REG is:

    typedef volatile unsigned int AT91_REG;
    And that's standard C along with the rest of the GNU-defined structures and #define's. You should be able to use the GNU method as-is without resorting to using language extensions.

Reply
  • "I'm trying this because i'm converting GNU code to Keil code. Some places in my GNU code use that pointer."

    In my opinion, this would be an area that does not require porting. Knowing that AT91_REG is:

    typedef volatile unsigned int AT91_REG;
    And that's standard C along with the rest of the GNU-defined structures and #define's. You should be able to use the GNU method as-is without resorting to using language extensions.

Children