cancel
Showing results for 
Search instead for 
Did you mean: 

Swim protocol

angelo_pa
Associate II
Posted on August 08, 2014 at 13:36

I'm trying to program an stm8s105 using  icp method through the swim interface and using an STM32F4 discovery board as host and a firmware written by me.

I can enable the swim interface of the stm8s and i can read and write eeprom memory and registers, i can also read flash program memory but i can not enable write access to this memory in fact the PUL bit in the FLASH_IAPSR register is always set to 0 even after a successfull writing of FLASH_PUKR register.

Has anyone encountered similar issues?

Any advice or useful information is very welcome
4 REPLIES 4
chen
Associate II
Posted on August 08, 2014 at 17:45

Hi

It is all horrible - truly horrible!

Do you do the 'unlock' with the 'entry' ?

    // unlock FLASH memory (MASS sequence)

    // Write 0x56 then 0xAE in FLASH_PUKR (0x5062)

Do you write 0x10 to FLASH_CR2

0xFE to FLASH_NCR2

to start the sector programming sequence?

angelo_pa
Associate II
Posted on August 08, 2014 at 18:55

Hi,

i am not trying to do block programming, i am trying to do byte programming with the WOTF command as explained in the document PM0051 and i follow all the steps explained at the paragraph 4.6.1 ICP Methods - First method but i am able only to unlock the eeprom memory

chen
Associate II
Posted on August 11, 2014 at 12:29

OK OK - I did say the whole thing is horrible.

All I can do is tell you what I do for the SWIM entry sequence:

Set STM8 reset

SWIM entry ( 4 long pulses, 4 short pulses)

delay 6ms

Send SWIM Comms reset (128 x HSI)

delay 3 ms

write 0xA0 into SWIM_CSR

delay 3 ms

clear STM8 reset

delay 7ms

stall the STM8 - set stall bit in DM_CSR2

delay 7ms

write 0xA4 to SWIM_CSR

delay 7ms

unlock FLASH memory (MASS sequence) Write 0x56 in FLASH_PUKR (0x5062)

then 0xAE in FLASH_PUKR (0x5062)

This works for me (but is not what the ST-Link does)

Also, because the programming sequence for the other devices in my system, my code will do a block erase before the programming.

angelo_pa
Associate II
Posted on August 21, 2014 at 12:18

Sorry for the delay in answering but I had problems with the ADSL service, I tried to program  another STM8 of the same type and this time I could  write also the flash program memory, both with the code that I used and  also with the changes that you suggested to me, so I concluded that the first STM8 was defective.

However, in two weeks I should receive an st-link and using that i will verify if the first stm8 is faulty or not.

Regards