2014-10-16 09:16 AM
Description:
In the STM8S For IAR Embedded WorkBench
I consulted AN2659 - AIP write the BootLoader, In the STM8S003F3,STM8S903K3 and 005 can be normal operation.
But in the STM8S207K6
First:
The sample program:
/****************************************************************************************/
// When shake hands with PC successfully.
CLK->CKDIVR = 0x00; // CLK Config
FLASH->PUKR = 0x56; // UNLOCK
FLASH->PUKR = 0xAE;
FLASH->DUKR = 0xAE;
FLASH->DUKR = 0x56;
RoutinesInRAM = 1; // Just a Flag
for(unsigned char i = 0;i < 248 ;i++) // Clear Flah for Program my Protect2
{
Write_Flah_Block_Data((0x8400 + 128*i),(unsigned char *)&Receive_Data_Buffer[0],128); //
Dead Here
}
// Mean I can not Program in the ram
// Program In the RAM
void Write_Flah_Block_Data(unsigned short Start_Address,unsigned char *Ptr,unsigned char Length)@''FLASH_CODE''
{
FLASH->CR2 |= 0X01;
FLASH->NCR2 &= (unsigned char)~0X01;
for( unsigned char i = 0; i < Length ;i++)
{
*(( PointerAttr unsigned char*) (unsigned short)Start_Address + i) = *Ptr;
Ptr++;
}
}
/*****************************************************************************************************************/
Second:
The ICF File
://
/////////////////////////////////////////////////////////////////
define memory with size = 16M;
define region TinyData = [from 0x00 to 0xFF];
define region NearData = [from 0x0000 to 0x17FF];
define region Eeprom = [from 0x4000 to 0x43FF];
define region BootROM = [from 0x6000 to 0x67FF];
define region NearFuncCode = [from 0x8000 to 0xFFFF];
define region FarFuncCode = [from 0x8000 to 0xFFFF];
define region HugeFuncCode = [from 0x8000 to 0xFFFF];
/////////////////////////////////////////////////////////////////
define block CSTACK with size = _CSTACK_SIZE {};
define block HEAP with size = _HEAP_SIZE {};
define block INTVEC with size = 0x80 { ro section .intvec };
initialize by copy { rw,
ro section .tiny.rodata,
section FLASH_CODE};
do not initialize { section .vregs };
do not initialize { section .*.noinit };
// Placement
place at start of TinyData { rw section .vregs };
place in TinyData { rw section .tiny.* };
place at end of NearData { block CSTACK };
place in NearData { ro section FLASH_CODE,
block HEAP,
rw }; // includes rw section .near.*
place at start of NearFuncCode { block INTVEC };
place in NearFuncCode { ro section .far.data_init,
ro section .huge.data_init,
ro }; // includes ro section .near_func.*
place in FarFuncCode { ro section .far.*,
ro section .far_func.* };
place in HugeFuncCode { ro section .huge.*,
ro section .huge_func.* };
place in Eeprom { section .eeprom.* };
Severity:
Medium
Due Date:
Product Type:
All
Project Name:
All
Production Forecast:
0
ku
(None)
Production Start Date:
(None)
Application Type:
(None)