Skip to content
Alden Hart edited this page Dec 21, 2013 · 7 revisions

##Setting up Winavr in AVRStudio4 The current extruderfin uses an Atmel atmega328p (Arduino Uno chip), so set up the project accordingly. It runs an 8 MHz internal oscillator.

###Set up Floating Point Printfs You will need to set up the project configs like so. Of particular importance is including the floating point libs so the numeric displays will function properly.

In the Custom Options section, the custom compilation [All files] tab should read:
-gdwarf-2 
-std=gnu99
-Wall
-DF_CPU=32000000UL
-Os
-funsigned-char
-funsigned-bitfields
-fpack-struct
-fshort-enums

In the [Linker options] section if must read:   (Note: may need to scroll left window to the end)
-Wl,-u,vfprintf
-lprintf_flt
-lm

That's -W "ell" (not "one") and all other leading 'l's are also "ell"

Here's a useful link: http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&t=117023

###Mappings

I'm not sure these are right but this is what I used

Z:\home\tools\hudson\workspace\avr8-gnu-toolchain\src\avr-lib\libc\stdlib\ --> C:\Program Files\Atmel\Atmel Toolchain\AVR8 GCC\Native\3.4.2.1002\avr8-gnu-toolchain\source\avr\avr-libc
Z:\home\tools\hudson\workspace\avr8-gnu-toolchain\src\avr-lib\libc\include\ --> C:\Program Files\Atmel\Atmel Toolchain\AVR8 GCC\Native\3.4.2.1002\avr8-gnu-toolchain\source\avr\avr-libc
Z:\home\tools\hudson\workspace\avr8-gnu-toolchain\src\avr-lib\libc\stdio\ --> C:\Program Files\Atmel\Atmel Toolchain\AVR8 GCC\Native\3.4.2.1002\avr8-gnu-toolchain\source\avr\avr-libc
Z:\home\tools\hudson\workspace\avr8-gnu-toolchain\avr8-gnu-toolchain-linux_x86_64\libc\gcc\avr\4.5.1\include --> C:\Program Files\Atmel\Atmel Toolchain\AVR8 GCC\Native\3.4.2.1002\avr8-gnu-toolchain\i686-pc-mingw32\avr\include
...stdio --> C:\Program Files\Atmel\Atmel Toolchain\AVR8 GCC\Native\3.4.2.1002\avr8-gnu-toolchain\lib\gcc\avr\4.7.2\avr5
...stdlib --> C:\Program Files\Atmel\Atmel Toolchain\AVR8 GCC\Native\3.4.2.1002\avr8-gnu-toolchain\lib\gcc\avr\4.7.2\avr5

Programming the atmega328p

Fuses

Fuses for the 328 should be this:

Fuse | Studio 4 Value | Notes
-----|-------|---------
BODLEVEL | Brown-out detection disabled | default value
RSTDISBL | unchecked | default value
DWEN | unchecked | default value
SPIEN | checked | with a little red arrow, usually. Can't change this
WDTON | unchecked | default value
EESAVE | unchecked | default value
BOOTSZ | Boot flash size - 2048, starts at $3800
BOOTRST | unchecked | default value
CKDIV8 | unchecked | default value
CKOUT | unchecked | default value
SUT_CKSEL | Int RC Osc. 8MHz; Startup time PWRDWN/RESET: 6CK/14CK + 65 ms 
Clone this wiki locally