Internal Flash read/write operation in km34

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

Internal Flash read/write operation in km34

1,102 次查看
RajPadmani
Contributor II

Hello everyone,

 

I am working on the km34, i wants to read/write in the internal flash of the km34. but my problem is when i am write on the flash while interrupt of ADC and timer it reset or generate the hardfault error. so i change the vector table into the ram and assign the address of the new vector table location to the VTOR, still i am not able write on the internal flash of the km34, still it continuous reset the code.

thank you 

0 项奖励
回复
3 回复数

1,079 次查看
Joey_z
NXP Employee
NXP Employee

hi,RajPadmani

Thank you for your interest in NXP Semiconductor products and the opportunity to serve you, I will gladly help you with this.

Interrupts are not allowed during Flash read and write operations. Ensure that all unnecessary interrupts are disabled before performing flash read and write operations. If you have already moved the vector table to RAM and are still encountering issues, try checking whether the NVIC's VTOR register is correctly set and ensure that the RAM region is initialized and available.

BR

Xu Zhang

0 项奖励
回复

1,051 次查看
RajPadmani
Contributor II
Thank you for your reply,

I create a partition into ram for Vector table and isr handler for adc and timer like

ram_isr (NOLOAD) :
{
KEEP(*(.Vector_ram))
KEEP(*(.ISR_ram))
KEEP(*(ADC_ISR))
} > SRAM_8

Declare them like
__attribute__((section(".ISR_ram"))) void Custom_ADC16_IRQ_HANDLER_FUNC(void)
{
g_Adc16ConversionDoneFlag = true;
/* Read conversion result to clear the conversion completed flag. */
g_Adc16ConversionValue = ADC16_GetChannelConversionValue(DEMO_ADC16_BASE, DEMO_ADC16_CHANNEL_GROUP);
ADC16_SetChannelConfig(DEMO_ADC16_BASE, DEMO_ADC16_CHANNEL_GROUP, &adc16ChannelConfigStruct);
g_Adc16InterruptCounter++;
SDK_ISR_EXIT_BARRIER;
}

__attribute__((section(".ISR_ram"))) void Custom_TMR1_IRQHandler(void)
{
/* Clear interrupt flag.*/
QTMR_ClearStatusFlags(TMR1, kQTMR_CompareFlag);
tmr_count++;
// PRINTF("\r\n Timer interrupt has occurred !");
// qtmrIsrFlag = true;
SDK_ISR_EXIT_BARRIER;
}

for vector table
unsigned int __attribute__((section(".Vector_ram"))) g_vectorTable[49];
__disable_irq();
DisableGlobalIRQ();
memcpy(g_vectorTable, (unsigned int *)SCB->VTOR, sizeof(uint32_t) * 48);
SCB->VTOR = &g_vectorTable;
__enable_irq();


the main thing for my project is i don't want to disable the interrupt while flash operation i need them. and i also move the isr handler into ram but still not write/read on particular address of the ram. please provide any suggestion or solutiond.

Thank you
0 项奖励
回复

1,016 次查看
Joey_z
NXP Employee
NXP Employee

Hi,RajPadmani

You mentioned that you do not want to disable interrupts during Flash operations. If the interrupt vector table is in the same block as the flash area you want to write to, you can't enter the interrupt while reading or writing flash. Make sure the interrupt vector table is not in the same block as the flash area you are writing to.
In addition, sometimes in order not to affect the erase flash, you can put the interrupt vector table in RAM, but the interrupt vector table and the interrupt service program must be placed in RAM, and the VTOR reg must be modified. If you use SRAM_8 in your application, check that your linker script defines the SRAM_8 region correctly and that it is not used by other parts.

BR

Xu Zhang

0 项奖励
回复