cancel
Showing results for 
Search instead for 
Did you mean: 

Nested interrupts and absolute flash variables

pt1
Associate II
Posted on November 05, 2008 at 09:44

Nested interrupts and absolute flash variables

10 REPLIES 10
pt1
Associate II
Posted on May 17, 2011 at 12:48

Hi

I'm new in STM32 software development and I have 2 questions:

1) Nested interrupts: I've tried several settings of the preemption and the sublevel interrupt but nothing help's. I need to have Timer1 interrupt the highest priority Interrupt, so it can interrupt an USART1 interrupt. Is this possible? If so, how?

2) I need to have some const variable at an absolut address in flash memory. It should be at the end of the flash memory. How can I do that?

I'm using the GNU compiler from raisonance.

Best regards Edi

pt1
Associate II
Posted on May 17, 2011 at 12:48

Hi,

nobody who can help me? No hints where I can search or get help?

Best regards Edi

picguy
Associate II
Posted on May 17, 2011 at 12:48

>I need to have Timer1 interrupt the highest priority Interrupt

You can't do that. But timer1 can interrupt a lower priority interrupt. You might be confused because lower numbered priorities are higher priority.

design5
Associate II
Posted on May 17, 2011 at 12:48

Hi Pt1:

In general, I try to avoid nested interrupts. It saves me a lot of headaches. Sorry, I can not be of more help, except to suggest looking at your design, and requirements, to see if you can do without nested interrupts.

Garry Anderson.

ivanov-i
Associate II
Posted on May 17, 2011 at 12:48

Hi Pt1,

The NVIC block, which is inside the STM32, is desribed in ''Cortex - M3 Techincal Reference Manual'', which could be found on ARM web-site. Note, than STM32 uses only 4 out of the 8 possible priority bits, which are the most significant ones. Another specific is that the counting of interrupt numbers starts from the Watchdog (0) and goes up.

About locating of constant at a fixed address - I am not using the GNU compiler, but in IAR it is possible by locating the constant in a named section and then assigning a phisical address of the given section in the .icf file. In GNU there should be an equivalent way to do so.

pt1
Associate II
Posted on May 17, 2011 at 12:48

Hi guys,

thank you so far,

@picguy: I know this, but the interrupt priorities should be altered, don't they? If I can't changed the interrupt priorities of the STM32 it seems to be a constructional defect.

@Garry: Nested interrupt is a normal thing in my applications. I had to use the timer interrupt for making timeouts, even in other interrupts. Should I count down a variable - this is not very professional.

@ivanov-i: I've seen an application for absolute variables: This is not very easy to do, the GNU should have a better feature in the future.

Interrupt priority: I've tried several setting, but nothing helps:

General:

/* Configure the NVIC Preemption Priority Bits */

NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);

Timer:

/* Enable the TIM1 UP Interrupt */

NVIC_InitStructure.NVIC_IRQChannel=TIM1_UP_IRQChannel;

NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority=1;

NVIC_InitStructure.NVIC_IRQChannelSubPriority=1;

NVIC_InitStructure.NVIC_IRQChannelCmd=ENABLE;

NVIC_Init(&NVIC_InitStructure);

USART:

/* Enable the USART1 Interrupt */

NVIC_InitStructure.NVIC_IRQChannel=USART1_IRQChannel;

NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority=2;

NVIC_InitStructure.NVIC_IRQChannelSubPriority=2;

NVIC_InitStructure.NVIC_IRQChannelCmd=ENABLE;

NVIC_Init(&NVIC_InitStructure);

I've tried also 1,1 in USART and 2,2 in Timer and many other combinations ...

Best regards Edi

jaroslaw2
Associate II
Posted on May 17, 2011 at 12:48

Hi,

I hope this will help you!

Code:

<BR>/* Configure NVIC for the whole project */ <BR>NVIC_DeInit(); <BR>NVIC_SCBDeInit(); <BR>NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4); <BR> <BR> <BR>/* Enable the TIM1 UP Interrupt */ <BR>NVIC_InitStructure.NVIC_IRQChannel=TIM1_UP_IRQChannel; <BR>NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority=1; <BR>NVIC_InitStructure.NVIC_IRQChannelSubPriority=0; <BR>NVIC_InitStructure.NVIC_IRQChannelCmd=ENABLE; <BR>NVIC_Init(&NVIC_InitStructure); <BR> <BR> <BR>/* Enable the USART1 Interrupt */ <BR>NVIC_InitStructure.NVIC_IRQChannel=USART1_IRQChannel; <BR>NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority=2; <BR>NVIC_InitStructure.NVIC_IRQChannelSubPriority=0; <BR>NVIC_InitStructure.NVIC_IRQChannelCmd=ENABLE; <BR>NVIC_Init(&NVIC_InitStructure); <BR> <BR>

I have edited this post and change subpriority from 1 to 0

[ This message was edited by: jaroslaw.oska on 29-10-2008 12:31 ]

I have edited this post and change

NVIC_PriorityGroup_0 to NVIC_PriorityGroup_4 thanks to paul.smitton

[ This message was edited by: jaroslaw.oska on 06-11-2008 09:04 ]

pt1
Associate II
Posted on May 17, 2011 at 12:48

Hi jaroslaw,

thank you, I'll try it as soon as possible and report here,

please stand by ...

At the moment I have another problem which need's to be fixed first.

Best regards Edi

[ This message was edited by: pt1 on 27-10-2008 15:57 ]

paulsmitton9
Associate III
Posted on May 17, 2011 at 12:48

jaroslaw.oska, pt1,

I think if you are setting pre-emption priorites (which is correct), then you should use say NVIC_PriorityGroup_4 since this allows four bits for pre-emption priority (whilst group 0 allows none).

Cheers,

Paul :)