9 years, 8 months ago.

Looking for 'overview' docs for general M3 c or c++ programming

Greets to all!

I'm coming from the Arduino world with an NXP LPC1549 board. My first IDE has been with the NXP-supplied LPCXPresso v7. In Arduino, I use Microsoft Visual Studio with the VisualMicro add-on. I'm most anxious to learn and enjoy the world of an on-chip debugger.

While the examples supplied by NXP are ok - They are a bit skimpy on explanations.

I'm looking to find documentation with general guidelines on how one should structure an M3, c/c++. program. By this I mean - what would be the order of setup steps - I understand there is a vector table for interrupt handlers, timer setups and so on. What is the general 'setup/housekeeping' sort of pieces need to be used to start any program/application.

Most of the books I've found all seem to address assembly language or are basic intro's to the c language.

There must be a sort of general 'template' of the setup structure to get the the M3 ready before you jump into your actual code. Obviously this all depends on what peripheral (s) one is working with, but there should (I hope) be common order in which to set up essentials - includes, timers, masks, pins... whatever.

Any ideas?

Alan R.

1 Answer

9 years, 8 months ago.

I understand you aren't using mbed?

I don't know if there is an overview, but it really depends on your requirements. Contrary to an 8-bit atmel which is the default Arduino, pretty much all ARM M3s and similar ones have clocking options done in code instead of with special bits. So initially you will need to set the clock source correctly, enable the PLL, etc.

Timers, pins, etc, all depends on if you want to use the or not. If you do you can find in the user manual the required tasks to enable them. I can imagine you want to setup timers first if you also use them for things like wait statements, or an uart if you use it for debugging purposes.

Interrupt vector tables can be moved to RAM (mbed does so), but they can also be kept in flash by using the standard defined interrupt function names.

In general you probably will need to look at examples and how they do it. You can at least learn alot from it, and in general it is useful to know how it works, but you don't need to re-invent the wheel either.

I'm just getting started, so looking at all options. When I tried to set up the mbed serial driver to the LPC1549, it said "no boards present" - and the 'fixes' for that look to be a pain.... So I'm going back to the NPCXpresso IDE for now. MBED looks super, but since I can't hook up to the board....

I've printed all 800 pages of the so called 'users guide' from NPX which is great to show the capabilities of the M3. I also have a number of other similar docs - but nothing talks about how one

I also have a full collection of example programs for each peripheral (from NXP) and have been looking at them. But they really don't explain much - stuff is just 'there' with no reason give.

But what I'm looking for is a sort of proper 'general setup workflow' - ie something like this: 1. Set up systick 2. set up interrupt vecs (if used) 3. set up needed pins 4 and so on

There should be an essential init steps one does for each program, obviously tailored by what peripherals are being used.

Since I'm not finding any sort of books or docs along these lines, it must already be somewhere in another form and I'm just not 'getting it'! :-)

Alan R.

posted by Alan Reinhart 12 Aug 2014

Did you look at the mbed source to see how they do it? It won't be exactly what you want but is at least an example of something that works and the bulk of the setup code seems to have a reasonable level of comments.

http://mbed.org/users/mbed_official/code/mbed-src/file/bf0f62a62bf4/targets/cmsis/TARGET_NXP/TARGET_LPC15XX/system_LPC15xx.c would be a starting point

posted by Andy A 13 Aug 2014