PDA

View Full Version : [Question(s)] Need a foothold with atmega2561(cm-510)



SvenStrikesBack
01-27-2011, 08:57 AM
Well, I suppose I should start from the beginning. I am a senior in high school, aspiring to work in computer science, and about a year ago I had convinced the network/programming teacher at our school to purchase a robot. We quickly located the Bioloid Premium found a grant and voila! It was on our doorstep before you knew it. After a little frustration with the assembly manual I managed to piece together a working type A! SO many cool things it can do... for a day or two. Took it apart, blah blah blah, started working with R+ Task. Very simple, easy to use and worked.. well, kinda. R+ Task wasn't going to cut it, since I had a decent amount of knowledge with C++, I figured I could take on programming it with C no problem, right? Well no, I quickly found out how difficult it was to find even the correct libraries and compiler and gave up. The robot has been shelved up until about a month ago. I am a bit smarter now right? No problem. After a long frustrating night I FINALLY managed to get a hold of WinAVR and WinAVR Studio. Perfect! After reinstalling a few times and changing out of the dreaded (x86) directory it was all working. Even managed to compile the Robotis sample code. So the next day comes along and it is time for round two. After realized how much was involved in this once I downloaded the arbotiX zip with the includes and libraries I decided that the best way for me to get a firm grip on the concepts would be to write my own headers. My own functions, to help me understand what was REALLY going on rather than arbitrarily calling functions. I got a light to blink, all by myself! But now to control it with a button. I know this is getting long and old but here is the main deal. I cannot find enough good documentation to figure out how to set pins/ports to input/output. I have been up literally all night trying to figure it out and have seen at least three methods of doing so.

DDRC = 0x7F;
DDRC = 0b00000001;
DDRC|=_BV(1);
Almost every resource I come to assumes knowledge of programming on this platform, of which I do not possess. What I need is some help. A tutorial, or simple website with GOOD documentation. Something that will explain the register addresses and such. Explain simple I/O, I feel that once I can get a grip on the methods/functions used in AVR, such as what they are really doing, and WHY. I think once I have this I can finish. I have searched for a thread to help me, searched the almighty Google, and simply come up sleep deprived. If I have missed something I sincerely apologize. Thank you in advance, I am hellbent on this project.

Thanks, The Newbie

lnxfergy
01-27-2011, 09:48 AM
You might start with a look at a tutorial that I wrote a while back: http://forums.trossenrobotics.com/tutorials/introduction-129/avr-basics-3261/

That should discuss a bit of the AVR architecture, and does use ''how to set ports'' as an example.

-Fergs

Upgrayd
01-27-2011, 09:55 AM
We do not really have enough info to go on to help you with your specific problem. What exactly is not working? What does your full code look like?

Have you read the datasheets (http://www.atmel.com/dyn/products/product_card.asp?part_id=3631) for the device? That is always the best place to start.

Also worth looking through the avr-libc documentation (http://www.nongnu.org/avr-libc/user-manual/index.html).

SvenStrikesBack
01-27-2011, 11:19 AM
The code I was using were two things that seemed self explanatory but weren't working properly. Once I return home I can post the full code. Tie particular part is ALWAYS returning true. I mainly need help with setting pins/ports for input/output and reading the values
if(bit_is_clear(PIND, 0))