ARM sample code

I got one of those NXP LPCXpresso boards with a Cortex M3 ARM on it, installed the dev tools, and whadda ya know, the demo using the semihosting thing works OK, for printf("Hello, World!") at least.

Sooo, now the problem is porting a bunch of fairly simple PIC code over to the ARM, for controlling RC servos etc. Not too radical a job, _except_ that, as always with a new micro, more than half the work is getting the peripheral control registers set up right.

Does anybody have a reasonably complete and well-commented (preferably exhaustively commented) Cortex M3 setup routine he could share? That would save me some significant time, since MCU programming isn't my main gig--it's just one of the several zillion things you have to be able to do to get mixed-technology things to work.

Thanks

Phil Hobbs

--
Dr Philip C D Hobbs
Principal
ElectroOptical Innovations
55 Orchard Rd
Briarcliff Manor NY 10510
845-480-2058
hobbs at electrooptical dot net
http://electrooptical.net
Reply to
Phil Hobbs
Loading thread data ...

Just to be clear, is this PIC assembly ??

over

Reply to
hamilton

Download the examples from NXP's website. These are exhaustive and also work for other compilers than the ones from KEIL.

--
Failure does not prove something is impossible, failure simply
indicates you are not using the right tools...
nico@nctdevpuntnl (punt=.)
--------------------------------------------------------------
Reply to
Nico Coesel

If you have "Hello, World", then everything is already setup for the boot code.

What else do you need to setup, except for I/Os? For example (for Keil):

GPIODirModeSet(GPIO_PORTB_BASE, GPIO_PIN_1, GPIO_DIR_MODE_IN); GPIOPinRead(GPIO_PORTB_BASE, GPIO_PIN_1); GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_1, 0);

Reply to
linnix

No, it's C written for the Hi-Tech compiler (which is a very nice tool, btw).

Cheers

Phil Hobbs

--
Dr Philip C D Hobbs
Principal
ElectroOptical Innovations
55 Orchard Rd
Briarcliff Manor NY 10510
845-480-2058
hobbs at electrooptical dot net
http://electrooptical.net
Reply to
Phil Hobbs

PWMs, captures, ADC, DAC, motor control,...

I usually suck down the manual and write a well-commented single function that sets all of them and discusses just what each bit is for. This manual is almost 900 pages, and I don't want to spend that amount of time if I can help it.

Cheers

Phil Hobbs

--
Dr Philip C D Hobbs
Principal
ElectroOptical Innovations
55 Orchard Rd
Briarcliff Manor NY 10510
845-480-2058
hobbs at electrooptical dot net
http://electrooptical.net
Reply to
Phil Hobbs

r

I can post codes for PWM and ADC. LPC11XX does not have DAC.

Reply to
linnix

I usually go through the manual and write a routine that sets each "thing" to its default state. This serves several purposes.

First, it gets me aware of what's inside the box. It makes me aware of how many of whatever.

Second, it lets me see what capabilities each of those things has. And, exposes me to any restrictions on the uses of those capabilities (e.g., pin sharing, etc.).

Third, it gives me a convenient place in my code to reference the "default conditions" for each of these devices. Saves a trip through the manual!

Fourth, it gives me a starting point for the "my version" of this routine -- i.e., after everything is at its default state, now I need to bring these things to the state that

*I* want them to be in for *this* application.

Fifth, it gives me a convenient way to reset everything AS IF power had just been applied. This is often invaluable with devices that must run unattended "indefinitely" -- where you can't rely on a PoR (and don't want to risk a watchdog reset).

Lately, as datasheets are getting *so* fat, I add crossreferences in the commentary pointing me to pages/sections in the datasheet (manual). I also paraphrase key restrictions on the initialization so I don't have to re-consult the datasheet (e.g., X must be initialized before Y *because*...)

Reply to
D Yuniskis

Thanks! This one is the LPC1343 version, which does have a DAC.

At the risk of some scorn and derision from Real Programmers, I'll post a link to the completed function when it's done.

Cheers

Phil Hobbs

--
Dr Philip C D Hobbs
Principal
ElectroOptical Innovations
55 Orchard Rd
Briarcliff Manor NY 10510
845-480-2058
hobbs at electrooptical dot net
http://electrooptical.net
Reply to
Phil Hobbs

ver

s
;

I don't see the DAC, only 8 channels 10 bits ADC.

formatting link

43.pdf
Reply to
linnix

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.