how to calculate The next address of memory ?

This is a discussion on how to calculate The next address of memory ? within the C Programming forums, part of the General Programming Boards category; I need write values to my SRAM memory, in fixed positions. memmap.h Code: #define SRAM_ENDERECO_INICIAL 0xE0084000lu // Endereço Inicial da ...

  1. #1
    Registered User
    Join Date
    Nov 2008
    Posts
    158

    how to calculate The next address of memory ?

    I need write values to my SRAM memory, in fixed positions.

    memmap.h
    Code:
    #define SRAM_ENDERECO_INICIAL	0xE0084000lu		// Endereço Inicial da SRAM
    
    void SRAM_Init(void);
    
    typedef struct stRede
    {
    	unsigned int iIP[4];
    	unsigned int iMascara[4];
    	unsigned int iGateway[4];
    	unsigned int iDns[4];
    	unsigned int iPorta;
    } SYSCONFIG_REDE;
    
    typedef struct stSerial
    {
    	unsigned int iIP[4];
    	unsigned int iMascara[4];
    	unsigned int iGateway[4];
    	unsigned int iDns[4];
    	unsigned int iPorta;
    } SYSCONFIG_SERIAL;
    
    
    SYSCONFIG_REDE *CONFIG_REDE;
    SYSCONFIG_SERIAL *CONFIG_SERIAL;
    memmap.c
    Code:
    #include "memmap.h"
    
    void SRAM_Init(void)
    {
    	CONFIG_REDE = (SYSCONFIG_REDE *) SRAM_ENDERECO_INICIAL;
    	//
    	CONFIG_SERIAL = (SYSCONFIG_SERIAL *) (SRAM_ENDERECO_INICIAL + sizeof(CONFIG_REDE));
    }
    
    void SRAM_Save(void)
    {
    	*CONFIG_REDE->iIP[0] = 192;
    	*CONFIG_REDE->iIP[1] = 168;
    	*CONFIG_REDE->iIP[2] = 1;
    	*CONFIG_REDE->iIP[3] = 222;
    
    	*CONFIG_REDE->iPorta = 47000;
    
    	*CONFIG_PESAGEM->lPesoCalibracao = 500000;
    }
    This line: *CONFIG_REDE->iIP[0] = 192;
    Error.....: memmap.c:23: error: invalid type argument of ‘unary *’
    //
    // is This the correct way to write in next address ?
    CONFIG_SERIAL = (SYSCONFIG_SERIAL *) (SRAM_ENDERECO_INICIAL + sizeof(CONFIG_REDE));

  2. #2
    Registered User
    Join Date
    Aug 2010
    Location
    Poland
    Posts
    682
    Remove asterix: *
    Code:
    CONFIG_REDE->iIP[0] = 192;
    I never put signature, but I decided to make an exception.

  3. #3
    Registered User
    Join Date
    Nov 2008
    Posts
    158
    ok, perfect.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Question regarding Memory Leak
    By clegs in forum C++ Programming
    Replies: 29
    Last Post: 12-07-2007, 12:57 AM
  2. Pointer to specific memory address
    By elnerdo in forum C++ Programming
    Replies: 10
    Last Post: 05-19-2006, 07:35 AM
  3. Pointer's
    By xlordt in forum C Programming
    Replies: 13
    Last Post: 10-14-2003, 02:15 PM
  4. Memory address?
    By Munkey01 in forum C++ Programming
    Replies: 4
    Last Post: 02-01-2003, 08:04 PM
  5. Im so lost at . .
    By hermit in forum C Programming
    Replies: 18
    Last Post: 05-15-2002, 01:26 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21