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


Connecting 2 NUCLEO32f411RE with SPI

Hi, I have this configuration on my master Nucleoboard
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_HARD_OUTPUT;
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;
HAL_SPI_Init(&hspi2);
__HAL_SPI_ENABLE(&hspi2);

}

when I receive an ASCII-character from the PC: I send it over to the slave
void USART2_IRQHandler(void)
{

HAL_UART_IRQHandler(&huart2);
HAL_UART_Receive_IT(&huart2,&data1,sizeof(data1));
data1++; //’A’ is echoed back, and transferred to slave as ‘B’

HAL_SPI_Transmit(&hspi2,&data1,(uint16_t)sizeof(data1),HAL_MAX_DELAY);
HAL_UART_Transmit(&huart2,&data1,(uint16_t)sizeof(data1),HAL_MAX_DELAY);
}

-----------------------
On my slave board I have:
void MX_NVIC_Init(void)
{
/* SPI2_IRQn interrupt configuration */
HAL_NVIC_SetPriority(SPI2_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(SPI2_IRQn);
SPI_1LINE_RX(&hspi2);
__HAL_SPI_ENABLE_IT(&hspi2, SPI_IT_RXNE);
__HAL_SPI_ENABLE(&hspi2);

/* USART2_IRQn interrupt configuration */
HAL_NVIC_SetPriority(USART2_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(USART2_IRQn);
__HAL_UART_ENABLE_IT(&huart2,UART_IT_RXNE);
__HAL_UART_HWCONTROL_RTS_ENABLE(&huart2);
}

void MX_SPI2_Init(void)
{

hspi2.Instance = SPI2;
hspi2.Init.Mode = SPI_MODE_SLAVE;
hspi2.Init.Direction = SPI_DIRECTION_2LINES_RXONLY;
hspi2.Init.DataSize = SPI_DATASIZE_8BIT;
hspi2.Init.CLKPolarity = SPI_POLARITY_HIGH;
hspi2.Init.CLKPhase = SPI_PHASE_1EDGE;
hspi2.Init.NSS = SPI_NSS_HARD_INPUT;
hspi2.Init.FirstBit = SPI_FIRSTBIT_MSB;
hspi2.Init.TIMode = SPI_TIMODE_DISABLE;
hspi2.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
hspi2.Init.CRCPolynomial = 10;
HAL_SPI_Init(&hspi2);

}

And my slave interrupt handler looks like this:
void SPI2_IRQHandler(void)
{
HAL_SPI_IRQHandler(&hspi2);
uint8_t data1;
HAL_SPI_Receive_IT(&hspi2,&data1,sizeof(data1));
HAL_UART_Transmit(&huart2,&data1,(uint16_t)sizeof(data1),HAL_MAX_DELAY);
}

Could anybody please tell me, why this doesn’t work?

Kindest regards,
Lasse Karagiannis

What does not work?
Is the ISR not being called?
Is the wrong character being received?
Can you look at the signal from the sending board with a scope to make sure that it is correct?
Are you sure that the BAUD rates on both boards are the same and are correctly set up.
(I’ve not used these boards mysefl but these questions are te ones I often ask when we are not really told enough to be of immediate assistance.)
Susan


Thank’s for your answer Susan, nothing gets transmitted to the slave board, the slave-program enters
a Cube generated snippet which is to get put the execution in an infinite loop for debugging purposes.
The comment to this snippet reads that it is for when the processor experiences an unexpected interrupt.

I can see that the cube has generated this initialization for the master
hspi2.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_32;
but it hasn’t generated anything for the slave, maybe that is a bug in the Cube?

I will add it and see what happens, don’t have an oscilloscope, unfourtuantely.

/Lasse


Tried adding this line:
hspi2.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_32;
in the SPI initialization routine.

The slave gets stuck in startup_stm32f411xe.se routine when an ASCII character is sent from the master. It enters there from within the SPI-interrupt routine, that must mean that it is recognized as an SPI-interrupt, but still not correct?

/**
* @brief This is the code that gets called when the processor receives an
* unexpected interrupt. This simply enters an infinite loop, preserving
* the system state for examination by a debugger.
* @param None
* @retval None

  • /

.section .text.Default_Handler,”ax”,%progbits
Default_Handler:
Infinite_Loop:
b Infinite_Loop