Skip to main content
Associate
December 15, 2023
Question

Problem with OpenAmp_ping pong

  • December 15, 2023
  • 3 replies
  • 1530 views

Dear Support team,

 

I am using this STM32H755 as a motor control application. 

I have developed motor control algorithm on M4 and the communication with Master through SPI using M7.

I need to exchange data between M4 and M7 continuously. I tried with OpenAmp_PingPong example. It works fine but it works just one time at the beginning of the program or depends on this while loop

while (message < 100)
{
message = receive_message();
message++;
status = OPENAMP_send(&rp_endpoint, &message, sizeof(message));
if (status < 0)
{
Error_Handler();
}
}
I need the send and receive are done continuously. For example I would like to have some thing like this
 

void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim) {

if (htim->Instance == TIM17) {

 

HAL_HSEM_FastTake(HSEM_ID_0);//Take HSEM

 

status = OPENAMP_send(&rp_endpoint, &message, sizeof(message));

//message++;

if (status < 0)

{

Error_Handler();

}

HAL_HSEM_Release(HSEM_ID_0, 0);//Release HSEM in order to notify the CPU2(CM4)

 

// Handle Timer 1 period elapsed event

// This code will execute when the period of Timer 1 elapses

}

}

In which the data is being sent in a timer or in an infinite loop.

I tried a lot with this but I could not. because both cores stopped working when I am doing this.

I also put the receive the receive message function on M4 side in this interrupt:

 

 

void HAL_HSEM_FreeCallback(uint32_t SemMask)

{

 

/* USER CODE BEGIN HSEM_FREE_CALLBACK */

 

 

receive_message();

 

 

 

/* USER CODE END HSEM_FREE_CALLBACK */

 

/* Prevent unused argument(s) compilation warning */

UNUSED(SemMask);

msg_received = RX_NEW_MSG;

 

#ifdef CORE_CM7

 

/* USER CODE BEGIN PRE_HSEM_FREE_CALLBACK_CM7 */

 

/* USER CODE END PRE_HSEM_FREE_CALLBACK_CM7 */

 

HAL_HSEM_ActivateNotification(__HAL_HSEM_SEMID_TO_MASK(HSEM_ID_1));

 

/* USER CODE BEGIN POST_HSEM_FREE_CALLBACK_CM7 */

 

/* USER CODE END POST_HSEM_FREE_CALLBACK_CM7 */

 

#endif

#ifdef CORE_CM4

 

/* USER CODE BEGIN PRE_HSEM_FREE_CALLBACK_CM4 */

 

/* USER CODE END PRE_HSEM_FREE_CALLBACK_CM4 */

 

HAL_HSEM_ActivateNotification(__HAL_HSEM_SEMID_TO_MASK(HSEM_ID_0));

 

/* USER CODE BEGIN POST_HSEM_FREE_CALLBACK_CM4 */

 

/* USER CODE END POST_HSEM_FREE_CALLBACK_CM4 */

#endif

}

 

I should clarify that I do not want to use FreeRTOS. Would it be possible to help me?

 

Best regards,

 

Hamidreza

3 replies

Technical Moderator
December 20, 2023

Hello @HamidGolbari 

I don't think this is the best approach to manage mailbox with IPCC peripheral using HAL_HSEM_FastTake and Release. You better use HAL_HSEM_FreeCallback or is_rpmsg_ept_ready.

The RPMsg service is implemented by the OpenAMP library. The Mailbox service is implemented by the HAL_IPCC driver. Pay attention to timings while debugging dual core. 

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.Best regards,FBL
Associate
January 15, 2024

@FBL Thank you so much for your consideration. Would it be possible if you could provide me with a simple example in which data is being sent and received between two cores continuously?

Thanks again.

Associate
January 19, 2024

I tested this library and it is functional.

https://github.com/adailtonjn68/STM32H7xx_inter-core_data_share