Skip to main content
Visitor II
March 27, 2009
Question

Set FLASH_INTM after first Flash-Op

  • March 27, 2009
  • 2 replies
  • 785 views
Posted on March 27, 2009 at 10:17

Set FLASH_INTM after first Flash-Op

    This topic has been closed for replies.

    2 replies

    netzAuthor
    Visitor II
    March 26, 2009
    Posted on March 26, 2009 at 05:02

    Hello,

    I try to initialize my Flash.

    I've learned to do this from RAM.

    But after this, it should be possible to

    set INTM in FLASH->CR0?!

    The following code prints:

    count = 4

    thus I have to write 4x the Register CR0. Why?

    Thanks,

    Steffen

    Code:

    FLASH_SectorErase(FLASH_B1);

    int c=0;

    while( !(FLASHR->CR0 & FLASH_INTM_Mask) ) {

    FLASHR->CR0 |= FLASH_INTM_Mask;

    c++;

    }

    printf(''count=%dn'',c);

    ...

    __ramfunc void FLASH_SectorErase(u32 Xsectors)

    {

    FLASH_WaitForLastTask();

    FLASHR->CR0 |= FLASH_SER_Mask;

    FLASHR->CR1 |= (Xsectors & 0x000300FF);

    FLASHR->CR0 |= FLASH_WMS_Mask;

    if ( !(FLASHR->CR0 & FLASH_INTM_Mask) ){

    FLASH_WaitForLastTask(); // Does'nt work with ISR !??

    }

    __ramfunc void FLASH_WaitForLastTask(void)

    {

    while (FLASHR->CR0&(FLASH_LOCK | FLASH_BSYA0 | FLASH_BSYA1)){

    }

    }

    netzAuthor
    Visitor II
    March 27, 2009
    Posted on March 27, 2009 at 10:17

    Hello,

    the problem is solved.

    In the flash.h the FLASH_LOCK, FLASH_BSYAx are numeric, not bits.

    Therefore I've tested the wrong bits in CR0.:-[

    Greetings,

    Steffen