ATMEGA64 I/O access

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

Dear all,

I am using ATMEGA64A controller for my project and i am trying to access the port A and port C for I/O action. If am am trying to set the output of the PORTA and PORTC to logic '1' the port is not accepting the whatever data i am sending to the port. The PORTA and PORTC are multiplexed with External Memory address bits. 

I have not used any external pull ups fort the PORTA and PORTC.

Please suggest what resistors i have to access to make the PORTA and PORTC as I/O port.

I used DDRA and DDRC for defining it as the output port.

 

edit: moved to correct forum.

 

Last Edited: Fri. Feb 17, 2017 - 12:27 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Are you saying you have enabled the XMEM interface - once you do the CPU will take control of the address and data lines - you won't be able to use them as GPIO.

 

If, on the other hand you are just trying to use the IO lines then show the code. You have set DDRA and DDRC so the pins are actually outputs haven't you?

 

Also, since you mention mega64, you have switched it out of M103C mode haven't you?

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

Dear clawson,

 

Thank you for the reply.

 

I have not enabled the XMEM Interface.

 

I have not switched it out of the M103 mode. Please let me know how to do it.

 

My code is

 

void main(){

           DDRA=0xFF;

           DDRC=0xFF;

 

           PORTA=0xFF;

          PORTC=0xFF;

          while(1);

}

}

 

 

 

 

 

 

 

 

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

shindehari32 wrote:
I have not switched it out of the M103 mode. Please let me know how to do it.

What do you find when you search the datasheet for "m103"?

 

The ATmega64A is a highly complex microcontroller where the number of I/O locations supersedes the 64 I/O location reserved in the AVR instruction set. To ensure backward compatibility
with the ATmega103, all I/O locations present in ATmega103 have the same location in
ATmega64A. Most additional I/O locations are added in an Extended I/O space starting from
0x60 to 0xFF (i.e., in the ATmega103 internal RAM space). These location can be reached by
using LD/LDS/LDD and ST/STS/STD instructions only, not by using IN and OUT instructions.
The relocation of the internal RAM space may still be a problem for ATmega103 users. Also, the
increased number of Interrupt Vectors might be a problem if the code uses absolute addresses.
To solve these problems, an ATmega103 compatibility mode can be selected by programming
the fuse
M103C.
In this mode, none of the functions in the Extended I/O space are in use, so the
internal RAM is located as in ATmega103. Also, the extended Interrupt Vectors are removed.
 

2.2.1 ATmega103 Compatibility Mode
By programming the M103C Fuse, the ATmega64A will be compatible with the ATmega103
regards to RAM, I/O pins and Interrupt Vectors as described above. However, some new features in ATmega64A are not available in this compatibility mode, these features are listed below:
...

Table 27-3. Extended Fuse Byte

Fuse Low Byte Bit no Description Default Value
7 1
6 1
5 1
4 1
3 1
2 1
M103C(1) 1 ATmega103 compatibility mode 0 (programmed)
WDTON(2) 0 Watchdog Timer always on 1 (unprogrammed)

 

 Note the default value...

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

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

 I have verified the extended fuse byte using the below command

 

avrdude -p atmega16 -P usb -c usbasp -U lfuse:w:0xFD:m 

 

Please suggest me, am i doing it properly. 

 

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

Sorry it is as below

 

avrdude -p atmega64 -P usb -c usbasp -U efuse:w:0xFD:m 

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

Well this is what the datasheet says about M103C mode:

 

 

The datasheet also says that the M103 fuse is programmed by default.

 

HOWEVER when you look at the list of how the mega103 is different to the mega64 while it does mention "Port C is output only" I don't actually see anything there that might explain why your very simple code wouldn't work just as well for a mega103 as a mega64 even if you built it telling Studio it was mega64 you are using.

 

But I guess you should try changing the state of the M103C fuse anyway and see if it "fixes things".

 

To do that you will use your ISP programmer. When you do you must be VERY careful about how the fuse bits are set. There are some that can make it very difficult to contact the chip!

 

Now the datasheet will tell you that "M103C" is bit 1 of the "Extended Fuse byte. The only other active bit in that byte is "WDTON". Don't change that one! And don't change anything in the "Low" or "High" fuse bytes either.