cancel
Showing results for 
Search instead for 
Did you mean: 

usart wakeup from halt

David.Cheng
Associate II

stm8L152 PC2 is USART rx,

1 rx to exit before halt()

USART_DeInit(USART1);
GPIO_Init(GPIOC, GPIO_Pin_3, GPIO_Mode_Out_PP_Low_Slow);
GPIO_Init(GPIOC, GPIO_Pin_2, GPIO_Mode_In_PU_IT);
RX_EXTI_setup();
EXTI_ClearITPendingBit(EXTI_IT_Pin2);

2, pc2 exit handler

INTERRUPT_HANDLER(EXTI2_IRQHandler,10)
{
    /* In order to detect unexpected events during development,
       it is recommended to set a breakpoint on the following instruction.
    */
    
    //stop_flag = 1;
    EXTI_ClearITPendingBit(EXTI_IT_Pin2);
    
    //GPIO_Init(GPIOC, GPIO_Pin_2, GPIO_Mode_In_PU_No_IT);
    // 1230 change
    GPIOC->CR2 &= (uint8_t)~GPIO_Pin_2;
    
    //write_usb_flag();
    FLASH_Unlock(FLASH_MemType_Data);
    //FLASH_EraseByte(0x1000);
    //delay_ms(20);
 
    FLASH_ProgramByte(0x1000, 0x66);
    record_time_f = 1; // to record time
    
    //write_addr
    FLASH_ProgramByte(0x1002, (uint8_t)(write_addr & 0xff));
    FLASH_ProgramByte(0x1003, (write_addr >> 8) & 0xff);
 
    FLASH_Lock(FLASH_MemType_Data);
    
    
}

could you help me review the code?

it works, but i want to know if here have some bug?

0 REPLIES 0