Пытаюсь писать по алгоритму Program memory Half Page Write.
Что-то происходит не так:
1) на запись 0x10000 байт уходит 54с, то есть 100мс на половинку страницы, хотя по документации должно 4мс
2) бит PROG вообще не получается выставить.
Подскажите, что я делаю не так ? Заранее спасибо !
Program memory Half Page Write
This operation is used to write half a page to the program memory (32 words). To do so:
• Unlock the FLASH_PECR register
• Unlock the program memory
• Set the FPRG bit in the FLASH_PECR register (this configures FLASH_PECR to
perform a data buffer loading sequence)
• Set the PROG bit in the FLASH_PECR register to access the required program
memory page
• Wait for the BSY bit to be cleared
• Directly write half a page with 32 different words to the program memory address
space. The words must be written sequentially starting from word 0 and ending with
word 31
Код
int i=0, j=0;
unsigned int *p_data_to_save_32=(unsigned int*)0x08010000;
unsigned int write_address= 0x08020000;
unsigned int data_size_32 = 0x10000/4;
unsigned int *p_flash_32;
//память предварительно разблокирована и стёрта
FLASH->PECR |= FLASH_PECR_FPRG; //включаем режим записи 1/2 страницы
FLASH->PECR &=~ FLASH_PECR_FTDW; //отключаем предварительное стирание
//если выставляю этот бит, всё виснет !!!!!!
//FLASH->PECR |= FLASH_PECR_PROG; //работаем с Program Memory
while((FLASH->SR & FLASH_SR_BSY)!=0) {}
p_flash_32=(unsigned int*)write_address;
i=0;
while(i<data_size_32)
{
for(j=0;j<32; j++) //записываем половину страницы
{
*( p_flash_32+i ) =p_data_to_save_32[i];
i++;
}
while((FLASH->SR & FLASH_SR_BSY)!=0) {}
}
}