Problem with Erase Flash Sector on Kinetis KL25 Freedom board

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Problem with Erase Flash Sector on Kinetis KL25 Freedom board

ソリューションへジャンプ
1,822件の閲覧回数
mikethomas
Contributor II

Hello All,

I am in the process of evaluating the Freedom board with the Kinetis KL25 MCU.

Basically, writing a small program that interacts with the serial port to test peripherals, and become familiar with CodeWarrior and the Kinetis MCU.

Up to now, everything has worked as expected.

I am now getting hung up on the flash programming and erasing.

To test the ability to erase a flash sector, and reprogram a long word, I have used code snippets from application note AN2295, specifically the Flash Driver code comprised of three modules; flash_kinetis.c, flash_kinetis.h and flash_kinetisRamFunc.c

My test program calls functions in these modules to; initialize the ram code, erase a sector, and program a long word (not using the other flash functions)

After initializing the ram code, and assuming the 1st long word in the sector is already erased (0xffffffff), I can perform a long word program using FLASH_ProgramLongWord(LWord destination, LWord data32b) which works correctly. A query of the long word flash location shows it was programmed as expected. However, if I call the sector erase function; FLASH_EraseSector(LWord destination), the sector is erased, but its as though the stack gets screwed up, because the program resets and starts from the begining. The Hard Fault exception is being handled, so I know a Hard Fault is not occurring.

If I load the PE Micro SDA debugger into the Freedom board, invoke the Eclipse debugger and step through the code, the reset does not occur after erasing the sector, however, if I run the program in the debugger without stepping through it (at full speed) , it again resets.

Any help would be greatly appreciated,

Mike

ラベル(2)
1 解決策
639件の閲覧回数
mikethomas
Contributor II

Problem solved - needed to disable interrupts during the relatively lengthy erase function.

Surprised that the flash driver in the AN2295 source code does not do this.

元の投稿で解決策を見る

2 返答(返信)
639件の閲覧回数
mikethomas
Contributor II

After further investigation , is has become clear that the reset is caused by a "Core Lockup" condition.

(Bit 1 in the RCM_SRS1 register is set.)

This problem sounds very much like the post entitled "K20 Reset bit Lockup set after sector erase", but I am not sure I understand the response.

0 件の賞賛
640件の閲覧回数
mikethomas
Contributor II

Problem solved - needed to disable interrupts during the relatively lengthy erase function.

Surprised that the flash driver in the AN2295 source code does not do this.