[STM8] stm8 串口中断唤醒

[复制链接]
746|2
 楼主| googcheng 发表于 2019-12-30 09:20 | 显示全部楼层 |阅读模式
本帖最后由 googcheng 于 2019-12-30 10:23 编辑

pc2 临时转外部中断 在调用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);


中断处理函数如下
  1. INTERRUPT_HANDLER(EXTI2_IRQHandler,10)
  2. {
  3.     /* In order to detect unexpected events during development,
  4.        it is recommended to set a breakpoint on the following instruction.
  5.     */
  6.    
  7.     //stop_flag = 1;
  8.     EXTI_ClearITPendingBit(EXTI_IT_Pin2);
  9.    
  10.     //GPIO_Init(GPIOC, GPIO_Pin_2, GPIO_Mode_In_PU_No_IT);
  11.     // 1230 change
  12.     GPIOC->CR2 &= (uint8_t)~GPIO_Pin_2;
  13.    
  14.     //write_usb_flag();
  15.     FLASH_Unlock(FLASH_MemType_Data);
  16.     //FLASH_EraseByte(0x1000);
  17.     //delay_ms(20);

  18.     FLASH_ProgramByte(0x1000, 0x66);
  19.     record_time_f = 1; // to record time
  20.    
  21.     //write_addr
  22.     FLASH_ProgramByte(0x1002, (uint8_t)(write_addr & 0xff));
  23.     FLASH_ProgramByte(0x1003, (write_addr >> 8) & 0xff);

  24.     FLASH_Lock(FLASH_MemType_Data);
  25.    
  26.    
  27. }

mmuuss586 发表于 2019-12-30 09:47 | 显示全部楼层
感谢分享
 楼主| googcheng 发表于 2019-12-30 10:16 | 显示全部楼层

帮我看看这个代码有没有毛病
您需要登录后才可以回帖 登录 | 注册

本版积分规则

32

主题

58

帖子

2

粉丝
快速回复 在线客服 返回列表 返回顶部