Author Topic: Learning to read MCU datasheet  (Read 2464 times)

0 Members and 1 Guest are viewing this topic.

Offline RevlexTopic starter

  • Jr. Member
  • **
  • Posts: 16
  • Helpful? 0
Learning to read MCU datasheet
« on: June 25, 2010, 06:36:55 AM »
Hi people of the SoR!

Recently i started to get interested in electronics and robotics and bought the KIT-09837 from SparkFun witch features a Arduino Duemilanove board with the AtMega 168 MCU PDIP version.

I searched for the datasheet witch is found here: http://www.atmel.com/dyn/resources/prod_documents/doc2545.pdf

My question is:

I understand pin 23 PC0 (ADC0/PCINT8) PDIP is a analog input value but what does PCINT8: Pin Change Interrupt source 8 mean?

greets,

Revlex

Offline waltr

  • Supreme Robot
  • *****
  • Posts: 1,944
  • Helpful? 99
Re: Learning to read MCU datasheet
« Reply #1 on: June 25, 2010, 07:17:27 AM »
Many processors can have one than one function on a pin and which function is used is set-up in either configuration bits or in the code. And have a pin be either analog input or a digital IO is common. It looks like the pin in question can be set-up as wither an analog input or as an digital input that causes an interrupt.
Search the data sheet for PCINT8 the explanation is in there.

Offline RevlexTopic starter

  • Jr. Member
  • **
  • Posts: 16
  • Helpful? 0
Re: Learning to read MCU datasheet
« Reply #2 on: June 25, 2010, 07:25:31 AM »
Thank you walter.
I think im understanding it now, it can be used as some sort of PMW receiver?

Offline KurtEck

  • Robot Overlord
  • ****
  • Posts: 217
  • Helpful? 12
Re: Learning to read MCU datasheet
« Reply #3 on: June 25, 2010, 07:42:43 AM »
Actually the pin interrupt can be used for a variety of things, such as you could use it to trigger an interrupt when someone pushes a button that is connected to the IO pin.

Details about Pin Change interrupts in covered in section 12 of the PDF file you mentioned.  In that section it will describe several IO registers that you can set to change how several of the IO pins on the processor are used.  For example if you look at the register PCMSK1 you will see that bit 0 is used to enable or disable an interrupt on that particular IO pin. Note: there are other registers that need to be set up as well: like bit1 of PCICR...

Also there are other registers that effect how that physical IO pin is used.  If you look in section 13 of the PDF you will find that for PortC many of the pins have alternative functions.  In your case it shows that PC0 can also be used as an Analog pin or a pin change interrupt source. 

Likewise there is more information in section 22 of the pdf on how to use the IO pin as an analog input pin.

Good Luck
Kurt

Offline RevlexTopic starter

  • Jr. Member
  • **
  • Posts: 16
  • Helpful? 0
Re: Learning to read MCU datasheet
« Reply #4 on: June 25, 2010, 08:25:17 AM »
Thank you KurtEck,

Im understanding it now a lil bit better, what i dont get(getting confused in that part) this particular MCU uses byte adresses to get going with the means of hexadcimal values. Do i need to use 8 hex numbers to program 1 I/O pin?

Offline KurtEck

  • Robot Overlord
  • ****
  • Posts: 217
  • Helpful? 12
Re: Learning to read MCU datasheet
« Reply #5 on: June 25, 2010, 12:24:54 PM »
If I understand your question, if you wish to do something to one IO pin do you have to manipulate it through a full byte, the answer is yes and no.

That is each IO pin is associated with an IO port.  Each IO port has up to 8 pins associated with it (some may have less).  So in your example the pin PC0 is saying pin 0 or port C.  And looking at the docs Port C only has actual IO pins on it.

The IO Port C has 3 IO registers associated with it.
PORTC - You can output the value per pin here.
DDRC - Pin directions - Are the pins input or output
PINC - Read in the value of each of the pins.

Now you can set the value of all 8 logical pins at once by doing something like:
PORTC = 0 
That will set all 8 pins to value 0 (off).

But the processor also has bit manipulation instructions that allow you to set/Clear... one specific bit.

Got to run
Kurt

 


data_list