CMSIS2000  0.0.7
 Указатель Структуры данных Файлы Функции Переменные Определения типов Перечисления Элементы перечислений Макросы Группы Страницы
MIGRATION GUIDE FROM LPC1700 to LPC2000

The problem description.

Today (2012) the modern MCU core is Cortex-M3 core. So there is many examples and libraries made for Cortex MCUs. Also NXP company has their LPC17xx series that is close to LPC23xx and 24xx series MCU. There are not so many differences in that microcontrollers. They have the same or close peripherals.

So this instructions is good in that two cases:

  • You have sources for LPC17xx MCU you want to make it work on LPC2000 to.
  • You have sources for LPC2xxx MCU but you want to prepare to migrate to LPC17xx family.

Instructions steps.

1. Get modified LPC17xx peripheral library sources CMSIS2000 project from http://sourceforge.net/projects/irtos/

2. Install cmake build system from cmake.org.

3. Copy CMAKE folder from CMSIS/Device/NXP/Drivers/Examples/Project_Template/CMAKE_CMSIS2000 with CMakeLists.txt file to main folder of you project.

4. Open CMakeLists.txt and add sources of your project to `exmpl_sources' list.

5. Create a project files by running cmake. (look *.bat files for example).

6. Modify your sources to some rules that described next.

Modify sources.

Use auto-generated mcu_id.h file and i_MCU_MODEL definition.

The first you should know that THERE IS NOT 100 % compatibility with LPC1700 and LPC2000 MCU series. So there is a i_MCU_MODEL definition witch included automatically in LPC17xx.h file and mcu_id.h file .

#include "LPC17xx.h"
#if ((i_MCU_MODEL > 1700) && (i_MCU_MODEL < 1800))
// Set RS485 control to default state
((LPC_UART1_TypeDef *)UARTx)->RS485CTRL = 0;
// Set RS485 delay timer to default state
((LPC_UART1_TypeDef *)UARTx)->RS485DLY = 0;
// Set RS485 addr match to default state
((LPC_UART1_TypeDef *)UARTx)->ADRMATCH = 0;
#endif

Interrupt Handlers

DO NOT USE InterruptHandlers in manner of CMSIS!

It is a pity but LPC2000 interrupt routines must be marked with special keyword __attribute__((IRQ)) so there is a special macroses in CMSIS2000 project. You should write Interrupt code in this manner:

#include "mcu_id.h"
#include "arch/interrupt.h" //for ISR_IRQ_PROTO()
volatile uint32_t cntr_uart;
ISR_IRQ(UART0)
{
cntr_uart++;
}

In case of MCU is LPC17xx the result of preprocessing the previous example will be:

void UART0_IRQHandler (void);
volatile uint32_t cntr_uart;
void UART0_IRQHandler (void)
{
cntr_uart++;
}

In case of MCU is LPC2xxx the result of preprocessing the previous example will be:

void UART0_IRQHandler (void) __attribute__ ((interrupt("IRQ")));
volatile uint32_t cntr_uart;
inline static void UART0_IRQHandler_internal( void );
void UART0_IRQHandler(void) {
UART0_IRQHandler_internal() ; ((VIC_TypeDef *) 0xFFFFF000 )->VectAddress = 0;
};
inline static void UART0_IRQHandler_internal( void )
{
cntr_uart++;
}