Why is priority HAL_DELAY compared to button?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2017-07-20 6:38 AM
Hi,
i've a little problem with stm32L0.I want change state with button B1, but HAL_DELAY is priority of button. the mian is:uint8_t stato; stato = 0;while (1)
{switch(stato)
{ case 0: HAL_GPIO_WritePin(LD2_GPIO_Port, LD2_Pin, GPIO_PIN_SET); HAL_Delay(500); HAL_GPIO_WritePin(LD2_GPIO_Port, LD2_Pin, GPIO_PIN_RESET); HAL_Delay(500); if(HAL_GPIO_ReadPin(B1_GPIO_Port, B1_Pin)==GPIO_PIN_RESET) { stato = 1; } break; case 1: HAL_GPIO_WritePin(LD2_GPIO_Port, LD2_Pin, GPIO_PIN_SET); HAL_Delay(100); HAL_GPIO_WritePin(LD2_GPIO_Port, LD2_Pin, GPIO_PIN_RESET); HAL_Delay(100); if(HAL_GPIO_ReadPin(B1_GPIO_Port, B1_Pin)==GPIO_PIN_RESET) { stato = 0; } break; }}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2017-07-20 1:11 PM
Sorry, don't understand the question.
The HAL_Delay() typically depends on SysTick and the priority assigned to that interrupt, usually needs to be rather high otherwise other code would dead-lock.
HAL_Delay() isn't going to end early because you press the button, your code here is just inserting fixed delays. Don't see any interrupt handlers or setup.
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2017-07-21 3:25 AM
I want change the type of blink of the led with button
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2017-07-21 7:45 AM
Ok, so use a variable, loop the delay while checking the button, so the LED/BUTTON occur in parallel. ie 100 or 500 loops of HAL_Delay(1), and more responsive change based on button
Up vote any posts that you find helpful, it shows what's working..
