Accesing a memory direction using a pointer

Hello! I am beginning my first FreeRTOS project, and I have a problem accesing a memory direction.
I have defined this pointer to a GPIO_regs struct:

struct GPIO_regs
{
    volatile uint32_t Data;   
    volatile uint32_t Output;   
    volatile uint32_t Direction;  
};

volatile struct GPIO_regs * const pGPIO_REGS =
        (struct GPIO_regs *)0xFC083000;

And I try to access the content of the Direction field:

pGPIO_REGS->Direction = pGPIO_REGS->Direction |(GPIO_LED0_MASK | GPIO_LED1_MASK |GPIO_LED2_MASK | GPIO_LED3_MASK);

But, when executing that code line, the program is terminated and shows this message:

Program terminated with signal SIGSEGV, Segmentation fault.
The program no longer exists.

Is there anything wrong in this code? Do I have to change anything in the FreeRTOSConfig.h file to access the memory direction 0xFC083000?

Thank you so much!

Which platform / CPU do you use ?
SIGSEGV sounds like running the code as Linux application :thinking:

Yes indeed, I am using Eclipse on Ubuntu.

Well, then you can’t simulate accessing a GPIO controller of a very different MCU this way. At least you can’t use/access physical addresses not existing on your Ubuntu box.
In addition Linux itself doesn’t allow direct access to physical addresses because it uses virtual memory/MMU and kernel/userspace address space split.
I don’t know what you’re trying to do, but you could use e.g.
pGPIO_REGS = (GPIO_regs *)malloc( sizeof(GPIO_regs) );
to get some accessible memory and initialize the structure accordingly to test/simulate your code up to a certain degree.

1 Like

I understand what the problem is! I will do it the way you suggested, thank you so much!!!