Loading...
 

SW4STM32 and SW4Linux fully supports the STM32MP1 asymmetric multicore Cortex/A7+M4 MPUs

   With System Workbench for Linux, Embedded Linux on the STM32MP1 family of MPUs from ST was never as simple to build and maintain, even for newcomers in the Linux world. And, if you install System Workbench for Linux in System Workbench for STM32 you can seamlessly develop and debug asymmetric applications running partly on Linux, partly on the Cortex-M4.
You can get more information from the ac6-tools website and download (registration required) various documents highlighting:

System Workbench for STM32


TXE flag isn't cleared after a SPI send

STM32F411 nucleo board is connected to AMT203 encoder via level-shifte (5V->3.3V).
I have a logic analyzer and TotalPhase Beagle connected to the level-shifter in addition to the encoder on the 3.3V side. The Beagle show no legitimate SPI transactions and the logic analyzer doesn’t pick up any SCK either since data isn’t going out of MOSI, I believe. I have checked and re-checked several times that all necessary clocks are turned on and to be absolutely sure USART isn’t messing with my SPI config, I commented all of that out. I still doubt the configuration.

Please let me know if anyone has ideas that I could try out! Thanks!
------
Current config is given below —
SPI (SPI2) init has been made as follows:

Set up Slave Sel (SS) GPIO pins as follows after enabling GPIOB:

__HAL_RCC_GPIOB_CLK_ENABLE();

/*Configure GPIO pin : SPI2_SS1_Pin */
GPIO_InitStruct.Pin = SPI2_SS1_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_PULLUP;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM;
HAL_GPIO_Init(SPI2_SS1_GPIO_Port, &GPIO_InitStruct);

/*Configure GPIO pin : SPI2_SS2_Pin */
GPIO_InitStruct.Pin = SPI2_SS2_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(SPI2_SS2_GPIO_Port, &GPIO_InitStruct);


Setup GPIO-pins - MOSI, MISO, SCK - using following function:
void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi)
{

GPIO_InitTypeDef GPIO_InitStruct;
if(hspi->Instance==SPI2)
{
/* USER CODE BEGIN SPI2_MspInit 0 */

/* USER CODE END SPI2_MspInit 0 */
/* Peripheral clock enable */
__HAL_RCC_SPI2_CLK_ENABLE();

/**SPI2 GPIO Configuration
PC2 --> SPI2_MISO
PC3 --> SPI2_MOSI
PB10 --> SPI2_SCK
*/
GPIO_InitStruct.Pin = GPIO_PIN_2|GPIO_PIN_3;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_PULLUP; //tried pulldown too
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
GPIO_InitStruct.Alternate = GPIO_AF5_SPI2;
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);

GPIO_InitStruct.Pin = GPIO_PIN_10;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_PULLUP; // tried pulldown too
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
GPIO_InitStruct.Alternate = GPIO_AF5_SPI2;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
}


/* SPI2 init function */
static void MX_SPI2_Init(void)
{
hspi2.Instance = SPI2;
hspi2.Init.Mode = SPI_MODE_MASTER;
hspi2.Init.Direction = SPI_DIRECTION_2LINES;
hspi2.Init.DataSize = SPI_DATASIZE_8BIT;
hspi2.Init.CLKPolarity = SPI_POLARITY_HIGH;
hspi2.Init.CLKPhase = SPI_PHASE_1EDGE;
hspi2.Init.NSS = SPI_NSS_SOFT;
hspi2.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_32;
hspi2.Init.FirstBit = SPI_FIRSTBIT_MSB;
hspi2.Init.TIMode = SPI_TIMODE_DISABLE;
hspi2.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
hspi2.Init.CRCPolynomial = 10;
if (HAL_SPI_Init(&hspi2) != HAL_OK)
{
Error_Handler();
}
}

Can anyone help? I added some more debug into hardfault_handler() and found I hit a Bus fault.
TXE (TX empty) is a hardware control register and will always be set as long as you are not transmitting. If you finished sending stuff and have nothing else to send you should disable the interrupt TXIE (TX interrupt enable bit (I think it’s in CR1 register).