KBOOT V2.0 with CANBUS on FRDM-K64F

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

KBOOT V2.0 with CANBUS on FRDM-K64F

Jump to solution
2,082 Views
a8Chcx
Contributor V

Hi,

 

I ported CANBUS interface to FRDM-K64F board by using KBOOT V2.0. It works fine with LED demo program.

 

Then, I change my project based on Jorge's document and it works fine as well. On my project, I am using CANBUS communication as well. When I send CANBUS packet to board, I found the CANBUS packets are received by boot-loader instead of my project because there is no receive output on my project. But, if I send "ping command", it gets accepted by boot-loader and waiting for boot-loader command.

I am using KDS3.0 with PE to build my project.

Is it possible the vector table is not changed? The CANBUS receive interrupt is in 0x0000_0000~~0x0000_0400?

How can I change interrupt vector to my project vector table?

 

Thanks,

 

Christie

Labels (1)
0 Kudos
1 Solution
1,487 Views
ramboyang
NXP Employee
NXP Employee

Hi Christie,

Maybe you can try to add __disable_irq() before changing SCB->VTOR in Bootloader, and remember to call __enable_irq() in the application to restore global irq.

Thanks,

Fan

View solution in original post

0 Kudos
12 Replies
1,486 Views
a8Chcx
Contributor V

Hi Fan,

I checked that __VECTOR_TABLE is 0x20000 in boot-loader that is the same as I set in application.

But, if I set SCB->VTOR in bootloader before jump, it will cause the problem. Could you tell me why? Is it because the vector table in 0x20000 is not set yet? But, all interrupts are disabled in bootloader? Can it be the other reason?

Thanks,

Christie

0 Kudos
1,487 Views
ramboyang
NXP Employee
NXP Employee

Hi Christie,

Please ensure that the SCB->VTOR is as close to the jump function as possible, and please ensure there are no pending interrupts before updating base address of vector table.

Thanks,

Fan

0 Kudos
1,487 Views
a8Chcx
Contributor V

Hi Fan,

I just put SCB->VTOR before jump. If I added some delay(20ms), it works fine. So, you think that it is possible the pending interrupt causes problem?

If I set the SCB-VTOR after initialization, it works as well. Both options should be fine, right?

Thanks,

Christie

0 Kudos
1,487 Views
a8Chcx
Contributor V

Hi Fan,

Is there any way to disable the pending interrupt?

Thanks,

Christie

0 Kudos
1,488 Views
ramboyang
NXP Employee
NXP Employee

Hi Christie,

Maybe you can try to add __disable_irq() before changing SCB->VTOR in Bootloader, and remember to call __enable_irq() in the application to restore global irq.

Thanks,

Fan

0 Kudos
1,487 Views
ramboyang
NXP Employee
NXP Employee

Hi Christie,

Please try to add SCB->VTOR = VTOR = 0x8000;

Hope it is helpful to your use case.

0 Kudos
1,487 Views
a8Chcx
Contributor V

Hi Fan,

Could you tell me I should add this in boot-loader or my application for CANBUS?

Thanks,

Christie

0 Kudos
1,487 Views
ramboyang
NXP Employee
NXP Employee

HI Christie,

Please add it to your application instead of bootloader.

Best regards,

Fan

0 Kudos
1,488 Views
a8Chcx
Contributor V

Hi Fan,

I checked the boot-loader, SCB->VTOR is set to 0 instead of 0xA000 before it jumps to application, why? I am using freedom_bootloader as my project. Do I am using wrong one?

So, I should set it to 0xA000 in my application?

In my application link file, I already change the address, I still need to set SCB->VTOR = 0xA000?

Regards,

Christie

0 Kudos
1,488 Views
a8Chcx
Contributor V

Hi Fan,

I check the VTOR setting is my project as follows:

if (__VECTOR_RAM != __VECTOR_TABLE)

{

/* Copy the vector table from ROM to RAM */

for (n = 0; n < ((uint32_t)__RAM_VECTOR_TABLE_SIZE)/sizeof(uint32_t); n++)

{

__VECTOR_RAM[n] = __VECTOR_TABLE[n];

}

/* Point the VTOR to the position of vector table */

SCB->VTOR = (uint32_t)__VECTOR_RAM;

}

else

{

/* Point the VTOR to the position of vector table */

SCB->VTOR = (uint32_t)__VECTOR_TABLE;

}

__VECTOR_RAM = 0x1FFF_0000

__VECTOR_TABLE = 0x0002_0000 // because I set the application in 0x0002_0000

__RAM_VECTOR_TABLE_SIZE= 0x0000_0400

Looks like the settings are right?

Regards,

Christie

0 Kudos
1,488 Views
ramboyang
NXP Employee
NXP Employee

Hi Christie,

Please check the linker file, I vaguely remember that the default setting is __VECTOR_RAM equals to __VECTOR_TABLE, so the code you posted doesn’t’ take effect.

Actually, there are two options, you can either use SCB->VTOR= in your application or put this code in bootloader before jumping to the application.

Best Regards,

Fan

0 Kudos
1,488 Views
a8Chcx
Contributor V

Hi Fan,

Looks like that I have to remove "SCB->VTOR = (uint32_t)__VECTOR_TABLE" before it jumps to application.

After I remove it, it works fine because it is set in application like the above...

Thanks,

Christie

0 Kudos