Why does adding a fourth module stops the firmware working as required?
Hello
I'm developing firmware for a STM32F413 on a PCBA. The controller needs to:
- control two ADCs via one SPI,
- control an LCD via another SPI,
- de-bounce a switch using a timer and
- communicate with a UI interface over a UART.
The SPIs and the UART use DMA.
I am able to develop the firmware in the two following ways before an error occurs:
1) Get data from the ADCs, display pages to the LCD and communicate over the UART.
When the de-bounced switch is added, then
a) HAL_SPI_Transmit_DMA(lcd->spiHandle, data, size); does not call the following callback:
HAL_SPI_TxCpltCallback(SPI_HandleTypeDef *hspi) which leaves the firmware in the following loop as the callback should set 'spiTX_cpltFL' to 'true'
// Wait for end of DMA transfer
while(!lcd->spiTX_cpltFL){};The above occurs the first time that data to display a page is sent to the LCD.
2) Get data from the ADCS, de-bounce the switch and communicate over the UART.
When the LCD is added the 'HardFault_Handler' is called:
a) BFARVALID and PRECISERR are set;
b) the value in the programme counter (PC)(MSP) is at 0x08002774 which points to
// ** stm32f4xx_hal_spi.c
// line 830 onwards
if ((hspi->Instance->CR1 & SPI_CR1_SPE) != SPI_CR1_SPE)
{
* Enable SPI peripheral */
__HAL_SPI_ENABLE(hspi);
}
// ** stm32f4xx_hal_spi.h
// line 455
#define __HAL_SPI_ENABLE(__HANDLE__) SET_BIT((__HANDLE__)->Instance->CR1, SPI_CR1_SPE)'__HAL_SPI_ENABLE' is as follows:
// ** stm32f4xx_hal_spi.c
// line 830 onwards
if ((hspi->Instance->CR1 & SPI_CR1_SPE) != SPI_CR1_SPE)
{
* Enable SPI peripheral */
__HAL_SPI_ENABLE(hspi);
}
// ** stm32f4xx_hal_spi.h
// on line 455
#define __HAL_SPI_ENABLE(__HANDLE__) SET_BIT((__HANDLE__)->Instance->CR1, SPI_CR1_SPE)Can anyone suggest what I might be doing wrong to generate these errors, please? The various pieces of code appear to work but not all together, so it appears that I've caused a conflict somewhere.
Regards
Ron
