Thread: how to calculate The next address of memory ?

  1. #1
    Registered User
    Join Date
    Nov 2008
    Location
    Santa Catarina - Brasil
    Posts
    184

    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
    733
    Remove asterix: *
    Code:
    CONFIG_REDE->iIP[0] = 192;

  3. #3
    Registered User
    Join Date
    Nov 2008
    Location
    Santa Catarina - Brasil
    Posts
    184
    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, 01: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, 09:04 PM
  5. Im so lost at . .
    By hermit in forum C Programming
    Replies: 18
    Last Post: 05-15-2002, 01:26 AM