2189 views|1 replies

406

Posts

1

Resources
The OP
 

stm32 event interrupt [Copy link]

This post was last edited by Qingchengshanxia on 2018-1-22 18:24 The variable CurrntStatus is the data received from the UART port. Suppose the data received at the 10th second is 0, then the fallt_light function at the bottom of the function will be executed. However, if the data received from the UART serial port is 1 when the fallt_light function is executed at the 11th second, I want to jump out of fallt_light and immediately execute the instructions below CurrntStatus==1. How should I deal with this?
  1. void light_carmaker(){ int i =0 ; if(Flag==1) return; if(CurrntStatus == 2){ ControlYellowLigh(); //Control and send the status of the yellow light} else if(CurrntStatus == 3){ GPIO_ResetBits(GPIOB,GPIO_Pin_7|GPIO_Pin_8); GPIO_SetBits(GPIOB,GPIO_Pin_6);//The north-south green light is on for SN seconds, and the east-west red light is on for SN secondsGPIO_SetBits(GPIOB,GPIO_Pin_5);//PB5 is the status indicator light and the status of the north-south green light is consistentdelay_ms(1000); } else if(CurrntStatus == 1){ GPIO_ResetBits(GPIOB,GPIO_Pin_6);//Turn off the north-south green lights, and turn on the east-west red lightsGPIO_ResetBits(GPIOB,GPIO_Pin_5);//The status indicator LED2 and the north-south green lights are consistent in on and offGPIO_ResetBits(GPIOB,GPIO_Pin_6|GPIO_Pin_7);//Give a high level and turn off the lights in other directionsGPIO_SetBits(GPIOB,GPIO_Pin_8); //The east-west green lights are on for EW seconds, and the north-south red lights are on for EW secondsdelay_ms(1000); } else if(CurrntStatus == 0){ falt_light(); } } void falt_light(){ //PB6 is connected to the north-south green light, the east-west red light, PB7 is connected to the yellow light, PB8 is connected to the north-south red light, the east-west green light, GPIO_ResetBits(GPIOB,GPIO_Pin_7|GPIO_Pin_8);//Give a high level to turn off the lights in other directionsGPIO_ResetBits(GPIOB,GPIO_Pin_5); //First turn off the status indicator snblu1=5; ewblu1=5; path = 0; w = 0; for(i=1;i<=snblu1;i++) { if(Flag==1) return; GPIO_SetBits(GPIOB,GPIO_Pin_6);//The north-south green light is on for SN seconds, and the east-west red light is on for SN secondsGPIO_SetBits(GPIOB,GPIO_Pin_5);//PB5 is the status indicator and the status of the north-south green light is consistentif(Flag==1) return; delay_ms(1000); //Delay 1s } if(Flag==1) return; GPIO_ResetBits(GPIOB,GPIO_Pin_6);//Turn off the north-south green lights, and turn on the east-west red lightsGPIO_ResetBits(GPIOB,GPIO_Pin_5);//The status indicator LED2 is consistent with the north-south green lightsGPIO_ResetBits(GPIOB,GPIO_Pin_7|GPIO_Pin_6);//Give a high level and turn off the lights in other directionsfor(i=1;i<=ewblu1;i++) { if(Flag==1) return; GPIO_SetBits(GPIOB,GPIO_Pin_8); //The east-west green lights are on for EW seconds, and the north-south red lights are on for EW secondsif(Flag==1) return; delay_ms(1000); } GPIO_ResetBits(GPIOB,GPIO_Pin_8);//Turn off the east-west green lights}
复制代码
                                                                           


This post is from stm32/stm8

Latest reply

Make a logical formula and add all the conditions that determine the action, and then execute the function according to the conditions. It is not a good idea to add more and more.  Details Published on 2018-1-22 19:31
 

4005

Posts

0

Resources
2
 
Make a logical formula and add all the conditions that determine the action, and then execute the function according to the conditions. It is not a good idea to add more and more.
This post is from stm32/stm8
 
 

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list