LPC2148 (non olimex)

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

Moderator: theShed

miphos
Posts: 4
Joined: Wed Jun 05, 2013 10:23 pm

LPC2148 (non olimex)

Postby miphos » Wed Jun 05, 2013 10:44 pm

Is there any tutorial to modify the demo of the LPC2148 to a custom plataform?
I know there is the demo and is very useful, but I modify the values of the file board.h in the (CHIBIOS)/boards/OLIMEX_LPC_P2148/ but doesn't work...

The olimex board use a crystal of 12Mhz, my board uses a 10 Mhz, so I through that modifying the values of FOSC and CCLK and PCLK will work... but doesn't.

Original
#define FOSC 12000000
#define CCLK 48000000
#define PCLK 12000000


For my board
#define FOSC 10000000
#define CCLK 40000000
#define PCLK 10000000


I know that the modify was navy for my part, but that was the last thing that come to my mind. I know there are the help in the source page and that, but is still some of confusing... not that full help or something... just asking here if there is any one that can help.

Thanks for reading. :geek:

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

Re: LPC2148 (non olimex)

Postby theShed » Wed Jun 05, 2013 11:44 pm

What do you mean by "doesn't work" ?

Changing FOSC, without modifying the PLL dividers, should give the CCLK/PCLK frequencies you expected.

--
mike

miphos
Posts: 4
Joined: Wed Jun 05, 2013 10:23 pm

Re: LPC2148 (non olimex)

Postby miphos » Thu Jun 06, 2013 11:13 pm

Hi mike, thanks for the answer.
Well, for "doesn't work" I mean that doesn't sent anything for the serial interface, and don't do anything with the GPIO, nor turning a led but the compilation with YAGARTO and YAGARTO Tools says that everything is well (this is my first non microchip btw) . Maybe is for the code that I wrote.... whatever, I will try what you say and if it works going to post the results.
There is a "Programming for dummies with ChibiOS" ?

Code: Select all

#include "ch.h"
#include "hal.h"
int main(void) {
sdStart(&SD1, NULL);
sdStart(&SD2, NULL);
while (1) {   
sdWrite(&SD1, (uint8_t *)"Hello World!\r\n", 14);
//TestThread(&SD1);
chThdSleepMilliseconds(500);
sdWrite(&SD2, (uint8_t *)"Hello World!\r\n", 14);
//TestThread(&SD2);
chThdSleepMilliseconds(500);
}
return 0;
}


That is the code, I copy and paste some lines from the demo....
I need to manage the tasks and in resume, know the most important functions in the OS.
Your help will be very appreciated in this sir.

Have a nice day, thanks for the answer. :geek:

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

Re: LPC2148 (non olimex)

Postby theShed » Fri Jun 07, 2013 11:17 am

OK, two things that stand out:

1) The system initialisation code is missing

Code: Select all

int main(void) {

  /*
* System initializations.
* - HAL initialization, this also initializes the configured device drivers
* and performs the board-specific initializations.
* - Kernel initialization, the main() function becomes a thread and the
* RTOS is active.
*/
  halInit();
  chSysInit();


2) there is no code to turn on/off an LED. Something like this:

Code: Select all

  while (TRUE) {
    palClearPad(IOPORT1, PA_LEDRED);
    chThdSleepMilliseconds(500);
    palSetPad(IOPORT1, PA_LEDRED);
    chThdSleepMilliseconds(500);
  }


The best place to start, *always*, is with a LED.... serial ports are far more complicated and a flashing LED gives a quick visual confirmation that it is doing something.

You say that you have a custom board, in that case you will probably need to modify the GPIO configuration in <BOARD>/board.h.
If you need any help with that let me know.

No dummies guide - any general RTOS guide is a good place to start for how an RTOS operates, after that the chibios specific documentation http://chibios.org/dokuwiki/doku.php?id=chibios:documents to understand the chibios implementation of an RTOS.

good luck

--
mike

miphos
Posts: 4
Joined: Wed Jun 05, 2013 10:23 pm

Re: LPC2148 (non olimex)

Postby miphos » Thu Jun 13, 2013 6:25 pm

Well, it's working now. I have know that the ADC and other drivers hasn't supported, I've been working with other OS and maybe I can make up the drivers (if there is any help will be very appreciated :) ). Will do that and if everything works well will post it here.

Thanks for the help, the FOSC actually make it all work, was a hardware malfunction in my board.

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

Re: LPC2148 (non olimex)

Postby theShed » Thu Jun 13, 2013 6:46 pm

Good to hear that you have it working.

For any drivers that have not been implemented:
1. a template can be found in /os/hal/templates, copy the template to the hal platform directory and fill in the missing bits ;-)
2. add the driver file to the platform makefile.
3. enable the driver in halconf.h
4. add any required flags to mcuconf.h eg PLATFORM_ADC_USE_ADC1 for the ADC driver

hope tha helps

--
mike

miphos
Posts: 4
Joined: Wed Jun 05, 2013 10:23 pm

Re: LPC2148 (non olimex)

Postby miphos » Mon Jul 15, 2013 4:26 pm

Well, it's been a month and just retake the ADC and this is what I have.

I make work the ADC in other OS by just adding some memory directives to the file

Code: Select all

 lpc214x.h
in the core system. But here this appears to not work that way. Is there anything that can suguest to do?

This is an example of the way It's used to be in other OS to work.

Code: Select all

#define AD0_BASE_ADDR      0xE0034000
#define AD0CR           (AD0_BASE_ADDR + 0x00)
#define AD0GDR         (AD0_BASE_ADDR + 0x04)
#define AD0STAT        (AD0_BASE_ADDR + 0x30)
#define AD0INTEN       (AD0_BASE_ADDR + 0x0C)
#define AD0DR0          (AD0_BASE_ADDR + 0x10)
#define AD0DR1          (AD0_BASE_ADDR + 0x14)
#define AD0DR2          (AD0_BASE_ADDR + 0x18)
#define AD0DR3          (AD0_BASE_ADDR + 0x1C)
#define AD0DR4          (AD0_BASE_ADDR + 0x20)
#define AD0DR5          (AD0_BASE_ADDR + 0x24)
#define AD0DR6          (AD0_BASE_ADDR + 0x28)
#define AD0DR7          (AD0_BASE_ADDR + 0x2C)


or maybe like this:

Code: Select all

#define AD0_BASE_ADDR      0xE0034000

#define AD0CR           (*(volatile unsigned long *)(AD0_BASE_ADDR + 0x00))
#define AD0GDR         (*(volatile unsigned long *)(AD0_BASE_ADDR + 0x04))
#define AD0STAT        (*(volatile unsigned long *)(AD0_BASE_ADDR + 0x30))
#define AD0INTEN       (*(volatile unsigned long *)(AD0_BASE_ADDR + 0x0C))
#define AD0DR0          (*(volatile unsigned long *)(AD0_BASE_ADDR + 0x10))
#define AD0DR1          (*(volatile unsigned long *)(AD0_BASE_ADDR + 0x14))
#define AD0DR2          (*(volatile unsigned long *)(AD0_BASE_ADDR + 0x18))
#define AD0DR3          (*(volatile unsigned long *)(AD0_BASE_ADDR + 0x1C))
#define AD0DR4          (*(volatile unsigned long *)(AD0_BASE_ADDR + 0x20))
#define AD0DR5          (*(volatile unsigned long *)(AD0_BASE_ADDR + 0x24))
#define AD0DR6          (*(volatile unsigned long *)(AD0_BASE_ADDR + 0x28))
#define AD0DR7          (*(volatile unsigned long *)(AD0_BASE_ADDR + 0x2C))


and of course this is not my code, this was an header file that was in other OS and is kinda different from what I used to know...

The questions are:
How can I add memory directives that can be modifited like the PINSEL0 or PINSEL1 in the board.h file?
How can I make it simple?

Something that at the end will look like this:

Code: Select all

#define VAL_PINSEL0 0xCF05FF55
#define VAL_PINSEL1 0x15041800
#define VAL_PINSEL2 0x00000004


I know is going to be hard... but maybe someone can help...

Thanks for reading. Hope you can help. :geek:


Return to “LPC Support”

Who is online

Users browsing this forum: No registered users and 1 guest