本帖最后由 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);
中断处理函数如下
- 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);
-
-
- }
|