Ran out of space

Hi guys. I am trying to make a circuit for real time parameter optimization. I am wanting to use an optimization technique called levenberg marquardt. The source code is freely available here:
ics.forth.gr/~lourakis/levmar/index.html
I first used codeblocks to write the function I want to optimize and successfully implemented levmar. I then moved it to avrstudio and it successfully compiles there - however I have run out of space on my mega168. I have used these forums before and have found them to be extremely helpful. I was wondering if you could advise me on my options. I have been thinking:
the mega1284 robot controller, larger flash memory and larger ram, however the chip only comes in 40 pin option, if i could do it in 28 pin that would save me re designing the board.
Try to strip down the code of levmar fucntion and see if there is alot of unecessary stuff that I dont need.
Any other ideas?
After compiling, AVRstudio says the program is 83274 bytes and the data is 2642 bytes.
Lastly, currently I have the Pololu robot controller with the mega 8 on and the mega 168 on. I am using the onboard timer which compiles fine for the 1284 and the mega8, however when I switch to mega168 it complains that the onboard timer initiliasation of TIMSK and TCCR0 are undeclared - do these change for the mega168?
Thanks guys

Hello.

I don’t really have too much advice for you beyond what you’ve already considered. From a software standpoint, the easiest solution would probably be to go with the larger AVR, but you might be able to make it work with an ATmega328P if you can rewrite the algorithm to be smaller and use less RAM (which, if possible, would probably cost you either resolution or speed, or both). Have you tried out the different compiler optimizations to see how they affect code size?

The errors you are getting now come from the fact that the ATmega168 has multiple versions of those registers. For example, there are three TCCR0 registers: TCCR0A, TCCR0B, and TCCR0C. Similarly, I think each timer has its own TIMSK register, so you would use TIMSK0 for timer 0, TIMSK1 for timer 1, and TIMSK2 for timer 2. You should look at the datasheet for more information.

- Ben

Hello,

Could you say a bit about why you want to run Levenberg–Marquardt on an AVR? I have a hard time imagining a situation in which that would make sense, so I wonder whether there is a much simpler way to do what you are trying to do, or if you are trying to do something basically impossible. What are you measuring, and what are you going to do with the result?

-Paul

Sorry for late reply. I went and bought a development board with a larger chip. I have man aged to get the code running smoothly on it also. Yeah I have already been asked when you would want a chip to be doing the levenberg calculations, but please bear in mind, I am an engineer really, learning about microcontrollers is a side project. I just want to see at the moment how much i cant port from C in windows to C on a microcontroller. It worked, however as you said it is a bit over kill to have a microcontroller solving this - there are other ways I can do it.
[Resloved]