做ppt很有创意的网站,网站编辑做多久可以升职,世界工厂网网址,网站可兼容移动端发觉用新版#xff08;V6.9.1#xff09;的它生成代码#xff0c;会有问题。可能是 BUG。具体如下#xff1a;
一个简单的点灯程序#xff0c;用 Keil MDK 5.38a#xff08;compiler version 6#xff09;编译。
如果在变量前#xff0c;不加上关键字“volatile”V6.9.1的它生成代码会有问题。可能是 BUG。具体如下
一个简单的点灯程序用 Keil MDK 5.38acompiler version 6编译。
如果在变量前不加上关键字“volatile”是不会闪灯的。
V6.8.1 也同样但好象如果你的工程是在旧版本中慢慢升一步步上来的不会有事如果是新建的就出问题。
大家可以试试
main.c 中
extern volatile uint32_t u32LedFlashTimeAdd;/* USER CODE END PTD *//* Private define ------------------------------------------------------------*/
/* USER CODE BEGIN PD *//* USER CODE END PD *//* Private macro -------------------------------------------------------------*/
/* USER CODE BEGIN PM *//* USER CODE END PM *//* Private variables ---------------------------------------------------------*//* USER CODE BEGIN PV *//* USER CODE END PV *//* Private function prototypes -----------------------------------------------*/
void SystemClock_Config(void);
/* USER CODE BEGIN PFP *//* USER CODE END PFP *//* Private user code ---------------------------------------------------------*/
/* USER CODE BEGIN 0 *//* USER CODE END 0 *//*** brief The application entry point.* retval int*/
int main(void)
{/* USER CODE BEGIN 1 */u32LedFlashTimeAdd 0;/* USER CODE END 1 *//* MCU Configuration--------------------------------------------------------*//* Reset of all peripherals, Initializes the Flash interface and the Systick. */HAL_Init();/* USER CODE BEGIN Init *//* USER CODE END Init *//* Configure the system clock */SystemClock_Config();/* USER CODE BEGIN SysInit *//* USER CODE END SysInit *//* Initialize all configured peripherals */MX_GPIO_Init();/* USER CODE BEGIN 2 *//* USER CODE END 2 *//* Infinite loop *//* USER CODE BEGIN WHILE */while (1){//HAL_Delay(1);if(u32LedFlashTimeAdd 5000){u32LedFlashTimeAdd 0;HAL_GPIO_TogglePin(Led_Flash_GPIO_Port,Led_Flash_Pin);}/* USER CODE END WHILE *//* USER CODE BEGIN 3 */}/* USER CODE END 3 */
} stm32g0xx_it.c 中
volatile uint32_t u32LedFlashTimeAdd;//...void SysTick_Handler(void)
{/* USER CODE BEGIN SysTick_IRQn 0 */u32LedFlashTimeAdd;/* USER CODE END SysTick_IRQn 0 */HAL_IncTick();/* USER CODE BEGIN SysTick_IRQn 1 *//* USER CODE END SysTick_IRQn 1 */
}