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.
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 Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net
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.
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.
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.
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
Sorry, I confused this one with:
And thought the OP was talking about assembler.
© 2018 Microchip Technology Inc.