Go Down

Topic: Timer interrupt (Read 7610 times) previous topic - next topic

drvlas

Great! You are right!

Say, what are these datasheets for? They repeat the same things about 3 timers, but forget quite a serious details  :-X

Don't want to write a note to Atmel?  ;)

Thank you for a tremendous work! I'll write the result to another (Russian) forum - they also don't know the TRUTH.

My best wishes from Kiev!
/sorry for my English/

drhex

There are more funny things in the datasheet.
E.g. 13.4.4 (page 92) says that all the bits of PINB are read-only, but 13.2.2 (page 77) says you can write to PINB to toggle outputs...

Grumpy_Mike

Quote
There are more funny things in the datasheet.


NO!

Read it again. Yes you can toggle the pins of port B BUT not through the PINB register. that register is only for reading the port pins. PORTB section 13.4.2 shows you the register to use for reading and writing.

drhex

Reading again at 13.2.2 "Toggling the pin"

   Writing a logic one to PINxn toggles the value of PORTxn

Worked fine when testing!

BenF

#19
Jun 28, 2010, 01:41 pm Last Edit: Jun 28, 2010, 01:42 pm by borref Reason: 1
Quote
you can toggle the pins of port B BUT not through the PINB register

Indeed you can and it is also a useful function as you can change the state of a single bit with a single instruction.

Example:
Code: [Select]

 // toggle PB5 output (digital pin 13)
 PINB = _BV(PINB5);


retrolefty

#20
Jun 28, 2010, 06:26 pm Last Edit: Jun 28, 2010, 06:31 pm by retrolefty Reason: 1
Quote
Indeed you can and it is also a useful function as you can change the state of a single bit with a single instruction.


Indeed it is an interesting command. I first learned of this 'trick' over on the AVRfreaks site. A caveat however is that it is limited to 'newer' AVR 8 bit processor chips and not on older ones. Not sure which Arduino compatible processors this would not work with, perhaps the Mega8 ? And of course any direct port access command will limit portablity between the various AVR chip types (168/328 Vs 1280, etc.).

PS: Grumpy, get with the times, things change over time.  ;D
Lefty

Go Up