AnsweredAssumed Answered

How to set up software generated interrupt?

Question asked by andra river on Mar 22, 2018
Latest reply on Apr 4, 2018 by andra river

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_SetPriority(ADC2, 3)


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_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_RDC_PDAP2             rdcPdapAdc2
#define BOARD_ADC_BASEADDR2             ADC2
#define BOARD_ADC_IRQ_NUM2                ADC2_IRQn
#define BOARD_ADC_HANDLER2                ADC2_Handler



this is my hardware_init.c

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

void hardware_init(void)
      /* Board specific RDC settings */


      /* Board specific clock settings */


      /* initialize debug uart */


      /* 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 "adc_imx6sx.h"
#include "debug_console_imx.h"
#include "board.h"




int main(void)
      uint32_t count;


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


      // Initialize board specified hardware.


      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");
      PRINTF("\nafter enable ADC1");
       PRINTF("\nafter set pending ADC1");
      PRINTF("\nafter clear pending ADC1");


       NVIC_SetPriority(101, 3);
       PRINTF("\n\nafter set priority ADC2");
       PRINTF("\nafter enable ADC2");
       PRINTF("\nafter set pending ADC2");
       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