Compiling C code to ARM7TDMI processor

Thread Starter

dor

Joined Feb 20, 2009
63
I'm using the AT91SAM7X512 device.

I have no idea which compiler to use in order to compile C code for the ARM7TDMI that's within the AT91SAM7X512 device.
I've read in many websites about Keil software but it confuses me even more.
What C class & corresponding header should I use for this device?

Also, how can I implement the binary code into the processor? Via JTAG? Which pins should I connect?

And there's a paradox in the AT91SAM7X512 datasheet: at first they say that the FLASH memory size is 512KB, later on (in the memory mapping page) it's 1MByte.

I'm totally frustrated.

Best regards,
Dor.

Edit:

Here's the relevant datasheets etc.: http://www.keil.com/dd/chip/4613.htm
 
Last edited:

Papabravo

Joined Feb 24, 2006
21,159
You need a C compiler that is designed to emit code for the intended target processor. I don't know why the mention of the Keil compiler should confuse you. Keil is a compiler vendor and you will have to pay some serious money to use their compiler. There is also the GNU Compiler Collection which may have an ARM7TDMI version you can download for free. The learning curve is a bit steep however. There are doubtless other compler vendors like IAR that may have suitable offerings.

There is no such thing as a C class. C++ has classes, but C does not. The compiler vendor will have a family of header files for popular parts and in most cases you will have to pick one and adapt it if the part is new or recently released.

Parts get programmed in a variety of ways, one of which is JTAG. To do this you need a JTAG programmer and the pins that you connect to the JTAG connector are specified in the datasheet. You can get the datasheet and the hardware reference manual from the manufacturer which in this case is Atmel.

On the memory size you need to reread the confusing sentences carefully. The most likely explanation for the discrepancy is that in one case the size is given in BYTES, and in the other case it is given in WORDS. You need to know which one they are talking about.

Here is the ARM7TDMI Reference Manual
http://www.atmel.com/dyn/resources/prod_documents/DDI0029G_7TDMI_R3_trm.pdf
And Here is the Atmel Datasheet
http://www.atmel.com/dyn/resources/prod_documents/doc6120.pdf

I can't find any references to 1MB of memory in the datsheet. Maybe you would be so good as to point out where you found the statement.

Are you planning to design a board with this part on it, or were you considering buying a development board for the part. I think your chances of success with the former are vanishingly small. If I were you I'd get my feet wet with an existing board. You can use that as a basis for your own design.

If this is for work and you need the design in a hurry I may be able to help you. Send me a PM if you like.
 
Last edited:

Thread Starter

dor

Joined Feb 20, 2009
63
Hi Papabravo,

Thanks for your quick reply.

I'll try to google for IAR.

About the memory, you can see here:
http://www.atmel.com/dyn/resources/prod_documents/doc6120.pdf

in page 18 that the total size of memory (including RAM, ROM & FLASH) is a lot more than 3000MByte, which is absolutely weird and not expected.
I think that there's no issue with WORDs here...

Is there any difference between the self-design board version and the development board version, except of the size of the device?

I'm not in a special hurry but I do feel very bad because usually I tend to understand things quickly.
 

Papabravo

Joined Feb 24, 2006
21,159
I see what is going on and why you might be confused. The architecture defines locations for various types of memories. The total memory space is 4,294,967,296 which is 2 raised to the 32nd power. An actual part will implement a subset of that amount of memory. Parts of each of those 1 MByte chunks will be empty. In the case of AT91SAM7X you have the amounts of memory present according to the datasheet, and from the diagram on p.18 you know where each type of memory begins. Knowing the amount of memory will allow you to compute where it ends.

Notice that any reference to 3.584 GB from address 0x1000 0000 through 0xEFFF FFFF, which is grayed out, is guaranteed to generate an exception. In the picture it is labeled (Abort).

For example the internal SRAM is located in the block which starts at 0x0020 0000. The AT91SAM7X has 128K Bytes of SRAM that starts at 0x0020 0000 and ends at 0x0021 FFFF. The rest of the SRAM block from 0x0022 0000 through 0x002F FFFF is unoccupied. References to that may or may not generate an exception. I'd have to read further to answer that question.

The end address of the 1 MByte Boot Block should be 0x000F FFFF. In the picture there is a missing F. According to the footnote there can be several different kinds of memory in that segment depending on GPNVM2 and REMAP which I believe are configuration bits. Again I'd have to read further to ferret out the details.

Remapping is a common strategy to allow a boot loader to execute from ROM or Flash after reset, load data into SRAM, then remap the SRAM into low memory so that the program may execute out of SRAM.

This is a complicated part. I would not beat myself up too hard for not getting it the first time. There is a BIG difference between a PIC and one of these babies.

If you design your own board, given your apparent experience level, it might be 6 months to 1 year before you can achieve a workable design. If you purchase an existing design you can focus on developing the software while you adapt the existing design to your form factor and specific requirements. If you think this is easy then you will certainly deserve the results that you manage to achieve.

This chip has quite a few peripherals including an Ethernet MAC, a CAN Controller, and a USB Port. Are you prepared to deal with those interfaces as well?

Once you recover from the sticker shock on the IAR compiler, you might decide to try the GNU compiler for free, or you might decide to swallow hard and open your wallet.
 
Last edited:

Thread Starter

dor

Joined Feb 20, 2009
63
I don't mind to try to make it work even if it would take 6 months. This is my learning process that I must pass.

All this information that's distributed on the internet does not make things simpler. The further I read, the more confused I become.

In this page: http://iar.com/website1/1.0.1.0/658/1/?item=prod_prod-s1/166&group=prod_prod_grp-s1/36

I found the following:

IAR KickStart Kit for Atmel AT91SAM7X contains all the necessary hardware and software and allows you to design, develop, integrate and test your applications:

• AT91SAM7X development board from Atmel

• IAR visualSTATE evaluation edition, 20-state limitation

• IAR Embedded Workbench with a 32KB edition of IAR C/C++ Compiler (including example projects)

• J-LINK JTAG debugger with USB connector
It seems that IAR software must be purchased in order to use it.
I'm looking for an open-source substitute.
I'm also looking for a page that can explain me, in the most simple way (with direct HTTP links to relevant pages etc.), how to build the simplest AT91SAM7X application.

While I looked for info, many names poped-up, like "SAM-ICE", "JLINK" and the term "boot" (which I understand as "restart" and don't know why this term appears in many pages and PDFs like "SAM-BA boot Assistant").
But none of the pages explained what this device or software really does.
Or maybe because that English isn't my native language, it's difficult for me to understand those terms that they're using and why they're related to AT91SAM7X. Despite that, I think that I can read & understand English well enough to search for the necessary info.

Those are the things that I can't distinguish among all the variety of names that appeared while searching for info:

  • An open-source software to compile C code, with some IDE (I'm already using Notepad++ as an IDE for MinGW GCC compiler).
  • C libraries for the AT91SAM7X512 and for it's different peripherals.
    Some decent examples would be helpful.
  • A device that can transfer the binary data to the AT91SAM7X512 chip via the JTAG interface.

Sorry that I'm asking, but could you please give me direct links to some web pages where I can find all the relevant open-source software & practical information?
This info is listed in the quote above, but instead of IAR I need an open-source replacement.

Thank you.

Dor.
 

Papabravo

Joined Feb 24, 2006
21,159
Well of course you have to purchase the IAR compiler. It is a company well known for emptying your wallet. IAR and Keil have much in common in that regard. I've given you a suggestion and a link to the open source tools already. Check my previous post for the getting started doc from the Atmel website -- doc6296.pdf

The C libraries are available on the Atmel website. I'm surprised that you have not already found them. I'm still a bit confused about what you are up to. Do you really need all of the onboard peripherals that this chip provides?
 

Thread Starter

dor

Joined Feb 20, 2009
63
Ok then, I'll inform later about my progress.

I found those C libraries, but while searching for info in the internet, I found many other C libraries that are for the ARM7TDMI processor.
So, how is it possible that there are many C libraries for the same processor? Why are they not using the main C libraries that Atmel provides? Which C libraries package is good for me?

After you told me to use Atmel's C library, I'll try it.
And I'll use YAGARTO as my compiler.

The major peripherals are very helpful for my purpose: 512KB of FLASH memory, USB built-in interface, RTT, SPI, etc.
 

Papabravo

Joined Feb 24, 2006
21,159
The short answer to your question about libraries is that there is a set of libraries for every possible variation of the ARM7TDMI processor made by Atmel and many other companies. Each of the variants has a different number of pins and a different collection of peripherals all centered around a common core.

So the CAN controller and the Ethernet MAC are of no interest. You might want to consider a cheaper part that has something more in line with what you intend to actually use.

Looks like the eval kit you want is about $200.00 from Digi-Key. They will ship international if required.

From doc6132.pdf which does not seem to be available from Atmel anymore, on the subject of SAM-BA
Rich (BB code):
To install SAM-BA 2.0 (or higher) on a PC: 1. Uninstall the previous version of SAM-BA if already installed. 2. Uninstall the previous version of AT91-ISP if already installed. SAM-BA 2.0 (or higher) is part of AT91-ISP installation program.
3. Run the
Install AT91-ISP.exe program.
4. Follow the installation program instructions.
5. When prompted for an installation directory, specify your AT91-ISP installation directory. SAM-BA 2.0 is installed in the following directory:
YOUR_AT91-ISP_INSTALL_DIRECTORY\SAM-BA v2.x
SAM-BA is now part of a program called AT91-ISP.exe. It is designed to do "In System Programming". It will download code into an AT91SAM7X through JTAG, USB, or Serial Port. I believe that the PC gets a JTAG port by using a USB to JTAG box such as the SAM-ICE/JLINK or similar device. Get the Eval kit it will make your life dramatically simpler, besides providing a reference design for your own board.​
 
Last edited:

Thread Starter

dor

Joined Feb 20, 2009
63
Hi Papabravo,

You were right. This microcontroller is very complicated. Many initializations are required. Even the "Getting started with ..." PDF document doesn't help me here.

I bought the Evaluation Kit and now I'm searching for a simple C code API that will demonstrate how to use the AT91SAM7X libraries.

There are just too many things there... How anyone can build a project on that thing :|

I'm using EDGE as a development environment.

How should I start building the project? I really do not know what to do...
 

Papabravo

Joined Feb 24, 2006
21,159
I would advise you to start with an understanding of the General Purpose I/O pins and any convenient method for measuring time. Such pins can be used to turn an LED On and Off. The timer hardware should allow to create a fixed delay based off of the system clock. Now I can't see all of what you have in front of you, but that is where I would start.

The GPIO pins have a defined behavior after RESET is released. I'm guessing that they are configured as inputs since it would be difficult to do much damage with a pin configured as an input. When your program gets control it should write some values to the registers that configure one of the general purpose pins to be an output. It should also set that output to some initial state, either 0 or 1, it really does not matter.

Now turn your attention to one of the hardware timers and see if you can figure out how to set it up to give you an idication after some fixed amount of time has elapsed. Do not use interrupts for this purpose, just keep them disabled. When the time has elapsed then change the state of your output, and repeat the process forever. Blinking an LED is the embedded equivalent of printing "Hello World" in the programming language of your choice.
 

Thread Starter

dor

Joined Feb 20, 2009
63
Thanks for your consistent help.

I'll try to do that. The main problem is how to start and where to look in the C libraries in order to do things (like blinking LED).

I mean that I can't find an example of initialization of the device.
Some example that I can use to get familiar with the device and learn about how it supposed to be written.

All I manage to find are tiny code snippets.
Is it supposed to be this way?
Why Atmel is not providing examples of initialization =\
 

Papabravo

Joined Feb 24, 2006
21,159
All C compilers provide a startup file that they link in with your program that actually does a boatload of initialization. If you can find a way to have your compiler generate a map file or a listing file or some kind of disassembly you may be able to locate the RESET vector and find out things like where the stack is placed and what sections of memory get set to what values, before your program runs its first instruction.
 

millwood

Joined Dec 31, 1969
0
I am also starting with ARM now.

As to compilers, i am going with Keil MDK. you can download a demo version of it from Keil, free of charge. it has the 32k code limitation - which is more than enough for what I do. so far, the experience has been great and I think the gui is far better than hi-tide / eclipse and more robust as well.

I am eventually going with cortex-m3 - got bunch of them just last week but now i am playing on Proteus in simulation, with a lpc2138 dev board on the way.

coming from PIC, the arm chips are a huge welcome, so far anyway.
 
can any one of u help me on the following???
i think Papabravo have a sound knowledge of ARM and can help me out, i ll be very thankful to you...

I want to interface a general IBM PC keyboard with at91sam7x512 which has ARM7TDMI within it...
i have read the keyboard protocol and the problem now is:

how keyboard data and keyboard clock pins are going to be connected with at91sam7x512???
data sent by keyboard is 11 bit long including 8 data bits, while registers in at91sam7x512 are 32 bits long...how will i access them in order to run my program in sam7x512???

keyboard protocol link:
http://www.beyondlogic.org/keyboard/keybrd.htm
 
Top