cancel
Showing results for 
Search instead for 
Did you mean: 

STM32N657X0-Q ADC+TIMER+DMA

Thomas_H
Associate II

Hi, 
I would like to develop an application using ADC + TIMER + DMA. My base code doesn’t work, and I don’t understand why. 

To debug, I introduce the variable "toto". This value of this variable doesn't change. 

I use STM32CubeIDEv1.19.

Best regards

Thomas- H

5 REPLIES 5
RomainR.
ST Employee

Hello @Thomas_H 

After checking your code, you forgot to configure the security privilege of analog path of ADC Channel_0 (PA1) and you do not configure the RIF aware peripherals such as ADC12 and GPDMA channel.
Remember that the STM32N6 is always in secure context.
Check the code below or refer to the existing project: 
STM32Cube_FW_N6_V1.3.0\Projects\NUCLEO-N657X0-Q\Examples\ADC\ADC_SingleConversion_TriggerTimer_DMA
Best regards,
Romain,

/* set all required IPs as secure privileged */
  __HAL_RCC_RIFSC_CLK_ENABLE();

  /*RISUP configuration*/
  HAL_RIF_RISC_SetSlaveSecureAttributes(RIF_RISC_PERIPH_INDEX_ADC12 , RIF_ATTRIBUTE_SEC | RIF_ATTRIBUTE_NPRIV);

  /* RIF-Aware IPs Config */

  /* set up GPDMA configuration */
  /* set GPDMA1 channel 0 used by ADC1 */
  if (HAL_DMA_ConfigChannelAttributes(&handle_GPDMA1_Channel0,DMA_CHANNEL_SEC|DMA_CHANNEL_PRIV|DMA_CHANNEL_SRC_SEC|DMA_CHANNEL_DEST_SEC)!= HAL_OK )
  {
    Error_Handler();
  }

  /* set up GPIO configuration */
  HAL_GPIO_ConfigPinAttributes(GPIOA,GPIO_PIN_1,GPIO_PIN_SEC|GPIO_PIN_NPRIV);

security  

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.

Hello,

Thank you for your reply.

I will test with your modifications.

Can the lines to be added to my code not be generated automatically by STM32CubeIDE?

Kind regards

Hello @Thomas_H 
Actually, when using STM32CubeMX 6.16.1 in standalone and STM32CubeIDE 2.0.0, this additional code must be added manually in reference to the example I'm referring previously.
I requested internally a change request to fix it and for a correct code generation in the next version of CubeMX (internal ticket number 224882)
Best regards,

Romain,

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.

Hello Romain, 

I am still having a problem. Before solving it, I would like to understand the configuration differences between the following project structures: 'Secure domain only', 'Secure and Non-Secure domains', 'FSBL', and 'Appli'. Also, in which 'main.c' file should I place my code? I am going to test this with a simple ADC conversion application.

Is there a document that outlines best practices and configurations for developing an application?

Best regards

Thomas

RomainR.
ST Employee

Hi @Thomas_H 

You could refer first to the UM3249, sections:
5.1 Running an example or an application
5.3 Developing a custom application

STM32Cube_FW_N6_V1.3.0\Documentation\STM32CubeN6GettingStarted.pdf

For ADC with DMA trigrered with a Timer there is also a ready to use example in:
STM32Cube_FW_N6_V1.3.0\Projects\NUCLEO-N657X0-Q\Examples\ADC\ADC_SingleConversion_TriggerTimer_DMA

Concerning CubeMX, when creating a new STM32N6 project, it asks if you want to create:

- Secure and Non-Secure domains Project:
This will include 3 sub-projects named, FSBL, AppS et AppNs. This is the full project including FSBL to configure external memory and System Clock, then jump in AppS to allow the peripherals privileges configuration allowed in Non Secure, then it jump in AppNs. This is a ARM-V8 secure - Non Secure Isolation context.
- Secure domains only: 
This will create only FSBL and AppS. Here the context will be always secure.

I don't know what kind of application you want to create. I recommend you:

- Start with the ADC + DMA example only based on FSBL project.
- Or with CubeMX, create a Secure domains only project, and before generated the code, you uncheck the Appli Project Structure in Project Manager Tab. (it will generate only FSBL and not AppS)
Place your code in FSBL\src\main.c

Best regards,

Romain, 

 

 

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.