Secondary CAN bootloader LPC11C24 (interrupts in user app are not running)

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Secondary CAN bootloader LPC11C24 (interrupts in user app are not running)

592 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Lea on Sat Feb 13 00:44:20 MST 2016
I have written a bootloader for the LPC11C24, that works so far.
The Blinky program from the LPCOpen is running when I flash the firmware with the bootloader, but it does not supports interrupts in my user app.

I copy the vector table from my user app to the location of the vector table of the bootloader before I call the user app.

Is there anything else to be noted?

void run_userApp(void)
{
unsigned int entry;

SysTick->CTRL = ~(1<<0);
NVIC_DisableIRQ(SysTick_IRQn);

__disable_irq();

// copy first 0x200 bytes (vector table)
Prepare_Copy((uint32_t *)APP_START_ADDR, (uint32_t *)0x10000000, 512);

// User RAM Mode. Interrupt vectors are re-mapped to Static RAM
LPC_SYSCTL -> SYSMEMREMAP = 0x01;
    __enable_irq();
   
    __set_MSP(*(uint32_t *)APP_START_ADDR);
entry = *((volatile unsigned int *)(APP_START_ADDR + 4));

((void(*)(void))entry)();
}
Labels (1)
0 Kudos
4 Replies

495 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Lea on Sat Feb 13 03:26:11 MST 2016
Thanky for your reply!

No I not copy 2K, because I decrement len -= 4;

Yes I read this thread in your link and it's the source of my run_userApp
0 Kudos

495 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by R2D2 on Sat Feb 13 02:21:53 MST 2016

Quote: Puschmann
I read in AN??? that I must copy my vector table from my user app to static RAM...



As shown in:

https://www.lpcware.com/content/forum/2nd-bootloader-requiring-the-same-interrupt-in-bootloader-and-...


You are copying 2k (512 * 4 bytes)  :quest:  :~

0 Kudos

495 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Lea on Sat Feb 13 02:09:21 MST 2016
Thanks for your reply!

The above function is called by my bootloader.
When the bootloader starts a CRC value is checked. If CRC is OK the methode run_user app is called to start the user app.
The user app does run fine, but the interrupts are not supported.

I read in AN??? that I must copy my vector table from my user app to static RAM (doing in prepare_copy(...))

/**
* @brief Copy a number of words from source to destination
* @param src: Pointer to source address
* @param dst: Pointer to destination
* @param len: Number of words to copy
*/
void Prepare_Copy( uint32_t * src, uint32_t * dst, uint32_t len )
{
    if(dst != src)
    {
        while(len)
        {
            *dst++ = *src++;

            len -= 4;
        }
    }
}

and then set the system memory remap register to 0x01 (UM10398, page 26) to select that the ARM interrupt vectors are read from SRAM.
0 Kudos

495 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by mysepp on Sat Feb 13 01:15:23 MST 2016
The above function is called by bootloader to start user app?
Is it not the task of user app to setup and enable interrupts,
so it can (at least theoretically) run stand-alone without bootloader (perhaps relocation needed)?
I would call user app with disabled interrupts and user app can enable them if it wants to.

Other question: What happens? Does it crash? Does it just not call interrupts, but main() of user app is called,
because you see blinking LEDs. Usually each user app does its own initialisation,
perhaps settings you have done in bootloader or in run_user_app() function are overwritten.

0 Kudos