Outputting port value on AVR xmega a

Status
Not open for further replies.

RoboWanabe

Member
Hi people i need help.

I'm currently involved in a project where i've got a dip switch connected to a port on the micro and i need to read the value? first id like to just output to console and then in the future it will be the address of a node?

i was wondering if anyone can help me.

So far ive defined the port and tryed to just print the definition to the console but im getting the error invalid initializer ?

IF you are an AVR axmega god can you please keep on eye on this post because i might have alot of questions lol
 
Ive now tryed: char a= DIP_PORT.IN, after setting it to DIP_PORT.DIR =0 ? am i at least on the right track?

Im more used to pic microcontrollers than these
 
On the pic, trising 0 makes it an output not an input... Might be the same on AVR..
 
ive just found out how to do it and lets just say its no way near as easy as the PIC lol. the way its done is all the register are defined and the bits defiend seperatly all over the place in diffrent files so you have to work through them to find out how to do it, where as with the pic its all defined for you, trising is an example.

Apparantly this is much better because it can be moved betweeen micros and other systems alot easier and people can understand it alot easier, say if i decided to die and someone took my place lol

Cheers for the reply anyway ian
 
On a standard atmega it was done in the fashion
Code:
DDRA=0xff; //sets direction to output on the whole port a
char data=PINA; //reads state of port A into the data variable
//you might also want pullups, which is done by seting PORT=0xff; but I am not too sure about that, so consult the datasheet.
 
Last edited:
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…