2025-03-12 10:21 AM
Hi folks,
I have started a very basic PSSI project with CubeMX with the STM32H533R. I send 10 bytes of data to the PSSI in 8 bit mode without any additional control lines (RDY and DE switched off). In the beginning I thought everything works well. I have reached the HAL_PSSI_TxCpltCallback() function, indicating that the whole buffer was send out. I also placed a debug pin before calling the dma transmitt function and clear it in the HAL_PSSI_TxCpltCallback() to measure the transmit delay and the tx time by varying the data length to be send from 10byte to 20byte, and I can see the difference in time on the debig pin with an oscilloscope.
BUT the only problem I have is that there is absolut no data output on any of the 8 GPIOs. Everything seems to be correct (clock, alternate pin function, drive level,...)
Can anybode see a problem in my code:
void HAL_PSSI_TxCpltCallback(PSSI_HandleTypeDef *hpssi)
{
HAL_GPIO_WritePin(GPIOC, GPIO_PIN_4, GPIO_PIN_SET);
PSSI_TransmitComplete_count++;
}
void HAL_PSSI_ErrorCallback(PSSI_HandleTypeDef *hpssi)
{
__NOP();
}
/* Private user code ---------------------------------------------------------*/
void HighPrio_ControlLoop(void)
{
/* USER CODE BEGIN ControlLoop */
/* Infinite loop */
for(;;)
{
/* Start transmitting the received & modified data */
HAL_GPIO_WritePin(GPIOC, GPIO_PIN_4, GPIO_PIN_RESET);
if (HAL_PSSI_Transmit_DMA(&hpssi, (uint32_t*)aTxBuffer, sizeof(aTxBuffer)) != HAL_OK)
{
__NOP();
}
while (PSSI_TransmitComplete_count != 1);
PSSI_TransmitComplete_count = 0;
HAL_Delay(1);
}
}
Here is the Init and the MSP code:
void HAL_PSSI_MspInit(PSSI_HandleTypeDef* hpssi)
{
GPIO_InitTypeDef GPIO_InitStruct = {0};
if(hpssi->Instance==PSSI)
{
/* USER CODE BEGIN PSSI_MspInit 0 */
/* USER CODE END PSSI_MspInit 0 */
/* Peripheral clock enable */
__HAL_RCC_DCMI_PSSI_CLK_ENABLE();
__HAL_RCC_GPIOA_CLK_ENABLE();
__HAL_RCC_GPIOB_CLK_ENABLE();
__HAL_RCC_GPIOC_CLK_ENABLE();
/**PSSI GPIO Configuration
PA4 ------> PSSI_DE
PA6 ------> PSSI_PDCK
PB15 ------> PSSI_D2
PC6 ------> PSSI_D0
PC7 ------> PSSI_D1
PC9 ------> PSSI_D3
PC11 ------> PSSI_D4
PB4(NJTRST) ------> PSSI_D7
PB6 ------> PSSI_D5
PB7 ------> PSSI_RDY
PB8 ------> PSSI_D6
*/
GPIO_InitStruct.Pin = GPIO_PIN_4|GPIO_PIN_6;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
GPIO_InitStruct.Alternate = GPIO_AF13_PSSI;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
GPIO_InitStruct.Pin = GPIO_PIN_15|GPIO_PIN_4|GPIO_PIN_6|GPIO_PIN_7
|GPIO_PIN_8;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
GPIO_InitStruct.Alternate = GPIO_AF13_PSSI;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
GPIO_InitStruct.Pin = GPIO_PIN_6|GPIO_PIN_11;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
GPIO_InitStruct.Alternate = GPIO_AF13_PSSI;
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
GPIO_InitStruct.Pin = GPIO_PIN_7|GPIO_PIN_9;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
GPIO_InitStruct.Alternate = GPIO_AF13_PSSI;
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
/* PSSI DMA Init */
/* GPDMA1_REQUEST_DCMI Init */
handle_GPDMA1_Channel0.Instance = GPDMA1_Channel0;
handle_GPDMA1_Channel0.Init.Request = GPDMA1_REQUEST_DCMI;
handle_GPDMA1_Channel0.Init.BlkHWRequest = DMA_BREQ_SINGLE_BURST;
handle_GPDMA1_Channel0.Init.Direction = DMA_PERIPH_TO_MEMORY;
handle_GPDMA1_Channel0.Init.SrcInc = DMA_SINC_FIXED;
handle_GPDMA1_Channel0.Init.DestInc = DMA_DINC_FIXED;
handle_GPDMA1_Channel0.Init.SrcDataWidth = DMA_SRC_DATAWIDTH_BYTE;
handle_GPDMA1_Channel0.Init.DestDataWidth = DMA_DEST_DATAWIDTH_BYTE;
handle_GPDMA1_Channel0.Init.Priority = DMA_LOW_PRIORITY_LOW_WEIGHT;
handle_GPDMA1_Channel0.Init.SrcBurstLength = 1;
handle_GPDMA1_Channel0.Init.DestBurstLength = 1;
handle_GPDMA1_Channel0.Init.TransferAllocatedPort = DMA_SRC_ALLOCATED_PORT0|DMA_DEST_ALLOCATED_PORT0;
handle_GPDMA1_Channel0.Init.TransferEventMode = DMA_TCEM_BLOCK_TRANSFER;
handle_GPDMA1_Channel0.Init.Mode = DMA_NORMAL;
if (HAL_DMA_Init(&handle_GPDMA1_Channel0) != HAL_OK)
{
Error_Handler();
}
__HAL_LINKDMA(hpssi, hdmatx, handle_GPDMA1_Channel0);
if (HAL_DMA_ConfigChannelAttributes(&handle_GPDMA1_Channel0, DMA_CHANNEL_NPRIV) != HAL_OK)
{
Error_Handler();
}
/* PSSI interrupt Init */
HAL_NVIC_SetPriority(DCMI_PSSI_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(DCMI_PSSI_IRQn);
/* USER CODE BEGIN PSSI_MspInit 1 */
/* USER CODE END PSSI_MspInit 1 */
}
static void MX_GPIO_Init(void)
{
GPIO_InitTypeDef GPIO_InitStruct = {0};
/* USER CODE BEGIN MX_GPIO_Init_1 */
/* USER CODE END MX_GPIO_Init_1 */
/* GPIO Ports Clock Enable */
__HAL_RCC_GPIOA_CLK_ENABLE();
__HAL_RCC_GPIOC_CLK_ENABLE();
__HAL_RCC_GPIOB_CLK_ENABLE();
/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(GPIOC, GPIO_PIN_4, GPIO_PIN_RESET);
/*Configure GPIO pin : PC4 */
GPIO_InitStruct.Pin = GPIO_PIN_4;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
/* USER CODE BEGIN MX_GPIO_Init_2 */
/* USER CODE END MX_GPIO_Init_2 */
}
static void MX_GPDMA1_Init(void)
{
/* USER CODE BEGIN GPDMA1_Init 0 */
/* USER CODE END GPDMA1_Init 0 */
/* Peripheral clock enable */
__HAL_RCC_GPDMA1_CLK_ENABLE();
/* GPDMA1 interrupt Init */
HAL_NVIC_SetPriority(GPDMA1_Channel0_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(GPDMA1_Channel0_IRQn);
/* USER CODE BEGIN GPDMA1_Init 1 */
/* USER CODE END GPDMA1_Init 1 */
/* USER CODE BEGIN GPDMA1_Init 2 */
/* USER CODE END GPDMA1_Init 2 */
}
the main() is very straignt forward:
int main(void)
{
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
/* MCU Configuration--------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* USER CODE BEGIN Init */
/* USER CODE END Init */
/* Configure the system clock */
SystemClock_Config();
/* USER CODE BEGIN SysInit */
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_GPDMA1_Init();
MX_ICACHE_Init();
MX_PSSI_Init();
/* USER CODE BEGIN 2 */
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
HighPrio_ControlLoop();
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */
}
Thank you for any advice on that!
Bets regards, Benedikt
2025-03-13 1:11 AM - edited 2025-03-13 1:12 AM
Hello @berait;
Please make sure that the AHB clock frequency must be at least 2.5 times higher than the PSSI_PDCK frequency.
At frequency ratios lower than 2.5, data might be corrupted or lost during transfers.
What is PSSI_PDCK's clock source?
Are you able to transmit data without DMA?
I advise to look at PSSI_Transmit_DMA may can help you.
Thank you.
Kaouthar
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.
2025-03-13 1:39 AM
Hi Kaouthar,
thank you for your hint! My understanding is, the PSSI_PDCK in my basic application is not crucial, because I only transmit data as a master. The clock in that case is even not connected to any slave device, I just want to see the data comming out of the GPIO (with PSSI_DE and PSSI_RDY disabled), but there is no data and even no clock at any pin (in my application clock should be at PA6). The 2.5 times higher clock rate of AHB is in my opinion needed for sampling (Nyquist) i.e. receiving data. Anyway the clock of the Core (AHB) is 250MHz but I tried it also with 32, and 4MHz without success. The code I posted is derived from the example of H7 and I use only DMA for transmitting, this is my transmit code:
if (HAL_PSSI_Transmit_DMA(&hpssi, (uint32_t*)aTxBuffer, sizeof(aTxBuffer)) != HAL_OK)
{
__NOP();
}
Thank you Kaouthar.
Regards, Benedikt
2025-03-13 3:41 AM - edited 2025-03-13 3:42 AM
Hello @berait;
Transmitting and receiving data uses the PSSI_PDCK clock, so if you don’t have it it will not be possible to send or receive any bit. Then the PSSI_PDCK can be either generated by the RCC or input on the PDCK pin.
Thank you.
Kaouthar
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.
2025-03-17 1:01 AM
Thank you Kaouthar,
I have now succeeded by connecting the PSSI_PCK to a clock signal generated with TIM2. Is there no possibility to generate the needed clock signal and connect it internal (inside of the chip). In terms of stability and EMI it would be great if I could avoid routing 80MHz to an external pin and feed it back to PSSI_PDCK pin.
Regards, Benedikt
2025-03-17 1:33 AM
Hello @berait;
Is the initial issue solved or not? Are you able to generate data output on GPIO's by connecting the PSSI_PCK to a clock signal ?
If yes, please click on Accept as Solution on the reply which solved your issue.
I’m not sure I’ve correctly understood your second question. For that, it is useful to create a new thread with more details.
The PSSI_PDCK can be configured in input mode (default) or in output mode. When configured in output mode, the clock is generated by the device RCC.
Thank you.
Kaouthar
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.
2025-03-18 4:29 AM
Hi Kaouthar,
no the problem is not solved. In the first moment I thought it is solved because I was able to reach a breakpoint inside HAL_PSSI_TxCpltCallback(). This ISR is getting triggered when DMA has transfered the entire user data from the FIFO to the PSSI-data lines. But, in my case I enter the ISR without any data transmission. My PSSI_D0..D7 stays low. For indication I have selected 4 byte with 0x55, 0xAA values to see the toggle pattern on the PSSI output pins.
Here is my init code:
static void MX_PSSI_Init(void)
{
hpssi.Instance = PSSI;
hpssi.Init.DataWidth = HAL_PSSI_8BITS;
hpssi.Init.BusWidth = HAL_PSSI_8LINES;
hpssi.Init.ControlSignal = HAL_PSSI_DE_RDY_DISABLE;
hpssi.Init.ClockPolarity = HAL_PSSI_RISING_EDGE;
hpssi.Init.DataEnablePolarity = HAL_PSSI_DEPOL_ACTIVE_HIGH;
hpssi.Init.ReadyPolarity = HAL_PSSI_RDYPOL_ACTIVE_HIGH;
if (HAL_PSSI_Init(&hpssi) != HAL_OK)
{
Error_Handler();
}
}
void HAL_PSSI_MspInit(PSSI_HandleTypeDef* hpssi)
{
GPIO_InitTypeDef GPIO_InitStruct = {0};
if(hpssi->Instance==PSSI)
{
/* Peripheral clock enable */
__HAL_RCC_DCMI_PSSI_CLK_ENABLE();
__HAL_RCC_GPIOA_CLK_ENABLE();
__HAL_RCC_GPIOB_CLK_ENABLE();
__HAL_RCC_GPIOC_CLK_ENABLE();
/**PSSI GPIO Configuration
PA4 ------> PSSI_DE
PA6 ------> PSSI_PDCK
PB15 ------> PSSI_D2
PC6 ------> PSSI_D0
PC7 ------> PSSI_D1
PC9 ------> PSSI_D3
PC11 ------> PSSI_D4
PB4(NJTRST) ------> PSSI_D7
PB6 ------> PSSI_D5
PB7 ------> PSSI_RDY
PB8 ------> PSSI_D6
*/
GPIO_InitStruct.Pin = GPIO_PIN_4|GPIO_PIN_6;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
GPIO_InitStruct.Alternate = GPIO_AF13_PSSI;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
GPIO_InitStruct.Pin = GPIO_PIN_15|GPIO_PIN_4|GPIO_PIN_6|GPIO_PIN_7
|GPIO_PIN_8;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
GPIO_InitStruct.Alternate = GPIO_AF13_PSSI;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
GPIO_InitStruct.Pin = GPIO_PIN_6|GPIO_PIN_7|GPIO_PIN_9|GPIO_PIN_11;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
GPIO_InitStruct.Alternate = GPIO_AF13_PSSI;
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
__HAL_SBS_FASTMODEPLUS_ENABLE(SBS_FASTMODEPLUS_PB6);
__HAL_SBS_FASTMODEPLUS_ENABLE(SBS_FASTMODEPLUS_PB7);
__HAL_SBS_FASTMODEPLUS_ENABLE(SBS_FASTMODEPLUS_PB8);
/* PSSI DMA Init */
/* GPDMA1_REQUEST_DCMI Init */
handle_GPDMA1_Channel0.Instance = GPDMA1_Channel0;
handle_GPDMA1_Channel0.Init.Request = GPDMA1_REQUEST_DCMI;
handle_GPDMA1_Channel0.Init.BlkHWRequest = DMA_BREQ_SINGLE_BURST;
handle_GPDMA1_Channel0.Init.Direction = DMA_MEMORY_TO_PERIPH;
handle_GPDMA1_Channel0.Init.SrcInc = DMA_SINC_INCREMENTED;
handle_GPDMA1_Channel0.Init.DestInc = DMA_DINC_FIXED;
handle_GPDMA1_Channel0.Init.SrcDataWidth = DMA_SRC_DATAWIDTH_BYTE;
handle_GPDMA1_Channel0.Init.DestDataWidth = DMA_DEST_DATAWIDTH_BYTE;
handle_GPDMA1_Channel0.Init.Priority = DMA_HIGH_PRIORITY;
handle_GPDMA1_Channel0.Init.SrcBurstLength = 1;
handle_GPDMA1_Channel0.Init.DestBurstLength = 1;
handle_GPDMA1_Channel0.Init.TransferAllocatedPort = DMA_SRC_ALLOCATED_PORT0|DMA_DEST_ALLOCATED_PORT0;
handle_GPDMA1_Channel0.Init.TransferEventMode = DMA_TCEM_BLOCK_TRANSFER;
handle_GPDMA1_Channel0.Init.Mode = DMA_NORMAL;
if (HAL_DMA_Init(&handle_GPDMA1_Channel0) != HAL_OK)
{
Error_Handler();
}
__HAL_LINKDMA(hpssi, hdmatx, handle_GPDMA1_Channel0);
if (HAL_DMA_ConfigChannelAttributes(&handle_GPDMA1_Channel0, DMA_CHANNEL_NPRIV) != HAL_OK)
{
Error_Handler();
}
}
}
With the upper initialization I call this:
/* Buffer data to transmit to the Slave */
static uint8_t aTxBuffer[4] __attribute__((aligned(4))) = {0x55, 0xaa, 0x55, 0xaa};
if (HAL_PSSI_Transmit_DMA(&hpssi, (uint32_t*)aTxBuffer, sizeof(aTxBuffer)) != HAL_OK)
{
__NOP();
}
After that call I reach the breakpoint immediately indside my ISR, even if there wasn't any clock pulse at the
PSSI_PDCK pin. I supply the clock external, but even if i connect the PSSI_PDCK input to GND - the beavior
is the same -> always end up in HAL_PSSI_TxCpltCallback...
void HAL_PSSI_TxCpltCallback(PSSI_HandleTypeDef *hpssi)
{
PSSI_TransmitComplete_count++; //set breakpoint here!
}
I guess it must have something to to with the GPDMA1 settings, but so far they look plausible
to me.
BTW:
I don't understand your hint:
"The PSSI_PDCK can be configured in input mode (default) or in output mode.
When configured in output mode, the clock is generated by the device RCC."
--> Do you mean the PPSI-Modul can be configured in input mode and output mode, and that
also changes the direction of PSSI_DE and PSSI_RDY?
In my opinion the clock pin PSSI_PDCK stays always an input and I can not find any setting in STM32H533
manual to do so.
Thank you again for your help!
Regards Benedikt
2025-03-19 5:53 AM
Hello @berait,
Are you able to transmit data without GPDMA?
May How to configure the GPDMA and How to configure the linked list mode in STM32CubeMX can help you to check the GPDMA configuration.
Thank you.
Kaouthar
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.