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
Ask yourself: Does a pointer to a structure exist at 0xFFFF4000, or does a group of registers organized like a structure exist at 0xFFFF4000? Having answered that, then ask yourself: Why am I attempting to use an extension to the C language to access these registers instead of using a bog-standard means similar to that in the example which utilizes the preprocessor (#define)?
Hi Dan, I'm trying this because i'm converting GNU code to Keil code. Some places in my GNU code use that pointer. Now i don't know what's the problem, or where. Could you help me whit this? Thanks Eduardo
StructPS *PS_BASE __at 0xFFFF4000;
"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;
/* AT91 Register type */ typedef volatile unsigned int at91_reg ;
The 0xFFFF4004 (PS_PCER) value not is affected (I saw this in Simulator).
"Now i don't know, where is the problem" Look at the pointer definition; answer the question...
Oh, Andy Sorry... I understood. But i tried another combinations One of them:
StructPS *PS_BASE; StructPS PS_BASE1 __at 0xFFFF4000; PS_BASE=&PS_BASE1;
View all questions in Keil forum