Skip to main content
redkofka
Associate II
July 3, 2012
Question

value at fixed memory address

  • July 3, 2012
  • 3 replies
  • 868 views
Posted on July 03, 2012 at 08:32

hi i want to place value - ''address of station'' at fixed memory address

without specifed address its look like

&sharpdefine mcu_address 0x03

i found - it may looks like

&sharpdefine mcu_address         (*((volatile unsigned long *) 0x20000000))

mcu_address = 0x03;    //here i have syntax error

i am using coocox ide...

thanks for all ideas ...

#value-address
    This topic has been closed for replies.

    3 replies

    Tesla DeLorean
    Guru
    July 3, 2012
    Posted on July 03, 2012 at 12:39

    Both Keil 4.53 and GCC 4.7.1 are tolerant of that, perhaps a more complete exemplar that demonstrates the issue would help. Is it the compiler or the IDE reporting this error, which version of GCC?

    The typical method is

    unsigned long *foo = (unsigned long *)0x20000000;

    *foo = 12345;

    foo[1] = 67890;

    Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
    Andrew Neil
    Super User
    July 3, 2012
    Posted on July 03, 2012 at 23:47

    ''here i have syntax error''

     

    You need to show the full text of the error.

    And, as clive1 says, you also need to show a complete example.
    A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
    redkofka
    redkofkaAuthor
    Associate II
    July 4, 2012
    Posted on July 04, 2012 at 07:38

    ok -

    so i used this in my code and it works great :

    #define rts_1        GPIOA->ODR |=  (1 << 12);                //rs485

    #define rts_0        GPIOA->ODR &= ~(1 << 12);            //rs485

    #define adresa 0x03              

    then i have something like rx_packet 24byte - adress of mcu is on rx_packet[2]

    in code i check if address is valid

    if  (adresa ==rx_packet[2] ){Decode_Packet(p);}

    /***************************************/

    when i used this definition

    #define mcu_address         (*((volatile unsigned long *) 0x20000000))

    mcu_address = 0x03;    //here i have syntax error -it show ''?'' in coocox and in compile log i have

           [cc] C:\CooCox\CoIDE\workspace\DMA\main.c:93: error: expected identifier or '(' before 'volatile'

           [cc] C:\CooCox\CoIDE\workspace\DMA\main.c:93: error: expected ')' before numeric constant

    so i tried used clive's example

    unsigned long *foo = (unsigned long *)0x20000000;

    *foo = 12345;    // error: conflicting types for 'foo'

    foo[1] = 67890; //  error: conflicting types for 'foo' and  error: invalid initializer

    i use gcc arm-none-eabi-gcc-4.4.1

    all in all i only want to have const or variable of device address on my memory adress where i want ....

    thanks for yours posts guys ...