+ Post New Thread
Results 1 to 4 of 4
  1. #1
    Junior Member level 2
    Points: 217, Level: 2

    Join Date
    Sep 2015
    Posts
    23
    Helped
    0 / 0
    Points
    217
    Level
    2

    How to write to a memory ports using c for SoC implementation?

    The below is not doing perfectly as per my question.so clarify me regarding this .
    Code:
    #include<stdio.h>    
    #define base_addr 0x20000000
    
    int *GPIO1=(int *)base_addr+0x00;
    int *GPIO2=(int *)base_addr+0x04;
    int *GPIO3=(int *)base_addr+0x08;
    int *GPIO4=(int *)base_addr+0x0c;
    
    int main()
    {
     int a=4,b=5,c=6,d=7;
    
     *GPIO1=a;
     *GPIO2=b;
     *GPIO3=c;
     *GPIO4=d;
    
     printf("GPIO1=%d,GPIO2=%d,GPIO3=%d,GPIO4=%d",GPIO1,GPIO2,GPIO3,GPIO4);
    }

    •   AltAdvertisement

        
       

  2. #2
    Advanced Member level 5
    Points: 12,636, Level: 26
    Achievements:
    7 years registered

    Join Date
    Apr 2010
    Posts
    1,918
    Helped
    411 / 411
    Points
    12,636
    Level
    26

    Re: How to write to a memory ports using c for SoC implementation?

    what is your requirement ?
    specify clearly.
    do you want to write the integers at GPIO1 ... or at *GPIO1...



    •   AltAdvertisement

        
       

  3. #3
    Super Moderator
    Points: 260,224, Level: 100
    Awards:
    1st Helpful Member

    Join Date
    Jan 2008
    Location
    Bochum, Germany
    Posts
    45,441
    Helped
    13826 / 13826
    Points
    260,224
    Level
    100

    Re: How to write to a memory ports using c for SoC implementation?

    Everything looks correct, except for the printf() line.
    The below is not doing perfectly
    How did you check? The printf() is not reading back the memory content, you want to read *GPIO1....



    •   AltAdvertisement

        
       

  4. #4
    Junior Member level 2
    Points: 217, Level: 2

    Join Date
    Sep 2015
    Posts
    23
    Helped
    0 / 0
    Points
    217
    Level
    2

    Re: How to write to a memory ports using c for SoC implementation?

    The basic idea is i want to write an write operation to GPIO peripheral. In the same way a write to all the peripherals and to memory which should have base address is common whereas offset keeps changing. as above



--[[ ]]--