KBOOT V2.0 with CANBUS on FRDM-K64F

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

KBOOT V2.0 with CANBUS on FRDM-K64F

跳至解决方案
2,906 次查看
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

标签 (1)
0 项奖励
回复
1 解答
2,311 次查看
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 项奖励
回复
12 回复数
2,310 次查看
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 项奖励
回复
2,311 次查看
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 项奖励
回复
2,311 次查看
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 项奖励
回复
2,311 次查看
a8Chcx
Contributor V

Hi Fan,

Is there any way to disable the pending interrupt?

Thanks,

Christie

0 项奖励
回复
2,312 次查看
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 项奖励
回复
2,311 次查看
ramboyang
NXP Employee
NXP Employee

Hi Christie,

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

Hope it is helpful to your use case.

0 项奖励
回复
2,311 次查看
a8Chcx
Contributor V

Hi Fan,

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

Thanks,

Christie

0 项奖励
回复
2,311 次查看
ramboyang
NXP Employee
NXP Employee

HI Christie,

Please add it to your application instead of bootloader.

Best regards,

Fan

0 项奖励
回复
2,312 次查看
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 项奖励
回复
2,312 次查看
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 项奖励
回复
2,312 次查看
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 项奖励
回复
2,312 次查看
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 项奖励
回复