Pages: [1]   Go Down
Author Topic: What pins is PORTB on the Teensy 3.0?  (Read 518 times)
0 Members and 1 Guest are viewing this topic.
Westbrook, CT
Offline Offline
Full Member
***
Karma: 2
Posts: 139
"Why should I bother with made-up games when there are so many real ones going on." (c) Kurt Vonnegut
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi guys, I have a Teensy 3.0 board and the reason for having it is because it has 32bit processor running at 48 MHz which is much more powerful than the one on the regular Arduino's. Not mentioning that it has more memory and other goodies. And it's compatible with the Arduino IDE.

http://www.pjrc.com/store/teensy3.html

Unfortunately the problem is that it's reference info online is limited compared to the one Arduino provides. Now I'm aiming for a project with sound synthesis which I found really cool such as this one. http://little-scale.blogspot.com/2013/05/diy-polyphonic-drum-machine-and-rhythm.html

In the example the guy uses a Teensy 2.0 and I have a Teensy 3.0 board. To Anybody that knows about this board, do you know on what pins the PORTB is on?

Thank you, sorry if this post doesn't belong to the Arduino Website. Just trying to seek for some help  smiley
Logged

Arduino Uno R3
Mac OSX Lion


Offline Offline
Edison Member
*
Karma: 35
Posts: 1429
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

http://forum.pjrc.com/forum.php
would be a better place to ask.

But they are:
0, 1, 16, 17, 18, 19, 25, 32

The code from a Teensy2 will not necessarily be easy to port to a Teensy3. The T3 is not just a bigger T2. It uses a completely different type of chip, an ARM Cortex M4.

Pete
« Last Edit: December 05, 2013, 07:28:34 pm by el_supremo » Logged

Where are the Nick Gammons of yesteryear?

SF Bay Area (USA)
Offline Offline
Tesla Member
***
Karma: 106
Posts: 6378
Strongly opinionated, but not official!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

"PORTB" is an AVR chip thing.  Teensy3 uses an ARM chip, which has GPIOA_PDOR as a "somewhat similar" thing.
Any Arduino code that uses PORTB will require some significant effort to run on a Teensy3 (this is "direct port manipulation", which is "underneath" the Arduino libraries.  Any compatibility between Arduino variants with different CPUs will only be for programs that use the libraries...
Logged

Westbrook, CT
Offline Offline
Full Member
***
Karma: 2
Posts: 139
"Why should I bother with made-up games when there are so many real ones going on." (c) Kurt Vonnegut
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

The code from a Teensy2 will not necessarily be easy to port to a Teensy3. The T3 is not just a bigger T2. It uses a completely different type of chip, an ARM Cortex M4.

That's a good point, but thank you as a start! smiley
Logged

Arduino Uno R3
Mac OSX Lion


Westbrook, CT
Offline Offline
Full Member
***
Karma: 2
Posts: 139
"Why should I bother with made-up games when there are so many real ones going on." (c) Kurt Vonnegut
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

"PORTB" is an AVR chip thing.  Teensy3 uses an ARM chip, which has GPIOA_PDOR as a "somewhat similar" thing.
Any Arduino code that uses PORTB will require some significant effort to run on a Teensy3 (this is "direct port manipulation", which is "underneath" the Arduino libraries.  Any compatibility between Arduino variants with different CPUs will only be for programs that use the libraries...


Thanks for this suggestion! I will certainly do some research on that one!  smiley
Logged

Arduino Uno R3
Mac OSX Lion


Dallas, TX USA
Offline Offline
Edison Member
*
Karma: 47
Posts: 2346
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

"PORTB" is an AVR chip thing.  Teensy3 uses an ARM chip, which has GPIOA_PDOR as a "somewhat similar" thing.
Any Arduino code that uses PORTB will require some significant effort to run on a Teensy3 (this is "direct port manipulation", which is "underneath" the Arduino libraries.  Any compatibility between Arduino variants with different CPUs will only be for programs that use the libraries...


That said, Paul has gone to great lengths to provide some AVR port emulation.
The emulation code will emulate the PORTx/DDRx/PINx registers of the UNO.
The resulting pins controlled with be same Arduino pin # as the corresponding
Arduino pin # in the AVR port register for an Arduino UNO.

i.e.
Code:
PORTB |= 0x2;
will control Arduino pin #9.

While not a true and full emulation of the AVR registers, it may
allow some code to work unmodified.

You can see the code in avr_emulation.h down in the core directory.

--- bill

Logged

SF Bay Area (USA)
Offline Offline
Tesla Member
***
Karma: 106
Posts: 6378
Strongly opinionated, but not official!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Paul has gone to great lengths to provide some AVR port emulation.
The emulation code will emulate the PORTx/DDRx/PINx registers of the UNO.
Really?  Cool; I have some Teensy3s, but I didn't realize that he had done this!
The miracles of C++, I guess; I'll have to take a look at how this was implemented.
Logged

SF Bay Area (USA)
Offline Offline
Tesla Member
***
Karma: 106
Posts: 6378
Strongly opinionated, but not official!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
The emulation code will emulate the PORTx
Hmm.  Does that mean that you can make PORTB be some ARBITRARY set of 8 pins?!
Logged

Dallas, TX USA
Offline Offline
Edison Member
*
Karma: 47
Posts: 2346
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I think so. But the current code seems to hard code the pins in the code.
It also controls each pin seperately.
It has to because of the way the i/o pins have been configured
as most of them are not consecutive bits in the same i/o register.

It would be kind of cool to make a configurable class that allowed
the user the configure the Arduino pin assigned to each bit.

--- bill

Logged

Westbrook, CT
Offline Offline
Full Member
***
Karma: 2
Posts: 139
"Why should I bother with made-up games when there are so many real ones going on." (c) Kurt Vonnegut
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Really?  Cool; I have some Teensy3s, but I didn't realize that he had done this!
The miracles of C++, I guess; I'll have to take a look at how this was implemented.


I found some awesome sources on the pjrc Forum. Check them out if you want to play with PORTs.
http://forum.pjrc.com/threads/23950-Parallel-GPIO-on-Teensy-3-0?highlight=teensy+3.0+PORTB

especially this one:
http://forum.pjrc.com/threads/17532-Tutorial-on-digital-I-O-ATMega-PIN-PORT-DDR-D-B-registers-vs-ARM-GPIO_PDIR-_PDOR
Logged

Arduino Uno R3
Mac OSX Lion


Pages: [1]   Go Up
Jump to: