2018-12-11 08:56 AM
Dear comunity,
I'm having some trouble using the SPI communication protocol between two MCU.
The aim is to transfer data via SPI(2) from MCU to a Murata MLM32L07x01 (based on STM32L072).
In my program, I'm using also UART2 / ADC / RTC / LoRa communication (SPI1) / GPIOs.
When I want to transfer data, I'm using the HAL_SPI_Receive function in the Murata like this :
HAL_SPI_Receive(&hspi2, aRxBuffer, sizeOfSPI, 3000);
If the variable sizeOfSPI is right, I received well the data and my program is following. However, when I don't know the size of SPI transfer (assuming I'm waiting for 80 char and I received only 60), I still receive the transfer char but the Timeout parameter should be used. In the case above, knowing the SPI is in polling mode, it should wait for 3 seconds maximum.
However, my program is going into an infinite loop. When I try to debug the software, I see a weird value from the HAL library :
In the SPI_WaitOnFlagUntilTimeout function, the call of HAL_GetTick returns 0 :
static HAL_StatusTypeDef SPI_WaitOnFlagUntilTimeout(SPI_HandleTypeDef *hspi, uint32_t Flag, FlagStatus Status, uint32_t Timeout)
{
uint32_t tickstart = 0U;
/* Get tick */
tickstart = HAL_GetTick();
There is my definition of SysTick_Handler :
void SysTick_Handler(void)
{
HAL_IncTick();
HAL_SYSTICK_IRQHandler();
}
How can I manage to get work the HAL_GetTick function ?
Solved! Go to Solution.
2018-12-11 10:45 AM
Need to make sure SysTick is enabled, and it has a higher priority than other interrupts and callbacks you might have dependencies in.
2018-12-11 10:45 AM
Need to make sure SysTick is enabled, and it has a higher priority than other interrupts and callbacks you might have dependencies in.
2018-12-12 12:26 AM
Thank you for notice this solution, you were right, the priority was the problem.
I though I fixed this issue before in the code but there are multiple calling of HAL_NVIC_SetPriority and it was a declaration in stm32l0xx_hal_conf.h which cause trouble:
#define TICK_INT_PRIORITY (((uint32_t)1<<__NVIC_PRIO_BITS) - 1) /*!< tick interrupt priority */
I changed it by choosing first priority :
#define TICK_INT_PRIORITY ((uint32_t)0U)
Best regards!