LPC1769 using LPCXpresso IDE

ChibiOS public support forum for topics related to the NXP LPC family of Cortex-M micro-controllers.

Moderator: theShed

User avatar
jcw
Posts: 55
Joined: Thu May 23, 2013 12:59 am
Location: Houten, NL

Re: LPC1769 using LPCXpresso IDE

Postby jcw » Fri May 24, 2013 11:46 am

Thanks for looking into this. I'm starting out with ChibiOS (and looking forward to the journey ahead!) - my vote would be for a basic demo, i.e. blinking LED w/ test suite reporting over serial. That's plenty to get started, and indeed there are a lot of peripherals. The most common boards are no doubt MBED and LPCXpresso 1769.

-jcw

User avatar
Giovanni
Site Admin
Posts: 11224
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 401 times
Been thanked: 333 times
Contact:

Re: LPC1769 using LPCXpresso IDE

Postby Giovanni » Fri May 24, 2013 4:07 pm

BTW, you can use ChibiOS just like any other RTOS without the HAL, it works perfectly on any Cortex micro right now.

Giovanni

User avatar
jcw
Posts: 55
Joined: Thu May 23, 2013 12:59 am
Location: Houten, NL

Re: LPC1769 using LPCXpresso IDE

Postby jcw » Sat May 25, 2013 10:05 pm

Thanks, good point. I'm up to my armpits in boards right now, but starting to understand how family & brand differences work. It sure is a big world, for someone coming from the sheltered life of Arduino's, ATmega's, and ATtiny's ... I suppose it's good to have that much choice, but it's also somewhat overwhelming.

I rather like the HAL, actually - it simplifies life.

-jcw

User avatar
jcw
Posts: 55
Joined: Thu May 23, 2013 12:59 am
Location: Houten, NL

Re: LPC1769 using LPCXpresso IDE

Postby jcw » Sat May 25, 2013 10:45 pm

To follow up - just came across what seems like a port to lpc17xx: https://github.com/stepmc/chibios-lpc1768

theShed
Posts: 50
Joined: Tue Feb 26, 2013 3:43 pm
Location: The flatlands of East Anglia

Re: LPC1769 using LPCXpresso IDE

Postby theShed » Sat May 25, 2013 11:22 pm

Its a start, but not completed.....
Will need a bit of work before I would be happy to include it.

--
mike

User avatar
jcw
Posts: 55
Joined: Thu May 23, 2013 12:59 am
Location: Houten, NL

Re: LPC1769 using LPCXpresso IDE

Postby jcw » Sun May 26, 2013 10:56 am

Mike, can you elaborate? Maybe I can help.

theShed
Posts: 50
Joined: Tue Feb 26, 2013 3:43 pm
Location: The flatlands of East Anglia

Re: LPC1769 using LPCXpresso IDE

Postby theShed » Sun May 26, 2013 7:23 pm

A good start would be the clock config code in
'os/hal/platforms/LPC17xx/hal_lld.c'

--
mike

User avatar
jcw
Posts: 55
Joined: Thu May 23, 2013 12:59 am
Location: Houten, NL

Re: LPC1769 using LPCXpresso IDE

Postby jcw » Sun May 26, 2013 8:30 pm

Bear with me... is this about converting the code from https://github.com/stepmc/chibios-lpc17 ... 7xx.c#L503 to get it into https://github.com/stepmc/chibios-lpc17 ... _lld.c#L80 ?

theShed
Posts: 50
Joined: Tue Feb 26, 2013 3:43 pm
Location: The flatlands of East Anglia

Re: LPC1769 using LPCXpresso IDE

Postby theShed » Sun May 26, 2013 10:24 pm

Sorry, I should have given a bit more info.
Use the LPC13xx port as a reference to how the code should be structured - this code is a modified version of that anyway.
And I would start from a clean Chibios checkout for two reasons:
1 - its easy to diff your changes against the current tree
2 - not sure what else you might catch......

Clock/PLL configuration
-----------------------------------
This is usually the hardest bit of a new port because if you get it wrong the device will probably do nothing at all....(and if the clock is fubar a debugger is no use either)
The xx_clock_init() function should set up the clocks/plls based on a set of config parameters. These parameters are configured in the application config file mcuconf.h. The set of config parameters, possible values and suitable default configuration are defined in hal_lld.h.

So, using the code in system_LPC17xx.c as a guide (and the LPC17xx user manual - don't assume that the code is correct!), come up with a set of defines (and suitable defaults) for hal_lld.h. I usually make the default a very simple case eg. internal OSC, no pll, minimal divider set-up so that it is pretty much always going to work.
Then use this set of defines and the code from system_LPC17xx.c to fill out LPC17xx_clock_init().
Try and be logical about it; if you examine the LPC13xx code you will see that it will only enable the system oscillator and configure the pll if the main system clock is set to be the pll output. Obvious really, but the original ARM code always tried to set-up the pll even if the oscillator wasn't enabled.
And finally, make sure you enable the clocks to the GPIO blocks.

GPIO driver (pal_lld)
------------------------------
I think that this will work.

Linker script
------------------
I'm assuming you are using GCC?
create this file: os / ports / GCC / ARMCMx / LPC17xx / ld / LPC1769.ld
The 1768 file should be fine to start off with and change the reference in the application makefile.

Board Files
-----------------
Create a board directory: boards /<SOME-BOARD-NAME>/
Again copy the 1768 version - but think of a better name, look in the main chibios repository for some ideas. Inspect the three files and modify as appropriate, ie references in the makefile, default gpio setup in board.h.
Change the reference in the application makefile


and that's it - you now have a very basic, but functional, LPC1769 port that should at least be able to make the leds flash. :D

Have fun and if need any pointers (or find I've missed something) please let me know.
--
mike

User avatar
jcw
Posts: 55
Joined: Thu May 23, 2013 12:59 am
Location: Houten, NL

Re: LPC1769 using LPCXpresso IDE

Postby jcw » Tue May 28, 2013 8:00 pm

Many thanks - this does clear up a lot. No promises, but I'll see if I can work on this at some point.


Return to “LPC Support”

Who is online

Users browsing this forum: No registered users and 1 guest