gptStartOneShot 'fails' with interval of 1 Topic is solved

Report here problems in any of ChibiOS components. This forum is NOT for support.
crthorne
Posts: 2
Joined: Fri Oct 07, 2016 5:33 pm

gptStartOneShot 'fails' with interval of 1

Postby crthorne » Mon Mar 27, 2017 9:40 pm

On Chibios 16.1.5, HAL for STM32. If I call gptStatOneShot with an interval value of 1 I 'never' get the timeout event.
Using GPT5 on STM32F4xx.

Tracking down the calls, I get to this function in os/hal/ports/STM32/LLD/TIMv1/gpt_lld.c:

void gpt_lld_start_timer(GPTDriver *gptp, gptcnt_t interval) {

gptp->tim->ARR = (uint32_t)(interval - 1); /* Time constant. */
gptp->tim->EGR = STM32_TIM_EGR_UG; /* Update event. */
gptp->tim->CNT = 0; /* Reset counter. */

/* NOTE: After generating the UG event it takes several clock cycles before
SR bit 0 goes to 1. This is because the clearing of CNT has been inserted
before the clearing of SR, to give it some time.*/
gptp->tim->SR = 0; /* Clear pending IRQs. */
if (NULL != gptp->config->callback)
gptp->tim->DIER |= STM32_TIM_DIER_UIE; /* Update Event IRQ enabled.*/
gptp->tim->CR1 = STM32_TIM_CR1_URS | STM32_TIM_CR1_CEN;
}

Setting the APR with (interval - 1) will set it to 0 and the down counter will have to go through an entire 32-bit count before it rolls to zero and triggers the event. This of course is a very long time, so effectively the timeout never happens. I do not think the (interval-1) should be used, I think it should just be (interval) and perhaps there should be a check for an interval value of 0.

User avatar
Giovanni
Site Admin
Posts: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

Re: gptStartOneShot 'fails' with interval of 1

Postby Giovanni » Mon May 29, 2017 10:45 am

bump

User avatar
RoccoMarco
Posts: 655
Joined: Wed Apr 24, 2013 4:11 pm
Location: Munich (Germany)
Has thanked: 83 times
Been thanked: 67 times
Contact:

Re: gptStartOneShot 'fails' with interval of 1  Topic is solved

Postby RoccoMarco » Mon May 29, 2017 8:44 pm

Fixed as Bug 843
Ciao,
RM


Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 20 guests