PORTD.OUT Usage scenario

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

How to store the values of any PORT using the OUT keyword?..and compare the values store in them with a another port using variable?

 

Im using atxmega a3bu.

Nitin Shenoy

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

OUT writes to one of the special function registers in low memory space. To get the value of a PORT, you DO NOT use OUT.

 

The rest is left as an exercise for the student. ONE of the things you can do is read the document about the AVR instruction set. For this document, Google is your friend.

 

Jim

 

 

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

Last Edited: Thu. Jan 10, 2019 - 06:23 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Can you tell me how to read the contents of the Port?.. Is it using IN...and i need to know how to compare the lower values if the PORT.. It'll be great if you helped.. Thank you.

Nitin Shenoy

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

Look, YOU can find that out, for yourself, by looking at the instruction set document. Nobody here will tell you such basic information that you can easily find on your own. We DO NOT do student's work for them.

 

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

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

Yes, you can read PORTA.OUT if you want. It holds the value that you wrote to the output driver latch.
If you want to read the input value use PORTA.IN. It reflects the current value on the input pins.
.
In other words PORTA.OUT is the same as a Mega PORTA.
And PORTA.IN is the same as PINA
.
Note that you can access Xmega ports with VPORT registers. The Xmega has impressive port driver speed.
.
David.

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

Key to all this is also PORTA.DIR. You have to set this first. Any 1 bits will be output, any 0 bits will be input. You would tend to read the inputs by checking the relevant bits in PORTA.IN and you would drive any outputs by setting their bits in PORTA.OUT

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

Sorry, I confused this one with:

 

https://www.avrfreaks.net/forum/...

 

And thought the OP was talking about assembler. 

 

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net