This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Basics: C programming for ARM - AHB transfers

Note: This was originally posted on 18th September 2007 at http://forums.arm.com

Hello,
Would someone please help me about the next basic things?
I have programed microcontrollers in the past but now I need to work with ARM processors and need some basic pieces to connect the puzzle.
I wil write a C/C++ code for ARM966 but I don't know what to do in the code to communicate to an AHB peripheral. It should be memory mapped but I don't know at what location and if I need to do the memory initalisation at the start of the code or I can read it from somewhere - I have not been able so far to find a clear document about that.
Also, I expect that is enough for me to write to that location in the memory and to read from it and the compiler 'armcc' will take care of generating AHB transaction data that will go to ARM AHB interface ports. I am right or there are specific C functions for AHB transfers in both directions?
I expect to have a library of the C functions that I can use in the code but also somehow I couldn't find the place where it is explained.
I have been digging over RealView 3.0 (Unix) directories in the search for that and I see several header files (like rt_heap.h, rt_memory.h and so on) but I don't have any single C project example where I can see their usage.
I would really apreciate if someone can give me some examples or point me to a location where I can read about that.
The same questions go for the tightly coupled memory (TCM) - where is it in the memory map and so on.
Any help is appreciated.
Thank you very much,
joewu
  • Note: This was originally posted on 18th September 2007 at http://forums.arm.com

    Thank you very much for the answer.
    Again I am continuing with the basics: where to find what AHB peripheral is mapped at what location in the memory so I can assign a value to a pointer and know I talk to that peripheral?
    Do you maybe have a little C example for AHB read/write to demonstrate this?
    The same goes for TCM.
    I am looking now at the ARM966E-S Tech. Ref. and it says on page 3-2 that one memory region for AHB unbuffered access is from 0x1000 0000 to 0x1fff ffff. I have a DRAM controller with AHB interface that should be connected to AHB interface of this processor. What to do here, maybe we can take this and make an example?
    Is there a document that describes this, I mean basic setup steps and an example of the AHB communication, it should be pretty short?
    Thank you very much,
    joewu
  • Note: This was originally posted on 19th September 2007 at http://forums.arm.com

    Thank you again, it is nice of you to try to help me with this.
    I understand what you are saying but still don't see when the memory map is configured and who decides at what location AHB peripheral will be mapped and how I can know that now in the early development phases. Do I have to do it in some initialization stage afterward and how? Is there C API for that (not SystemC, just C or C++)?
    Then, let's say I found somehow that location and have written something to it. Now I want to read the answer from that particular peripheral. I would expect to have a separate address for AHB HRDATA[31:0] bus - is my assumption correct here or it is also taken care of automatically?
    These are all the simple basic questions and I beleive after a little example it would all click in place for me.
    It seems to me I also need to spend some time in adding and configuring an AHB peripheral but it is very distant in the flow and I need to do some programming now.
    Many thanks...
  • Note: This was originally posted on 20th September 2007 at http://forums.arm.com

    Thank you very much again.
    The actual situation is that I need to prepare a draft program version assuming that at some address in the memory there will be later attached an AMBA peripheral (a DRAM controller). I don't have a specific SoC, just know that ARM966E-S will be used to build that SoC. Since I have not worked practically yet with the AMBA bus (coming to that, obviously :rolleyes:) I am trying to model the situation because I must proceed without waiting for anyone around to finish ther job so I can start mine.
    Best regards.
  • Note: This was originally posted on 20th September 2007 at http://forums.arm.com

    I understand what you are saying but still don't see when the memory map is configured and who decides at what location AHB peripheral will be mapped and how I can know that now in the early development phases.


    All that the ARM966 TRM states is the mapping to the AHB interface.

    Everything *outside* of the core will be defined by the hardware manufacturer - not by the ARM core, so I can't help you here. What peripherals / RAM / memory controllers sit at what address on the AHB bus depends on how the bus is configured by the ASIC manufacturer.

    If you are working with a silicon chip that has already been manufactured then refer to the actual ASIC TRM for the hardware map, if you are working for a company actually designing the ASIC, then go and talk with your hardware guys =)

    The mapping will be fixed for a particular ASIC - so there is not normally a need to set up any mapping using software at boot time.

    I would expect to have a separate address for AHB HRDATA[31:0] bus - is my assumption correct here or it is also taken care of automatically?


    Automatic - hard defined by the ASIC bus implementation normally =)

    These are all the simple basic questions and I believe after a little example it would all click in place for me.


    I think you are trying to make this more difficult than it really is - my example C code above is *all* that you need to do to talk to a peripheral on the ARM966. There is nothing else to turn into an example.

    You just need to read the ASIC TRM from the hardware mfr. to find out the constant that defines YOUR_PERIPHERAL_BASE_ADDRESS.
  • Note: This was originally posted on 18th September 2007 at http://forums.arm.com

    As a programmer you don't see the details of the bus protocol (AHB / AXI / etc) - the hardware does all of this for you, so don't worry about it. The compiler will generate "load" and "store" instructions - the ARM core will handle the rest =P

    Simply use standard C pointer operations (with appropriate volatile type modifiers) to access data from the hardware peripheral you want to connect to.

    Cheers,

    I