Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

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
 
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.

Latest threads

New Articles From Microcontroller Tips

Back
Top