cancel
Showing results for 
Search instead for 
Did you mean: 

STM8S001J3 in halt mode: SWIM PROG error in IAR EWB. Is it possible to restore MCU programmability?

bvn123
Associate II

Hi,

Is it possible to restore STM8S001 for programming after set it to HALT mode?

I try to use halt mode for STM8S001 and STM8S003.

The programmer worked, when I used

__wait_for_interrupt();

but stopped after replacing this procedure to

__halt();

After set STM8S001 to halt mode I can't reprogram this MCU,

IAR EWB for STM8 shows the error:

'Failed to set configuration with MCU name STM8S001J3: SWIM PROG error [4]: Memory write error'

Now I try to test halt mode for STM8S003, but I added a cycle about 6-7s for SWIM PROG may start to work. As I see, SWIM PROG really works, when I start it during 6s after Power On, but doesn't start to work after this time.

Here is a program, which I loaded to STM8S001:

#include <intrinsics.h>
#include <iostm8s001j3.h>
 
#pragma vector = EXTI3_vector
__interrupt void PD_IRQhndl(void)
{
  PB_ODR_ODR4 = !PB_ODR_ODR4;    // Toggle Port D, pin 3, STM8S001/cont.6
}
 
void main()
{
   __disable_interrupt();
   PB_ODR_ODR4 = 0; 
   PB_DDR_DDR4 = 1;
   PB_CR1_C14 = 1; 
   PB_CR2_C24 = 1; 
 
   for(unsigned long i=0;i<400000;i++){}; 
  //I placed this cycle to provide about 6s for SWIM PROG for STM8S003
  //There was not this cycle for STM8S001
 
  PB_ODR_ODR4 =1; //<LED & R=1k> may be connected between PB4 & +3V3 to indicate the end of 6s cycle
 
  PD_ODR_ODR6 = 1; 
  PD_DDR_DDR6 = 0;
  PD_CR1_C16 = 1; 
  PD_CR2_C26 = 1; 
  EXTI_CR1_PDIS = 2; 
  EXTI_CR2_TLIS = 0; 
  __enable_interrupt();
 
  while (1)
 {
   //__wait_for_interrupt();
   __halt();
  }
}

1 REPLY 1
bvn123
Associate II

I've restored the programmability of STM8S001J3, which have been going to HALT mode practically after Power On.