How many CPU cycles does it takes to fully execute u32AHI_DioReadInput();

cancel
Showing results for 
Search instead for 
Did you mean: 

How many CPU cycles does it takes to fully execute u32AHI_DioReadInput();

168 Views
hernanolave
Contributor I

Hello,

We are developing an Ultrasonic sensor in which we need to read data from a parallel ADC. We are currently using the following code to read data from DIO:

PinsReadOut[i] = u32AHI_DioReadInput();

We managed to measure how long it is taking for this instruction to execute using the following code:


vAHI_DioSetOutput((1 << DIO17), 0x0);
PinsReadOut[i] = u32AHI_DioReadInput();
vAHI_DioSetOutput(0x0, (1 << DIO17));

We are setting a pin high before the instruction and then resetting the pin back to low.

The signal measured on scope for this step is 880nano seconds
We already measure how long does it takes for the controller to set and reset the pins and it was measured the same way using the same code but without the "PinsReadOut[i] = u32AHI_DioReadInput();" line. The result was that setting the pin high and then resetting it took 660nano seconds. Which leaves us with a total duration of 220nano secons for the port readout

We already set the clock frequency divider to be 1 so we are running at full speed using "bAHI_SetClockRate(0x3);" in our code.

How many cycles does u32AHI_DIOReadInput() would take to fully execute? Is 220nano seconds normal for this type of instruction?

Our main goal is to achieve ADC reads at 3MSPS or something around that number for our projects needs, and since the ADC has a throughput capability of up to 10MSPS the only thing that is slowing down the process would be the total time to execute readouts from pins. How could we improve the process of reading data from pins on the module?

We took some other measurements in which we put the code on a for loop to measure how long does it takes to read 200 times from pins and the result was 88.40micro seconds. 88.4 microseconds / 200 times gives us that each readout in the for loop is taking 442 nano second which is longer than before (we know that there's some logic executing the for loop but it seems to be too much for a module running at 32Mhz. The code for this test is the following:

vAHI_DioSetOutput((1 << DIO17), 0x0);
for (i = 0; i <= 200; i++) {
PinsReadOut[i] = u32AHI_DioReadInput();
}
vAHI_DioSetOutput(0x0, (1 << DIO17));

Labels (2)
Tags (2)
0 Kudos
1 Reply

61 Views
mario_castaneda
NXP TechSupport
NXP TechSupport

Hi Hernan,

Unfortunately, the requirement Time cannot be reached by the JN. 

The 'for' implementation adds more clock cycles.

All peripherals have their registers mapped into the memory space. Access to these registers requires three peripheral clock cycles. Applications have access to the peripherals through the software libraries that present a high-level view of the peripheral's functions through a series of dedicated software routines.

Regards,

Mario

0 Kudos