Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics 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.

Problem with signal speed in a ignition controller app.

Status
Not open for further replies.

john2020

Full Member level 5
Joined
Nov 13, 2005
Messages
292
Helped
12
Reputation
24
Reaction score
8
Trophy points
1,298
Activity points
4,911
Real time app problem

Hi all,

I am using the Infineon C167 Microcontroller with Keil Environment for an Ignition Controller application. I capture positive transition of the input signal at the CapCom unit and generate, service the interrupt to set a port(port 2) high. The code which I have written in a function call from the ISR is a few simple switch case statements and some floating point calculations. But the time taken between getting a positive transition at the input and the setting of the port is nearly 700 us. Even accounting for the interrupt latency it is very large and it is above the tolerance limit for our Ignition controller. Can someone pl explain why it takes such a long time?? I checked the clock speed(20 MHz) and I have optimized the compiler to level 7.

Thanks for your time
john
 

Re: Real time app problem

If you can try to write (not re-write) the code in straight assembly ..
Some compilers are not very good as far as speed is concerned ..
Regards,
IanP
It is amazing that people will spend lots of money to buy a machine slightly faster than the one they own, but they won't spend any extra time writing their code in assembly so it runs faster on the same hardware. There are many raging debates about the speed of machines versus the speed of the software, but one fact remains: users always want more speed. On any given machine, the fastest possible programs will be written in assembly language.
 

Re: Real time app problem

I guess your problem is "some floating point calculations".
Certainly do you work with an ICE so you can make a trace. Look at your trace and the time, which is need for your "some floating point calculations" ;-).

Try to change your code in integer calculation. It's faster.

Gomez
 

Re: Real time app problem

hi IanP

thankyou for your reply.i will try write code in assembly.can you suggest me which is the best compiler for real time application?i am not sure about,whether its some floating point calculations thats creating problems here as Gomez has mentioned here.any suggestions?

regards
john
 

Real time app problem

If you dont have ICE debugger it is possible to make simple debug by using one or more GPIO.

Reset all GPIO when you enter ISR
Set GPIO at various places in your ISR routines and check negative pulse width on those by scope. That will give you clear execution time wihtout using hardware debugger .

Floating operations are deferently lenghty if no FPU unit is implemented in mcu. if you concerned about ISR execution time and if it is possible to postpone floating calculations in non ISR mode - do those calculations outside of ISR.

If you are concerned about floating usage first figure out calculation precision . Try to write your own multiplication and division routes with lookup tables - these are much faster (but opccupies memory). Search in google for those (e.g. "multiplication with lookup table")

Another approach is to use mcu with FPUm implemented or external hardware FPU (if there is such or implemented on another mcu). Try to find heuristic approach to your problem .
 

Real time app problem

i think if you post your isr code here it will be better .
If you can measure execution time by your ICE at various point in ISR code - try to find what code portions does influence execution . The latter is subject for program optimization .
 

Re: Real time app problem

john2020,

Most likely Gomez is right, and your floating point calculations are taking a long time to exacute.

You don't have to have an ICE to find the problem, you could simulate the code in a simulator or trace the assembly through your ISR by hand (not fun).

First thing though I would do is post the ISR code here so we could take a look at it.
Other than that try to convert your isr function to fixed point maths (if possible) and see if the latency is better/good enough.

Maui
 

Re: Real time app problem

john2020 said:
thanks a lot for your valuable suggestion.i have ti find a good ICE now.can you suggest me one to resolve my problem?

Sorry I've thought you'd use an ICE because to work with "ke*il Environment for an Ignition Controller application" sounds like a professional application for me.

To check your code with a scope is a good idea and sufficiently.

john2020 said:
i will try write code in assembly.can you suggest me which is the best compiler for real time application?

That's hardly a problem of your compiler. The ke*il compiler is very excellent and I'm sure the math routines are very good optimized too, but to calc with floating routines need a bit time. What want you make with assembler? To write your own floating point routines in assembler and to hope that would be faster? Forget it. I'm sure that's isn't it what you want really.

My experience says me that the mostly calculations can make with integers and a bit intelligence. Yes thats the spirit of programming. I don't know the C167. Maybe it has a hardware multiply unit and you can use it. Think about it, but it'd be better to post your code here then we'd be more helpful.

Gomez
 

Re: Real time app problem

hi Gomez

For my application i do use an ICE,and am working on Keil environment for Ignition controller application.but problem lies in calculating the floating point routines.i mean to ask you,whether i could use any other ICE which suites best for my application?

regards
john
 

Re: Real time app problem

Unfortunately I can't say your what's the best ICE for your application, because I dosn't work with C167. I've decided to work only with R8C, M16C and M32C yet,(ARM coud be interesting, but these have some bugs inside yet) because these are not so expensive and the support is better for me (I've also never heart, that my clients want like external memory, because it's expensive, it makes a lot of EMC problems and you can't be sure to get this external memory in then years yet).
Anyway for "Real time app" it's important to say exactly which time is needed for these or those functions. So it's certainly a good idea to buy something with enough trace memory. I know that's expensive. For instance I've developed for two years ago with an ICE from Lauterbach (http://www.lauterbach.de) and a H8 controller. These ICE has cost 12.000EUR.
A good ICE cost certainly not under 4000EUR. So you see it isn't a thing, what you want buy every day.
My advise would be to ask Keil. The guys from there know certainly what's the best ICE for your application and with which one they can give the best support for you. Maybe they can also help your with your floating point problems.

Gomez
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top