Pages: 1 [2]   Go Down
Author Topic: Timer interrupt  (Read 6727 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 28
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?  smiley-wink

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/
Logged

Knivsta,Sweden
Offline Offline
Sr. Member
****
Karma: 0
Posts: 274
Low level's cool
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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...
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 596
Posts: 33271
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Knivsta,Sweden
Offline Offline
Sr. Member
****
Karma: 0
Posts: 274
Low level's cool
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Reading again at 13.2.2 "Toggling the pin"

   Writing a logic one to PINxn toggles the value of PORTxn

Worked fine when testing!
Logged

Offline Offline
Edison Member
*
Karma: 3
Posts: 1001
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
 // toggle PB5 output (digital pin 13)
  PINB = _BV(PINB5);
« Last Edit: June 28, 2010, 06:42:11 am by borref » Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17253
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
« Last Edit: June 28, 2010, 11:31:34 am by retrolefty » Logged

Pages: 1 [2]   Go Up
Jump to: