Calling ports in Atmel Studio 7, and other questions

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

Hi,

 

First post here, and newbie question to boot, so be prepared for what you've probably been asked a few times over..

 

I've been given a task to use an Atmel ATtiny817 to measure voltages, and output those voltages to the screen like an oscilloscope. I'm a mechanical engineer by schooling, so I have little experience with microcontrollers or programming.

 

Here are my questions.

 

1. I've been looking at sample code for calling ports, and I notice that certain things like "DDRB" which for some people's screens on Youtube turns into a purple font, so that their computer recognizes that name, doesn't read into mine, which makes it a bit tricky trying to borrow code. I'm thinking it could be because I use Atmel Studio 7 (versus 6 or 4), or because my of my microcontroller model. The same things happen for types like "UBRRH" where my computer reads "UBRRH_VALUE"

 

2. I'd like to output the voltages my ATtiny817 gets to the screen, and I have a feeling that Atmel's Data Visualiser is the way to do it. However, I'm not sure how to write any analog input values I read into my serial port, so that they appear in the data visualiser. I'm wondering if there is a library of commands that I can reference which is available on the web, or if it looks like I'm on the right track. Atmel's user guide on the ADV is a bit too technical for me.

 

Thanks for your help.

Last Edited: Fri. May 26, 2017 - 09:12 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I would use an Arduino UNO, it's made for those with little experience with micro's!  It also has a built in plotter function in the IDE(Tools/Serial Plotter). 

Lots of examples on the web to do what you are seeking.

example: www.instructables.com/id/Ultimat...

 

Jim

 

Click Link: Get Free Stock: Retire early! PM for strategy

share.robinhood.com/jamesc3274
get $5 free gold/silver https://www.onegold.com/join/713...

 

 

 

 

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

Are you including <avr/io.h>?  This is where all the port/pin definitions come from.

 

Post your code.

 

Greg Muth

Portland, OR, US

Xplained/Pro/Mini Boards mostly

 

Make Xmega Great Again!

 

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

Hey, ki0bk and Greg_Muth

Thanks for your suggestions. 

I actually do have an Arduino already, and I am using the <avr/io.h> library. I've opted to learn the right way as opposed to frantically looking for immediate solutions to small problems on the internet.. I just received my copy of "Make: AVR Programming" by Elliot Williams (one-day shipping by Amazon on a Saturday!!), so I'm looking forward to the ride! Consider the above problems solved or at least put on hold lol

Last Edited: Sat. May 27, 2017 - 10:05 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

1) DDRB etc are for "old school" tiny and mega AVR chips. 817 is more like an Xmega so direction for B would be PORTB.DIR not DDRB etc. 

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

Okay I see. In that case, would commands like DDRB still work for the 817 and XMegas as long as you import the right libraries? And is there a book or website that you would recommend to reference these newer commands?

 

Thanks

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

The way you program any AVR is to read the datasheet then program the registers / bits you read about there. 

 

Why pick 817? There's a lot more existing stuff on the net for some of the more established models of AVR (mega 328 being perhaps the prime example as it is the CPU at the heart of Arduino) 

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

daisy148 wrote:
commands like DDRB

Note that they are not commands - they are registers.

 

As clawson says, the available registers and their operation are detailed in the datasheet.

 

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...