IRQ Management

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

IRQ Management

1,797 Views
nadine
Contributor III

Hi,

 

For some time now, I have been working on a software application using a FRDM-K64F board and a specific daughter board on it. This program will mange a PLC stack, and I have harsh real time constraints. The two boards communicate thru electrical wiring.

 

I have asked several questions, and received useful and effective help of the community.

I have configure the DAC (transmit side), the ADC16 (receive side) using interruptions and hardware trigger mechanism (PIT,  PDB) to make sure to send /receive data at 1.2 MHz.

And finally, I have a receive and a transmitter operational applications.

 

But (there is always a but in my email), the problem becomes a little bit more complex when I want to mix the send/receive in the same applications.

On the transmit side, I use the interrupt function of the PDB and I can enable / disable the interrupts using the EnableIRQ/DisableIRQ functions.

On the receive side, I use the interrupt function of the ADC16, and I enable the interrupts using the EnableIRQ function.

But once I have disable them using the DisableIRQ function, I'm not able to restart them again.

 

Any help, advice is welcome.

 

Thanks,

Best Regards

Nadine

Labels (1)
0 Kudos
7 Replies

1,336 Views
isaacavila
NXP Employee
NXP Employee

Hello,

Have you checked if PDB sequence error is set? maybe PDB error occurs when MCU is printing on console and it avoids ADC_Handler to be called. In my side, I cannot reproduce this issue in my FRDM-K64F but I think that this could be happening due timing issue on PDB.

Regards,

Isaac

0 Kudos

1,336 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, Nadine,

I suppose that you use PDB to trigger ADC16, if you use SDK, you can use the following code to enable interrupt.

  NVIC_SetPriority(xx,10);

   NVIC_ClearPendingIRQ(xx);

    EnableIRQ(xx);

Here, xx is the interrupt vector number.

If it can not solve your issue, pls develop a simple project which can duplicate your issue if your code is confidential, and tell us the part number and software  tools version and attach your project here, so that we can debug on our side.

BR

XiangJun Rong

0 Kudos

1,336 Views
nadine
Contributor III

Hi XiangJun,

I have send you a « simple project » that duplicates my issue.

I have removed a lot of code related to the PLC stack, but it looks like the

problem

still remains. I have deliberately left all the FRDM related code.

I’m using a FRDM-K64F board, on Kinetis Design Studio 3.2.0 and SDK 2.0

environment.

Running the program, a simple menu will appear …

Select choice 2, enter a number of PPDU (for example 5000), plug a scope on

PTB23 and you should see

something like next picture. The GPIO associated to PTB23 is toggled each

time the PDB_IRQ_HANDLER()

function is called. This is how the data are sent on the line. Have a look

at the Frdm_TX() function, you will see,

EnableIRQ(PDB_IRQ_ID) and DisableIRQ(PDB_IRQ_ID) functions calls. It works

fine.

Reset the board, run the program again, and select choice 1, and a number of

PPDU of 500 for example.

Plug a scope on PTC9, and you should see next picture. . The GPIO associated

to PTC9 is toggled each time

the ADC16_IRQ_HANDLER() function is called.

You can select the option 1 more than once, the process is still working.

Now, in the Frdm_RX() function uncomment EnableIRQ(ADC16_IRQ_ID) and

DisableIRQ(ADC16_IRQ_ID) functions calls.

Run the program again, and select choice 1, and a number of PPDU of 500 for

example. Plug a scope on PTC9

THE PROBLEM APPEARS here. The second time, you select option 1, the

ADC16_IRQ_HANDLER() function

is not called anymore.

I’m not able to do the same thing on the receive side as I do on the

transmit side.

Any help is welcome. Let me know if you need more details.

Thanks in advance.

Best Regard

Nadine,

TALUKO

CRE@TVT NUMERIQUE

Bâtiment A, 1er étage

Place Besagne

83000 Toulon

<http://www.taluko.com> www.taluko.com

Tel : +(33) 4 98 07 74 52

Mobile: +(33) 6 66 27 85 66

0 Kudos

1,336 Views
isaacavila
NXP Employee
NXP Employee

Hello Nadine,

I've not checked deeper your code but it seems to be a Sequence Error on PDB, here is the bit status from PDB registers:

Sequence Error.jpg

Please check this note (Section 39.4.1 PDB pre-trigger and trigger outputs):

PDB Sequence Error.jpg

And checking your IRQ handlers, you do a lot of stuff in every IRQ handlers (it is recommended to implement shorter IRQ handlers like setting flags, events, etc in order to avoid this issues). Besides, you configured PDB to count "1" Bus cycle in order to generate a new hardware trigger for ADC, so it takes aproximately 1/60MHz to generate a trigger (16nS) for ADC, are you sure that ADC's conversion speed is higher that this value?

Regards,

Isaac

0 Kudos

1,336 Views
nadine
Contributor III

Hi Isaac,

You’re certainly right. I can improve my IRQ handlers functions,

And I will do as you suggest.

But, the point that causes me some confusion, is that

the program works (enter and leave the ADC16_IRQ_HANDLER()

function with no problem using following code. And, the Frdm_RX()

function can be called several times with no problem.

void Frdm_RX(int NbPPDU)

{

int32_t NbDone = 0;

while (NbDone++ < NbPPDU) {

adc16_buffering = true;

adc16IndexBuffer = 1;

//EnableIRQ(ADC16_IRQ_ID);

while (adc16IndexBuffer > 0) { } /* Frame

buffering - Wait to reach end of buffer */

adc16_buffering = false;

//DisableIRQ(ADC16_IRQ_ID);

}

}

Then, if I uncomment the two lines

EnableIRQ(ADC16_IRQ_ID);

And

DisableIRQ(ADC16_IRQ_ID);

The ADC16_IRQ_HANDLER() is called ‘NbPPDU’ times (validated with 500)

with no problem. But, only ONE time. Then, the ADC16_IRQ_HANDLER()

function is never called again.

And finally, if I uncomment the two lines, and add a printf at the end of

the while loop,

The ADC16_IRQ_HANDLER() is called only once.

EnableIRQ(ADC16_IRQ_ID);

And

DisableIRQ(ADC16_IRQ_ID);

printf(“.”);

It looks like, the printf() function, has an uncontrollable effect on my

program.

What do do think ?

Thanks again.

Best regards

Nadine

TALUKO

<mailto:CRE@TVT> CRE@TVT NUMERIQUE

Bâtiment A, 1er étage

Place Besagne

83000 Toulon

<http://www.taluko.com> www.taluko.com

Tel : +(33) 4 98 07 74 52

Mobile: +(33) 6 66 27 85 66

0 Kudos

1,336 Views
isaacavila
NXP Employee
NXP Employee

Hello,

I am unable to execute ADC's handler (no matter if I select 500) when enable IRQ and DisableIRQ are not commented. How did you test it?

Regards,

Isaac

0 Kudos

1,336 Views
nadine
Contributor III

Hi Isaac,

The problem is that I can DISABLEIRQ/ENABLEIRQ with no problem, until I

leave the Frdm_RX() function. In fact,

until the printf function is called.

I have tried to called the Frdm_RX() function several times, without any

printf between the function calls, and it works fine.

In the ADC16_IRQ_HANDLER(), I set a GPIO pin to 0/1 and I use a scope to see

what ‘s going on in the function.

The first time the Frdm_RX() function is called (for NbPPDU=500), here are

the scope results. The function is called at

requested frequency (1.2 MHz) with the Enable/Disable IRQ called every

FRAMESIZE (20000) points.

Then, as soon as we leave the function, display the main menu, and re-enter

the function …

The ADC16_IRQ_HANDLER() is not called anymore. The GPIO remains high

Best Regards

Nadine,

TALUKO

CRE@TVT NUMERIQUE

Bâtiment A, 1er étage

Place Besagne

83000 Toulon

<http://www.taluko.com> www.taluko.com

Tel : +(33) 4 98 07 74 52

Mobile: +(33) 6 66 27 85 66

0 Kudos