Вопрос в дополнение к предыдущему.
Стал тестировать запись - микроконтроллер перезагружается.
Вот мой код:
CODE
WDOG_Enable (false); // Disable of the watchdog.
// For to be on the safe side.
MSC->LOCK = MSC_UNLOCK_CODE; // Unlock of the FLASH writting.
MSC-> WRITECTRL |= MSC_WRITECTRL_WREN; // Set enable of the FLASH writting.
MSC -> ADDRB = USERDATA_BASE; // Set of the FLASH User memory address.
MSC -> WRITECMD = MSC_WRITECMD_LADDRIM; // Write addres to MSC hardware.
MSC -> WRITECMD = MSC_WRITECMD_ERASEPAGE; // Command to erase of the first User FLASH page. !!!
// !!! If I comment of the previous line the microcontroller works, otherwize it rebooted.
// Wait for the FLASH erase process end.
i = 0;
while (((MSC -> STATUS & MSC_STATUS_BUSY) == MSC_STATUS_BUSY) && (i < 100000))
{
i++;
}
...
// Write of the CKS.
MSC -> ADDRB = FLASH_Addr; // Set of the FLASH User memory address.
FLASH_Addr = FLASH_Addr + 4; // Increment of the FLASH Address.
MSC -> WDATA = CKS; // Write of the dara to FLASH write.
MSC -> WRITECMD = MSC_WRITECMD_LADDRIM; // Write addres to hardware.
MSC -> WRITECMD = MSC_WRITECMD_WRITEONCE; // Command to write of the one word.
// !!! If I comment of the previous line the microcontroller works, otherwize it rebooted.
i = 0;
while (((MSC -> STATUS & MSC_STATUS_BUSY) == MSC_STATUS_BUSY) && (i < 100000))
{
i++;
}
MSC-> WRITECTRL &= ~MSC_WRITECTRL_WREN; // Disable of the FLASH writting.
MSC->LOCK = 0x0; // Lock of the FLASH writting.
WDOG_Enable (true); // Enable of the watchdog.
WDOG_Feed(); // Reset of the Watchdog.
Перезагузка происходит при любой попытке изменить FLASH - стереть или записать.
Вчитавшись в User Guide обнаружил маленькую сноску, смысл коиорой - все операции
с FLASH только при коде в RAM.
Собственно сам вопрос - не даст ли кто ссылку или кусочек кода как грамотно
перенести исполняемую функцию в область RAM?