avr mega168 restarting

Go To Last Post
15 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi Guys
Got a 168 here, and just cant for the life of me get libm.a and lib_printf_flt.a to be found and compile - i added a library location and selected them, which cause all manner of issues, and I aded them "absolutely" but that didnt work either.
"undefined reference to __mulhi3 in function vfprintf".
Only want to be able to see values to see if timer is calculating correclty, so converted floats to char arrays for printing - fine.
However after doing the prints it restarts. I think I've prob run out of ram because of the conversion to char arrays, but avrstudio isnt shoing me memory useage - it used to but had to reinstall.
Can anyone tell me how to get this back? (AVS4)
Thanks

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Missing semi-colon line 47.

Seriously - you have 652 posts here - you know how this works.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
Missing semi-colon line 47.

I have absolutely no idea what to make of that.

My problem is AVS4 related not code related I think - or at least the way it communicates with avrDude?

In library options I used to get a list ob libraries available to me - they're gone. If I add the folder AVR/lib in AVR_200.... (AVR GCC) i can see them but adding any of them causes the above error...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You gave some sketchy details

Quote:

i added a library location and selected them, which cause all manner of issues, and I aded them "absolutely" but that didnt work either.

Where did you did you do this? What was the exact result? The correct way to add the libraries in AS4 is within Project configuration you go to the "Libraries" section and make sure libm.a and libprintf_flt.a are copied form left to right pane. Under "Custom Options" you make sure -Wl,-u,-vfprintf is added to the [Link] options.

If you only give wooly details here you only get wooly answers - hence my semi-colon comment.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ahhh.
Sorry, didnt pick up on that.
Yeah I was vague, because thats what I did - I know that doesnt sound logical.
When I go to libraries section there is nothing in the left hand panel.
I add a library location above, to the AVRGCC/AVR/lib folder, and they appear in the left hand side. I add the two to the right hand side, and add those details to the Link Options, and I get:
"undefined reference to __mulhi3 in function vfprintf".

Also how do I get back memory details on build in AVR Studio?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Only want to be able to see values to see if timer is calculating correclty, so converted floats to char arrays for printing - fine.

Do timers output floats?

If they do not, may be you can work around mathematical and floating point printing libraries (you might add errors in conversions and errors managing these libraries)...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thats not the point - my timer outputs an integer which I am dividing by 1000 (ms - S) and casting to a float. The problem though is printing it which requires the above mentioned libraries if I want to use printf.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Have you tried to print a given float (say, 3.14159), leading to a very simple code ?
If your timers work OK, I bet you can print their results as integers and compare with the value you think they have?

Difficult problems are, sometimes, more easily solved when splitted into smaller, simpler ones....

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
Also how do I get back memory details on build in AVR Studio?
Try
Menu-View-Toolbars-Build Output.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

I am dividing by 1000 (ms - S) and casting to a float

Hope you are actually casting to a float THEN dividing by 1000 in fact!

Anyway I think I see the problem. It seems that one of the ways Atmel broke Studio version 4.19 is not just the way in which it doesn't "see" WinAVR but even if you fix that manually it still does not "see" the usual lib*.a files to populate that "add object" dialog in the Libraries screen (what a complete flipping screw up Atmel made!)

OK well having just done a test build for mega168 and then examined the .map file I'm reminded that mega168 is a member of the "avr5" architecture family. So under libraries click the "new" icon for "library search path" and set it to be \WinAVR20100110\avr\lib\avr5. You should then see something like this from which the various lib*.a files can be selected...

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Wow! I didnt realise this went all the way back to Atmel!
OK cool Clawson, I'll give that a try.
Thanks

P.S yeah I have build output selected on the toolbars menu - its not the output view thats the problem, its that its not outputting memory details of the size of my program/ram useage etc.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The downside of this is that it does not automatically pick the right libm.a/libprintf_flt.a and so on. If you now change the project to build for mega48/mega88 instead of mega168/mega328 then you have to remember to change that to "/avr4/" instead of "/avr5/" or library code using CALL/JMP may be used on a processor that only has RCALL/RJMP.

Quote:
I didnt realise this went all the way back to Atmel!

It appears that Atmel deliberately went out of their way to make sure WinAVR would no longer work with AS 4.19. IMAO this is the most childish, spoilt, ill advised thing Atmel have ever done. Sure they might prefer you to use their "toolchain" (though the issue of it they had at the time they did this was unusable!) but how petty was it to actually deliberately break the mechanism that previously would locate and use WinAVR. Atmel went down several steps in my estimation the day this was revealed. In fact I wonder if the US Federal Commission could prosecute them for anti-competitive behaviour?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hmm Maybe they can but that would be a horribly boring case to be a jury on!
Any ideas about this memory stuff I want avrdude to display?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If I want to know the size of portions (text, data, code) of an executable Linux/Cygwin binary, I use "size" (and to remove symbols while not debugging, I use "strip") .
Is there , in the same place as avr-gcc.exe, something like avr-size.exe?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

something like avr-size.exe?

Yes the GCC utility is avr-size.exe. This is another part of what got broken in 4.19. Previously the auto-generated makefile would contain:

avr-size -C --mcu=atmega168 project.elf

and you'd get a display like:

E:\avr\default>avr-size -C --mcu=atmega168 test.elf
AVR Memory Usage
----------------
Device: atmega168

Program:     150 bytes (0.9% Full)
(.text + .data + .bootloader)

Data:         10 bytes (1.0% Full)
(.data + .bss + .noinit)

It's a shame AS4 lacks the pre/post build steps that AS6 now offers otherwise it'd be easy to add an invocation of avr-size as a post (and perhaps pre as well?) build step.