0
\$\begingroup\$

So I was trying to write a code to connect an SD card to my atxmega128 . Code is nearly ready but when I want to compile it in Atmel Studio, I get errors about not declaring some codes. Some of the undeclared codes are "PORTD , PORTD_DIR, ... " . Question : Aren't these port codes part of the atmel studio software? Do I need to define some source codes for them ? What should I do to make it work ?

\$\endgroup\$
2
  • \$\begingroup\$ Did you forget to include <avr/io.h>? Are you writing IAR code for the GCC compiler? \$\endgroup\$ Jan 7, 2016 at 8:21
  • \$\begingroup\$ Nope! I didn't forget that. \$\endgroup\$
    – Mike Gh
    Jan 7, 2016 at 8:29

2 Answers 2

0
\$\begingroup\$

These sort of things should be included in avr/io.h, which you should be including at some point. Check to make sure you have

#include <avr/io.h>

in the appropriate locations (top of C files and/or included header files).

\$\endgroup\$
3
  • \$\begingroup\$ I've included io.h and iox128a.h . problem still remains. actually there's nothing about ports and port_dir in these h files. \$\endgroup\$
    – Mike Gh
    Jan 7, 2016 at 8:28
  • \$\begingroup\$ try #include "avr/io.h" \$\endgroup\$
    – kabZX
    Jan 7, 2016 at 8:33
  • 1
    \$\begingroup\$ There is no iox128a.h. Only iox128a1.h, iox128a1u.h, iox128a3.h, iox128a3u.h, and iox128a4u.h. All of these files define PORTD and PORTD_DIR, among many other things. However, you should not have to include anything beyond avr/io.h as this file will automatically include the device-specific file. Are you correctly specifying what the target device is to the compiler? \$\endgroup\$ Jan 7, 2016 at 8:50
0
\$\begingroup\$

If you're using ASF then put an include to asf.h in the header file of the part you're working on. It's the easiest way to fix any of these problems.

#include <asf.h>
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.