How to write data flash in K40?

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

How to write data flash in K40?

跳至解决方案
2,230 次查看
donden
Contributor II

How do I write data flash when FTFL_FCCOBn only provides 24-bits of address, and data flash is at 0x1000_0000?

I have a bare metal bootloader that needs to access three sectors of data flash, which start at 0x1000_0000.

The K40 reference manual  says that the FTFL_CCOBn registers are used to write to program and data flash.

These registers work fine for program flash, but since FTFL_CCOB0 has 8-bits for the command and only 24-bits

for address, it cannot access data flash properly.

What is the correct method to write to data flash on a bare metal embedded system?

Don dT

标签 (1)
标记 (3)
1 解答
1,785 次查看
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi,

In fact, the 24 bit Flash internal address Flash address bit [23] indicate the program Flash block is program flash block or data flash block. If customer want to program data flash, it just need to add 0x800000 with converted FTFL internal flash address. More detailed info, please check below code:

/* check for valid range of the target addresses */

    if((endAddress >= PSSDConfig->PFlashBlockBase) && \

        (endAddress <= (PSSDConfig->PFlashBlockBase + BYTE2WORD(PSSDConfig->PFlashBlockSize))))

    {

        /* Convert System memory address to FTFx internal memory address */

#if DSC_56800EX == CPU_CORE

     destination = (2*(destination - PSSDConfig->PFlashBlockBase));

#else  

     destination -= PSSDConfig->PFlashBlockBase;

#endif

        sectionAlign = PPGMSEC_ALIGN_SIZE;

    }

    else if((endAddress >= PSSDConfig->DFlashBlockBase) || \

            (endAddress <= (PSSDConfig->DFlashBlockBase + BYTE2WORD(PSSDConfig->DFlashBlockSize))))

    {

        /* Convert System memory address to FTFx internal memory address */

#if DSC_56800EX == CPU_CORE

     destination = (2*(destination - PSSDConfig->DFlashBlockBase)+ 0x800000);

#else  

destination = destination - PSSDConfig->DFlashBlockBase + 0x800000;

#endif

        sectionAlign = DPGMSEC_ALIGN_SIZE;

    } 

    else /* end address does not fall within Pflash or Dflash range */

    {

        /* return an error code FTFx_ERR_RANGE */

        returnCode = FTFx_ERR_RANGE;

        goto EXIT;

    }

Customer could dowload Kinetis Flash driver from below link:

http://cache.freescale.com/files/32bit/software/C90TFS_FLASH_DRIVER.exe
Wish it helps.

在原帖中查看解决方案

5 回复数
1,785 次查看
donden
Contributor II

Thank you!  I knew there must be some little trick to make this work.  This has resolved my problem.  :-)

I didn’t notice this in the documentation.  I was using the K40P144M100SF2RM Reference Manual, mainly.


1,786 次查看
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi,

In fact, the 24 bit Flash internal address Flash address bit [23] indicate the program Flash block is program flash block or data flash block. If customer want to program data flash, it just need to add 0x800000 with converted FTFL internal flash address. More detailed info, please check below code:

/* check for valid range of the target addresses */

    if((endAddress >= PSSDConfig->PFlashBlockBase) && \

        (endAddress <= (PSSDConfig->PFlashBlockBase + BYTE2WORD(PSSDConfig->PFlashBlockSize))))

    {

        /* Convert System memory address to FTFx internal memory address */

#if DSC_56800EX == CPU_CORE

     destination = (2*(destination - PSSDConfig->PFlashBlockBase));

#else  

     destination -= PSSDConfig->PFlashBlockBase;

#endif

        sectionAlign = PPGMSEC_ALIGN_SIZE;

    }

    else if((endAddress >= PSSDConfig->DFlashBlockBase) || \

            (endAddress <= (PSSDConfig->DFlashBlockBase + BYTE2WORD(PSSDConfig->DFlashBlockSize))))

    {

        /* Convert System memory address to FTFx internal memory address */

#if DSC_56800EX == CPU_CORE

     destination = (2*(destination - PSSDConfig->DFlashBlockBase)+ 0x800000);

#else  

destination = destination - PSSDConfig->DFlashBlockBase + 0x800000;

#endif

        sectionAlign = DPGMSEC_ALIGN_SIZE;

    } 

    else /* end address does not fall within Pflash or Dflash range */

    {

        /* return an error code FTFx_ERR_RANGE */

        returnCode = FTFx_ERR_RANGE;

        goto EXIT;

    }

Customer could dowload Kinetis Flash driver from below link:

http://cache.freescale.com/files/32bit/software/C90TFS_FLASH_DRIVER.exe
Wish it helps.

1,785 次查看
dmitriyc
Contributor III

Is there any initiative to put this in documentation, specifically the reference manuals? A year later, I still do not see this anywhere in K60P144M150SF3RM either, which probably means it is not included in the common manual section that keeps getting pasted into many Kinetis reference manuals. Seems a like a pretty important thing to include.

0 项奖励
回复
1,785 次查看
mjbcswitzerland
Specialist V

Hi

I believe that the details have always been there:

pastedImage_1.png

Regards

Mark

Kinetis: µTasker Kinetis support

K60: µTasker Kinetis TWR-K60N512 support  / µTasker Kinetis TWR-K60D100M support  / µTasker Kinetis TWR-K60F120M support

For the complete "out-of-the-box" Kinetis experience and faster time to market

1,785 次查看
dmitriyc
Contributor III

Haha. Got me. Maybe if I had read that chapter three more times I would have noticed that.

pastedImage_5.png

Thanks for pointing that out. You don't have to call a "wambulance" to come pick me up. Yes technically it's there... technically. *sigh*

0 项奖励
回复