could not declare DDR in Attiny816

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

This is my code

#ifndef F_CPU
#define F_CPU 16000000UL 
#endif

#include <avr/io.h>
#include <util/delay.h>

int main(void)
{
    DDRA = 0xFF; 
    //while(1) 
    //{
        //PORTA = 0xFF; 
        //_delay_ms(1000); 
        //PORTA= 0x00; 
        //_delay_ms(1000);
    //}
}

 

When I use 2313 It is working but when I change to Attiny816 I get this error like this

 

recipe for target 'main.o' failed 

  'DDRA' undeclared (first use in this function)

  each undeclared identifier is reported only once for each function it appears in    GccApplication1

 

Please help whats wrong.

Thanks.

  

I am new to this. 

 

 

This topic has a solution.

nameat

Last Edited: Tue. May 10, 2022 - 03:58 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Welcome to the freaks!

 

This happens when moving to the newer parts.

What does the datasheet tell you about setting the ports----did you take a look yet?  Skim over the entire datasheet so you can see what it has to offer!  The short summary datasheet is also handy in this regard, but gives no specifics on setting up the part.

 

It is completely different (full datasheet, section 16)

 

To use pin number n as an output, write bit n of the PORTx.DIR register to ‘1’

 

https://ww1.microchip.com/downlo...

 

 

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

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

If you want to program like a 2313 use VPORT that way you still have the original bit handling. 

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

:: Morten

 

(yes, I work for Microchip, yes, I do this in my spare time, now stop sending PMs)

 

The postings on this site are my own and do not represent Microchip’s positions, strategies, or opinions.

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

 

FF = PI > S.E.T

 

This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
     DDRA = 0xFF; 

This will need to be one of the following:

 

  VPORTA.DIR = 0xFF;  // preferred: register in IO space
  PORTA.DIR = 0xFF;   // slower: register is in memory space.

  VPORTA_DIR = 0xFF;  // legacy (non-structure) definitions
  PORTA_DIR = 0xFF;

 

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

Hallo,

 

ich habe in "avr/io.h" mal reingeschaut und dein Mikrocontroller "ATtiny816" ist nicht auf der Liste.

 

Grüße

Patrick Dreger

 

------------------------ English ------------------------------

 

Hello,

 

I have looked into "avr/io.h" and your microcontroller "ATtiny816" is not on the list.

 

Greetings

Patrick Dreger

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

Device support for newer parts are moved into DFP (Device Family Pack). This enables us to release and fix device support independent of toolchain releases.
The DFPs are included in the IDE installations and also available at https://packs.download.microchip... (For MPLAB X) and http://packs.download.atmel.com/ (for Microchip Studio).

So, new devices are handled by this magical section of avr/io.h:

#elif defined (__AVR_DEV_LIB_NAME__)
#  define __concat__(a,b) a##b
#  define __header1__(a,b) __concat__(a,b)
#  define __AVR_DEVICE_HEADER__ <avr/__header1__(io,__AVR_DEV_LIB_NAME__).h>
#  include __AVR_DEVICE_HEADER__

In your Studio installation you will find the header file for ATtiny816 here: C:\Program Files (x86)\Atmel\Studio\7.0\packs\atmel\ATtiny_DFP\<version-number>\include\avr\iotn816.h

Last Edited: Thu. Jun 2, 2022 - 08:44 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

patrick_cpp wrote:

I have looked into "avr/io.h" and your microcontroller "ATtiny816" is not on the list.

It is supported only via the Atmel Packs Framework.

 

Oh - Beaten to the answer by a Microchip Man.

 

Last Edited: Thu. Jun 2, 2022 - 09:25 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

N.Winterbottom wrote:

Oh - Beaten to the answer by a Microchip Man.

Don't feel too beat up about it ;-)

 

I might add that the DFPs for MPLAB X are located at C:\Program Files\Microchip\MPLABX\<version-number>\packs\Microchip\ (DFPs included in the MPLAB X installation. Only seen by this MPLAB X installation) and %userprofile%\.mchp_packs\Microchip\ (DFPs installed through the PackManager in the IDE. Seen by all MPLAB X installations.).

 

Similar locations on Linux.