Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Register Log in

Float variables inside interrupts

Status
Not open for further replies.

jaschek

Newbie level 5
Joined
Aug 27, 2008
Messages
10
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,347
I am using linux on a MPC5200 board.

There is a serial interrupt in the code. On accessing a global floating point variable from inside the interrupts I am corrupting variables elsewhere. Is accessing float variables inside not recommended and why ?

also note that the frequency of this interrupts is fairly high.
 

luben111

Advanced Member level 1
Joined
Mar 2, 2002
Messages
491
Helped
111
Reputation
223
Reaction score
107
Trophy points
1,323
Location
UK
Activity points
3,907
Hi,
There is no such limitation to avoid accessing floating point variables in the interrupt section. The problem is just manifestation of something completely different:
1. stack overflow
2. sharing problems
3. timing problem

You can try to pinpoint the problem by insulating the problems - try to:
1. change the stack size
2. put some protection tehniques when accessing this variable - it's common mistake to access such variables without protection. You'll get definetly problems if during the access of the variables from the main level the interrupt changes this variable.
3. reduce the speed of interupts (slow down the serial events)
 

vysakhpillai

Junior Member level 2
Joined
Jun 10, 2008
Messages
23
Helped
5
Reputation
10
Reaction score
4
Trophy points
1,283
Activity points
1,375
for ultra timing critical applications, there can be minor slacks if u access floating point variables inside interrupts. especially if the FPU is implimented in software. However, corruption cannot occur as a result of this as luben111 suggested
 

blind_man

Member level 3
Joined
Feb 26, 2005
Messages
56
Helped
10
Reputation
20
Reaction score
10
Trophy points
1,288
Location
Romania
Activity points
1,646
It cross my mind two reasons:
- wrong set of adress in moving data memset() memcpy()
- wrong set of adress in DMA access
 

horace1

Advanced Member level 5
Joined
Nov 18, 2008
Messages
2,123
Helped
596
Reputation
1,188
Reaction score
573
Trophy points
1,393
Location
Norwich, UK
Activity points
13,071
the MPC5200 has a floating point unit. A couple of thoughts
1. does the hardware automatically save the FPU registers on interrupt?
2. are you calling none-reentrant functions from within the interrupt service routine?
3. have you declared global variables used within the interrupt routine as volatile?
 

blind_man

Member level 3
Joined
Feb 26, 2005
Messages
56
Helped
10
Reputation
20
Reaction score
10
Trophy points
1,288
Location
Romania
Activity points
1,646
1.In the interrupt no registers are save by hardware, depending on compiler there are implicit implementation on interrupt header of routine and post.
If you need special register to be save you have to rewrite the interrupt mechanism from scratch .
2. You can call what function you need in the interrupt but there are bad thinks coming after if
- functions are to big and can lock the resources
- if same interrupt come in this time, lost of interrupts (phantom interrupts) can appear and old 16 bit micro have hardware support for this situation.
3. Global variables used in interrupt can be changed any time and in a way you have to be careful take this into account. Usage of volatile I find it useful
- when you what to avoid optimization
- when the address points out to a mapped register.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top