Author Topic: Beginning Cortex M3, but so lost!!  (Read 8933 times)

0 Members and 1 Guest are viewing this topic.

Offline dt

  • Contributor
  • Posts: 8
Beginning Cortex M3, but so lost!!
« on: January 06, 2012, 07:23:11 am »
Hi everyone,

After spending a few days researching on what MCU I should invest my time on learning, I concluded to go with the Cortex M3 family. But man, where do I start!? The documentation is really fragmented and no implementor seems to have their house in order, looks chaotic for a beginner. Could someone please outline what to read and in what sequence, and link to relevant docs? I'm looking for material that starts from step 1, i.e., what tools to use, what is the development process, mcu architecture and instruction set, code samples, etc..

Many thanks!!

 

Offline Psi

  • Super Contributor
  • ***
  • Posts: 7523
  • Country: nz
Re: Beginning Cortex M3, but so lost!!
« Reply #1 on: January 06, 2012, 07:27:11 am »
mcu architecture and instruction set

Do you plan to code the ARM in ASM?

In my opinion that really isn't needed, especially with such a modern/fast cpu.
C would be a much better choice.

All you really need to get is a M3 chip + board, a programmer and compiler/ide. (A good ARM M3 dev board would come with all three)
Once you have that you can compile some one line code onto the micro and then start expanding on it.
etc, checking the datasheet for register names, turn ports on/off, enabling timers etc.

However, maybe that's just me. I learn by doing and only read docs if there's something info i need.
« Last Edit: January 06, 2012, 07:32:21 am by Psi »
Greek letter 'Psi' (not Pounds per Square Inch)
 

Offline dt

  • Contributor
  • Posts: 8
Re: Beginning Cortex M3, but so lost!!
« Reply #2 on: January 06, 2012, 07:31:11 am »
Do you plan to code the ARM in ASM?

I'd probably avoid it where I can, but I would like to keep the options open.

In any case, I'm stuck at a much earlier step, I don't seem to be able to find an authoritative development guide explaining how to put together the required toolchain. There seem to be a lot of tools around, some free, some for a fee, doing different things. But how do they fit together, and which ones do I need to get started?
« Last Edit: January 06, 2012, 07:39:02 am by dt »
 

Offline Psi

  • Super Contributor
  • ***
  • Posts: 7523
  • Country: nz
Re: Beginning Cortex M3, but so lost!!
« Reply #3 on: January 06, 2012, 07:34:41 am »
Although it's good to know ASM, so you have an understanding of what's happening behind your C code, i think its perfectly ok to learn C first.
Then, if you need it, learn some ASM later.

Chances are you wont need it for quite a while, if at all.

« Last Edit: January 06, 2012, 07:36:19 am by Psi »
Greek letter 'Psi' (not Pounds per Square Inch)
 

Offline dt

  • Contributor
  • Posts: 8
Re: Beginning Cortex M3, but so lost!!
« Reply #4 on: January 06, 2012, 07:45:54 am »
I'm on Mac OS X BTW. I'm now wondering if it would be possible to setup xcode for the task, and if so, whether it would be a good idea in the first place (i.e., would in-circuit debugging or ice work?)
 

Offline Psi

  • Super Contributor
  • ***
  • Posts: 7523
  • Country: nz
Re: Beginning Cortex M3, but so lost!!
« Reply #5 on: January 06, 2012, 07:53:13 am »
I'm afraid i know nothing about macs.
Greek letter 'Psi' (not Pounds per Square Inch)
 

Offline AndreasF

  • Frequent Contributor
  • **
  • Posts: 251
  • Country: gb
    • mind-dump.net
Re: Beginning Cortex M3, but so lost!!
« Reply #6 on: January 06, 2012, 08:01:42 am »
I don't know which exact device you are planning on using, but Atmel has an application note "GNU-Based Software Development on AT91SAM Microcontrollers" (link), which may be of some use. It does, however, also only mention Windows and Linux environments, so I don't know if this will be of much help to you.
my random ramblings mind-dump.net
 

Offline dt

  • Contributor
  • Posts: 8
Re: Beginning Cortex M3, but so lost!!
« Reply #7 on: January 06, 2012, 11:26:05 am »
Thanks guys, I bumped into this link which has a good collection of info so it will get me started: http://milksnot.com/content/arm-cortex-m3-getting-started

Also, here's a guide on how to set up a toolchain on OS X, based on the GCC compiler: http://www.coactionos.com/index.php/getting-started/9-cortex-m3-compiler-osx
 

Offline Short Circuit

  • Frequent Contributor
  • **
  • Posts: 439
  • Country: nl
Re: Beginning Cortex M3, but so lost!!
« Reply #8 on: January 06, 2012, 12:33:45 pm »
Do yourself a favor and get a normal PC (normal as in Windows).
Then you have access to plenty ready to run development environments (Raisonance, Keil, IAR, etc) so you can focus on the Cortex itself instead of being bothered by all the quirks of OSS. Having the compiler is one thing, but you also want a reasonable IDE, and a debugger. Getting all that together and up and running on weird host systems is a waste of time.
And you'll need that time to get around with the Cortex itself ;) Great micro, but so many features that it can be a pita to get things like periperals up and running. After a few times, you get familiar with it, and such things become more obvious, but in the beginning it can be a serious problem.
 

Offline ToBeFrank

  • Regular Contributor
  • *
  • Posts: 234
  • Country: us
Re: Beginning Cortex M3, but so lost!!
« Reply #9 on: January 06, 2012, 03:15:08 pm »
Do yourself a favor and get a normal PC (normal as in Windows).
Then you have access to plenty ready to run development environments (Raisonance, Keil, IAR, etc) so you can focus on the Cortex itself instead of being bothered by all the quirks of OSS. Having the compiler is one thing, but you also want a reasonable IDE, and a debugger. Getting all that together and up and running on weird host systems is a waste of time.

I agree. I also run Mac OS X so I have my Cortex dev environments installed in a virtual machine. I've had no problems doing that. I looked into getting everything set up on Mac and concluded it's just not worth the hassle. Rowley Crossworks runs on Mac, but the cheapest version is $150 and that's only if you don't ever plan to sell anything you write with it.

I started with the NXP LPCXpresso. It's a $30 dev board that includes a JTAG/SWD programmer. When you're ready to move on to your own projects you can separate the programmer and use it for your own boards. The IDE and compiler that is part of LPCXpresso is free for anything under 128KB of flash. It's based on Eclipse and it works pretty well. The LPC1768 LPCXpresso seems to be a popular M3 dev board and there are plenty of examples out there for it. I just read the LPC1768 user guide and looked at examples and I was up and running.
 

Offline bruce273

  • Contributor
  • Posts: 39
  • Country: gb
Re: Beginning Cortex M3, but so lost!!
« Reply #10 on: January 06, 2012, 05:39:33 pm »
The documentation will be per procosser so you'll need to determine which chip you want to use first as they all have different internal peripherals. If you choose the stm32 m3 chips they'll normally call the most usful document the reference manual it contains all the register definitions and how they work.
The programming manual normally gives information on memory addressing modes and the instruction set of the processor which isn't that important for C programming.
The datasheet itself is also quite helpful as it gives the electrical characteristics, so read up on it an check the maximum current draw, and be careful as the specifications of the pins occasionally change if there function is changed

I started on windows using the attolic IDE for stm chips. it isn't amazing but it's an ok starting point as it has all the necessary header files for C which allow you to use premapped function registers.

Macs and linux pcs are not quite as easy for a bigginer unless you are already used to makefiles and such and I think codeblocks has reasonably nice arm compiler support if you prefer the open source route on any platform aswell. Just takes a little more effort to set up and you'll have yet more manuals to read for the compilers aswell down that route.

I used a midibox based stm32 board. But stm provide a discovery board which is similar to the nxp. It does run at 72MHz rather than 100MHz so if speed is important.
 

Offline bruce273

  • Contributor
  • Posts: 39
  • Country: gb
Re: Beginning Cortex M3, but so lost!!
« Reply #11 on: January 06, 2012, 05:42:42 pm »
Do yourself a favor and get a normal PC (normal as in Windows).
Then you have access to plenty ready to run development environments (Raisonance, Keil, IAR, etc) so you can focus on the Cortex itself instead of being bothered by all the quirks of OSS. Having the compiler is one thing, but you also want a reasonable IDE, and a debugger. Getting all that together and up and running on weird host systems is a waste of time.

I agree. I also run Mac OS X so I have my Cortex dev environments installed in a virtual machine. I've had no problems doing that. I looked into getting everything set up on Mac and concluded it's just not worth the hassle. Rowley Crossworks runs on Mac, but the cheapest version is $150 and that's only if you don't ever plan to sell anything you write with it.

I started with the NXP LPCXpresso. It's a $30 dev board that includes a JTAG/SWD programmer. When you're ready to move on to your own projects you can separate the programmer and use it for your own boards. The IDE and compiler that is part of LPCXpresso is free for anything under 128KB of flash. It's based on Eclipse and it works pretty well. The LPC1768 LPCXpresso seems to be a popular M3 dev board and there are plenty of examples out there for it. I just read the LPC1768 user guide and looked at examples and I was up and running.

Have you tried wine for mac this guys made a nice user interface for it http://winebottler.kronenberg.org/ it's open and free. Think crossworks is based on wine aswell.
 

Offline steff

  • Contributor
  • Posts: 30
Re: Beginning Cortex M3, but so lost!!
« Reply #12 on: January 06, 2012, 06:01:25 pm »
Not M3, but as a very simple environment in which to get used to ARM, you might want to have a look at http://mbed.org/
 

Offline dt

  • Contributor
  • Posts: 8
Re: Beginning Cortex M3, but so lost!!
« Reply #13 on: January 06, 2012, 08:54:08 pm »
Do yourself a favor and get a normal PC (normal as in Windows).

Hehe, for an increasing number of people the "normal PC" is the Mac, whereas Windows is the unstable, slow and fiddly thing of the past. I have a bunch of vista boxes sitting in the closet and the idea of using them for anything is a nightmare that makes me wonna cry ;D

More seriously now: I'm just a beginner hobbyist in electronics but have a 15y old career in Software eng. I have developed software in all the popular platforms and then some, and I can honestly say that the xcode platform on the mac (which is really a unix OS with a nice UI and extensions) is by faaaaar the most advanced AND user friendly IDE for software dev. And I'm not only talking about code completion and other similar features that everyone has, but for a collection of highly sophisticated static analysis and profiler tools that help the average Joe truly optimize their code. And they are so user-friendly that it makes you wonna cry. No one else offers this degree of sophistication in their IDE, while it comes for free with any modern Mac.

xcode uses the gcc compiler so pretty much any hardware can be targeted, has assembler/disassembler, linker, debugger, etc.., etc.. Of course, the problem in question is how to integrate JTAG, which is an area that I'll have to investigate further. The argument on spending time on setting up the toolchain rather than learning to program the cortex does not have a straight forward answer. Having a good toolchain in place is guaranteed to speed up development in the long run, so in my opinion the time spent in setting up a good environment is an investment. But I'm sure people can argue either way :)

Anyhoo, I now understand a bit more about the process and thanks everyone for your input. Reading the documentation from Keil, IAR, and Crossworks were the best pointers, ironically.
 

alm

  • Guest
Re: Beginning Cortex M3, but so lost!!
« Reply #14 on: January 06, 2012, 09:57:54 pm »
Not M3, but as a very simple environment in which to get used to ARM, you might want to have a look at http://mbed.org/
Most mbed's are based on the LPC 1768, a Cortex M3. I believe there is a new version based on the M0, but I'm not sure if it's available yet.

xcode uses the gcc compiler so pretty much any hardware can be targeted, has assembler/disassembler, linker, debugger, etc.., etc.. Of course, the problem in question is how to integrate JTAG, which is an area that I'll have to investigate further. The argument on spending time on setting up the toolchain rather than learning to program the cortex does not have a straight forward answer. Having a good toolchain in place is guaranteed to speed up development in the long run, so in my opinion the time spent in setting up a good environment is an investment. But I'm sure people can argue either way :)
Nothing wrong with choosing your own IDE, you'll just have more work getting it to work compared to complete packages of IDE, compilers, programmers and debuggers like Code Red.

Anyhoo, I now understand a bit more about the process and thanks everyone for your input. Reading the documentation from Keil, IAR, and Crossworks were the best pointers, ironically.
NXP, STM and TI are the places to be for ARM Cortex M3 for hobbyists in my opinion. Atmel seems to be behind (did they release their M0 parts yet?), and most others seem purely focused on industry. Choose whichever appears to have the best toolchain support. I believe the JTAG dongle part of the LPCXpresso is closed, there is some support for the STM32 Discovery JTAG interface by flashing it with a different firmware. This does not matter if you use a different JTAG interface. OpenOCD UrTAG will probably have Mac support. Note that many of the low pin count ARMs will use SWD, not the traditional JTAG. Other useful search terms may be Codesourcery Lite, they make a free GCC toolchain for ARM, although they may not have binaries for Mac, and CMSIS, which is a kind of standardized hardware abstraction for ARM Cortex.
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 3143
  • Country: us
Re: Beginning Cortex M3, but so lost!!
« Reply #15 on: January 07, 2012, 10:09:54 am »
Quote
xcode uses the gcc compiler so pretty much any hardware can be targeted
When you've got XCODE working and cross compiling for some CM3 ARM chip, be sure to write up how you managed to do it!

The compiler is relatively easy; the core libraries (libgcc, libc,  cmsis) are a pain in the license, and the peripheral libraries are going to be vastly different on a per-manufacturer basis.  You'd definitely have an easier time using one of the pre-packaged IDEs.
 

Offline McMonster

  • Frequent Contributor
  • **
  • Posts: 417
  • Country: pl
    • McMonster's blog
Re: Beginning Cortex M3, but so lost!!
« Reply #16 on: January 07, 2012, 12:35:05 pm »
I've heard that manufacturer supplied libraries for some ARMs are nothing but crap, so at least this shouldn't be a problem. I'm starting using ARMs too, but I've choosen Eclipse (yeah, I know it's a bloated hog, but it keeps all my coding work in a single, well known and configured environment, sometimes simplicity is just not enough) as IDE, CodeSourcery's G++ Lite toolchain and OpenOCD as debugging backend (there's a guide how to set this up, but unfortunately in Polish).

After extensive analyzing of what's available to get I've choosen SMT32s, they have a really wide choice of chips and dev boards including their dirt cheap discovery boards, less than 20$ shipped and with integrated SWD programmer that can work as standalone. I'm actually getting one discovery board and one more powerful with Ethernet, USB and JTAG interfaces and with most of the IO pins routed to goldpins. I don't really like all-in-one, expensive boards with tons of devices hardwired and no user access to IO pins directly, but I really wanted built-in Ethernet for future use. I already have a JTAG, a hobbyist designed and produced device that's comparable in availability to Dave's uCurrent. Once in a while a small batch appears and is sold out in the matter of 2-3 hours. :) It's a really great FT232 based programmer with integrated JTAG, RS232 and UART interfaces, I can do a small teardown/review if you want (again original materials are all in Polish).
 

Offline steff

  • Contributor
  • Posts: 30
Re: Beginning Cortex M3, but so lost!!
« Reply #17 on: January 07, 2012, 01:02:52 pm »
Not M3, but as a very simple environment in which to get used to ARM, you might want to have a look at http://mbed.org/
Most mbed's are based on the LPC 1768, a Cortex M3. I believe there is a new version based on the M0, but I'm not sure if it's available yet.

Good point. I'd misremembered - been a while since I touched one, and of course the front page is shouting about the new version to confuse me further. I do recall it being a nice easy introduction though, so the recommendation stands.
 

Offline benemorius

  • Regular Contributor
  • *
  • Posts: 173
Re: Beginning Cortex M3, but so lost!!
« Reply #18 on: January 08, 2012, 06:15:35 am »
I've used GCC with kdevelop on linux. I forget what toolchain I decided on, but I believe I used both codesourcery and gnuarm. I was able to get jtag debugging going in kdevelop through GDB and openocd. It was very buggy, but I think that was mostly or entirely due to kdevelop. I believe you should be able to use all of the above with xcode on osx.

I know exactly how you feel about sticking with xcode. I had the pleasure of using it pretty extensively a few years ago. Since then, using any other IDE just hasn't been as enjoyable as it use to be. I've been spoiled for sure. :( I'm looking forward to using to it again more permanently on an airbook as soon as they release one with a proper macbook-worthy LCD so I'm pretty interested to hear about your experiences. I do hope you don't give in before you get it working. It's certainly true that getting everything going on that other OS is less trouble, but working within a foreign environment is quite a distasteful solution for something you're going to be using regularly and that's true regardless of which OS is the "other" one to you.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf