How to set up software generated interrupt?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to set up software generated interrupt?

Jump to solution
2,494 Views
andrariver
Contributor I

Currently, I am doing some research on my campus about creating new scheduler method by implementing software generated the interrupt. The method is using unused device specific interrupts listed in IRQn. In previous research that uses Arduino Due (ARM Cortex M3), this method worked. when I tried this method on Udoo Neo (imx6sx ) using Freertos BSP Linux by modifying ADC driver example and adding one more interrupt. In the test, I used the scenario below, just for testing the NVIC interrupt functions and I've got stuck in function NVIC_SetPendingIRQ(ADC2).

NVIC_SetPriority(ADC1, 3)
NVIC_EnableIRQ(ADC1)
NVIC_SetPendingIRQ(ADC1)
NVIC_ClearPendingIRQ(ADC1)

NVIC_SetPriority(ADC2, 3)
NVIC_EnableIRQ(ADC2)
NVIC_SetPendingIRQ(ADC2)
NVIC_ClearPendingIRQ(ADC2)

This is my board.h

#if !defined(__BOARD_H__)
#define __BOARD_H__

#include "pin_mux.h"
#include "rdc.h"
#include "rdc_defs_imx6sx.h"
#include "ccm_imx6sx.h"
#include "clock_freq.h"

/* The board name */
#define BOARD_NAME "IMX6SX_AI_M4"
#define BOARD_DOMAIN_ID (1)

/* ADC information for this board */
#define BOARD_ADC_RDC_PDAP             rdcPdapAdc1
#define BOARD_ADC_BASEADDR             ADC1
#define BOARD_ADC_IRQ_NUM                ADC1_IRQn
#define BOARD_ADC_HANDLER                ADC1_Handler
#define BOARD_ADC_INPUT_CHANNEL   (3)

#define BOARD_ADC_RDC_PDAP2             rdcPdapAdc2
#define BOARD_ADC_BASEADDR2             ADC2
#define BOARD_ADC_IRQ_NUM2                ADC2_IRQn
#define BOARD_ADC_HANDLER2                ADC2_Handler
#define BOARD_ADC_INPUT_CHANNEL2  (3)

this is my hardware_init.c

#include "board.h"
#include "pin_mux.h"

void hardware_init(void)
{
      /* Board specific RDC settings */
      BOARD_RdcInit();

      /* Board specific clock settings */
      BOARD_ClockInit();

      /* initialize debug uart */
      dbg_uart_init();

      /* In this example, we need to grasp ADC1 module exclusively */
      // RDC_SetPdapAccess(RDC, BOARD_FLEXCAN_RDC_PDAP, 3 << (BOARD_DOMAIN_ID * 2), false, false);
      RDC_SetPdapAccess(RDC, BOARD_ADC_RDC_PDAP, 3 << (BOARD_DOMAIN_ID * 2), false, false);
      RDC_SetPdapAccess(RDC, BOARD_ADC_RDC_PDAP2, 3 << (BOARD_DOMAIN_ID * 2), false, false);

}

this is my main.c


#include
#include
#include "adc_imx6sx.h"
#include "debug_console_imx.h"
#include "board.h"

#define ADC_RESOLUTION 0xFFF;

int main(void)
{
      uint32_t count;

      adc_init_config_t adcConfig = {
            .clockSource = adcIpgClockDivide2,
            .divideRatio = adcInputClockDiv4,
            .averageNumber = adcAvgNum32,
            .resolutionMode = adcResolutionBit12
      };

      // Initialize board specified hardware.
      hardware_init();

      PRINTF("\n-------------- ADC imx6sx driver example with two ADC on--------------\n\n\r");
      PRINTF("This example demonstrates usage of ADC driver on i.MX 6SoloX processor.\n\r");
      PRINTF("It Continuous convert Analog Input, and print the result to terminal \n\r");

      /* Initialize ADC module. */
      ADC_Init(BOARD_ADC_BASEADDR, &adcConfig);
      ADC_Init(BOARD_ADC_BASEADDR2, &adcConfig);

      NVIC_SetPriority(100, 3);
      PRINTF("\nafter set priority ADC1");
      NVIC_EnableIRQ(100);
      PRINTF("\nafter enable ADC1");
       NVIC_SetPendingIRQ(100);
       PRINTF("\nafter set pending ADC1");
       NVIC_ClearPendingIRQ(100);
      PRINTF("\nafter clear pending ADC1");

       NVIC_SetPriority(101, 3);
       PRINTF("\n\nafter set priority ADC2");
       NVIC_EnableIRQ(101);
       PRINTF("\nafter enable ADC2");
       NVIC_SetPendingIRQ(101);
       PRINTF("\nafter set pending ADC2");
       NVIC_ClearPendingIRQ(101);
       PRINTF("\nafter clear pending ADC2");      

}

      

and this is the output

-------------- ADC imx6sx driver example with two ADC on--------------
This example demonstrates usage of ADC driver on i.MX 6SoloX processor.

It Continuous convert Analog Input, and print the result to terminal

after set priority ADC1
after enable ADC1
after set pending ADC1
after clear pending ADC1

after set priority ADC2
after enable ADC2

It stuck when running NVIC_SetPendingIRQ() function for ADC 2.

Any idea will be helpful . thanks

Labels (2)
0 Kudos
1 Solution
1,707 Views
CarlosCasillas
NXP Employee
NXP Employee

Hi Andra,

It means that it is required to consider the entire SoC, as the interrupts and peripherals are shared between M4 and A9 cores (managed by the RDC), and the M3 code cannot be copy&paste with the same results. That’s why the mentioned documents were pointed.

Hope this will be useful for you.

Best regards!

/Carlos

View solution in original post

4 Replies
1,707 Views
CarlosCasillas
NXP Employee
NXP Employee

Hi Andra,

The mentioned procedure cannot be directly used as is on the i.MX6SX, as it is a hybrid device and there are different functionalities for interoperability between A9 and M4 cores.

You could take a look at the following links that provides information regarding i.MX6SX functionality:

https://community.nxp.com/docs/DOC-103350

https://www.nxp.com/docs/en/application-note/AN5127.pdf

https://www.nxp.com/docs/en/application-note/AN5317.pdf

https://www.nxp.com/docs/en/application-note/AN4815.pdf


Hope this will be useful for you.
Best regards!
/Carlos

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
1,708 Views
andrariver
Contributor I

Sorry for late reply and thanks for the references,

But when you meant by "the mentioned procedure cannot be directly used ", does interrupt by software method cannot be used anymore in this board (Udoo Neo) or there is still a hope for me to use it?

0 Kudos
1,708 Views
CarlosCasillas
NXP Employee
NXP Employee

Hi Andra,

It means that it is required to consider the entire SoC, as the interrupts and peripherals are shared between M4 and A9 cores (managed by the RDC), and the M3 code cannot be copy&paste with the same results. That’s why the mentioned documents were pointed.

Hope this will be useful for you.

Best regards!

/Carlos

1,708 Views
andrariver
Contributor I

Hi Carlos,

thanks for the answer and now I've got your point. I will look up further  to the references for the solution.

Radipta

0 Kudos