Is there a reference for porting Arduino examples to Teensy?

Status
Not open for further replies.

Neurogami

Member
I'm trying to get an Adafruit Bluefruit LE UART Friend to work with a Teensy 3.1

I'm attempting the same thing as discussed here: https://forum.pjrc.com/threads/28906-Trouble-porting-Adafruit-nRF51-to-Teensy-3-1

As one might expect, the examples on the Adafruit site all reference Arduino boards.

I ran their example sketch using an Uno, and all worked great, so I thought my next step might be to figure out how the Uno maps to the Teensy.

I'm sure I'm not the only person trying to get Arduino-centric hardware and examples to play nice with a Teensy.

By and large, example code for different hardware from places like Sparkfun or Adafruit explain things in terms of Arduino boards.

Is there a FAQ file or something that describes the ways a Teensy is and is not similar to different Arduino boards?

Is there an Arduino board that is a "close match" for a Teensy?

I see that the Teensy 3 has hardware UART, so I should probably look at Arduino examples that use that (e.g. the Leonardo).

As best I can tell, no Arduino board is using an MK20DX256. But I don't know if that's critical or not for judging compatibility in pin and behavior.

Any assistance in understanding how to translate Arduino examples to working Teensy code is much appreciated.
 
You didn't post any simple sample code showing what you tried . . .

Since the device is UART - Serial - it should work similarly on Teensy. The difference is that may be in nomenclature - where on Teensy Serial is USB and Serial1 [ or 2 or 3 ] are the UART based serial devices.

In following your link I came across my prior post that helped in that case:

https://forum.pjrc.com/threads/28906-Trouble-porting-Adafruit-nRF51-to-Teensy-3-1?p=75529&viewfull=1#post75529

As noted there the Teensy starting faster and be online before other devices are ready so follow my link's link to qBlink sample and get the USB online [Serial()] - maybe add a short delay after that then look to see if the Adafruit hardware is responsive.

For UART use Serial1 and those pins 0 [Rx1] & 1 [Tx1] and as suggested in that link - one side's RX is the other's TX.

Check those things and it should work - post a simple sample showing your work [ per Forum Rule ] if not.
 
Yup, the most common issue is needing to change "Serial" to "Serial1".

Or if you're using an Adafruit example that has SoftwareSerial, either change it to Serial1, or configure it to use the same 2 pins that are a real serial port (eg, pins 0 and 1).
 
You didn't post any simple sample code showing what you tried . . .

I didn't post any code because my questions are not about that specific problem. My question are:

Is there a reference for porting Arduino examples to Teensy?

Is there a FAQ file or something that describes the ways a Teensy is and is not similar to different Arduino boards?

Is there an Arduino board that is a "close match" for a Teensy?

I mentioned a specific problem I was having (and have since solved), but I'm sure other people have other issues, and are in a similar situation: they can find and understand Arduino-centric examples but are unclear on how they map to the Teensy.

I managed to figure out what to do after much Googling and happening upon certain forum posts that mentioned things specific to my problem.

It seems wasteful for people to have to do that every time they have a problem porting an Arduino example to Teensy. I want to know if there's a place that collects such information.
 
Yup, the most common issue is needing to change "Serial" to "Serial1".

Or if you're using an Adafruit example that has SoftwareSerial, either change it to Serial1, or configure it to use the same 2 pins that are a real serial port (eg, pins 0 and 1).

That helps with a specific situation. I'm asking if there is a reference that helps people in other cases of trying to move from Arduino to Teensy.

Is there a reference for porting Arduino examples to Teensy?

There is an FAQ page at https://forum.pjrc.com/faq.php It has a heading that says "Teensy Board FAQ" but there's no link.

Is there a Teensy FAQ someplace? Does it explain the ways the Teensy is (and is not) similar to various Arduino boards?
 
There is a "Teensy Tips and Tricks" post here, collecting some useful info:
https://forum.pjrc.com/threads/25395-Teensy-Quick-Reference-Code-Examples-Tips-and-Tricks

however as far as I know, a specific guide to differences between Arduino (which one?) and Teensy hasn't been done. Maybe you can start such a document. Many of the Arduino libraries http://www.pjrc.com/teensy/td_libs.html work "out of the box", despite the significant hardware differences between the original Atmel AVR-based Arduinos and the ARM based Teensy platforms. Of course, some of them don't, often due to low-level port addressing.
 
There is a "Teensy Tips and Tricks" post here, collecting some useful info:
https://forum.pjrc.com/threads/25395-Teensy-Quick-Reference-Code-Examples-Tips-and-Tricks

Ah! Many thanks. That looks super helpful.

however as far as I know, a specific guide to differences between Arduino (which one?) and Teensy hasn't been done. Maybe you can start such a document. Many of the Arduino libraries http://www.pjrc.com/teensy/td_libs.html work "out of the box", despite the significant hardware differences between the original Atmel AVR-based Arduinos and the ARM based Teensy platforms. Of course, some of them don't, often due to low-level port addressing.

Is there a Teensy/pjrc wiki? Some means for the community to jointly edit content?

It seems unlikely that there is a single Arduino board is "almost just like" the Teensy. However, realizing that a) the Teensy 3 has hardware serial, and b) so does the Leonardo, helped me move along. Having a place to track other such similarities would be nice.

I think it's the sort of thing that requires multiple input (because no one person is likely to encounter all the various ways Teensy boards map or differ from Arduinos).

If there is no wiki I can appreciate that setting one up means Work To Be Done, and I understand why that may not be forthcoming. In which case I can figure out some other way to manage a community editing effort.
 
The precursor to the Wiki was assembling a list of specific topics to seek out topical gems - hopefully all the links above are posted here:

Wiki Coming - Please link worthy posts

Paul did a great deal to make porting the code involve "selecting the board in the Tools menu". Using a specific interface often has examples - but indeed mapping to the ideal Teensy supported LIB takes situational awareness - and often good forum-foo and perhaps follow up post. The leap to that "situational awareness" would be nice if it could be captured in the WiKi.

re p#5: Sounded like you started this after getting stuck with a specific problem . . .

I'm trying to get an Adafruit Bluefruit LE UART Friend to work with a Teensy 3.1

I'm attempting the same thing as discussed here: https://forum.pjrc.com/threads/28906-Trouble-porting-Adafruit-nRF51-to-Teensy-3-1
 
There is allegedly a wiki planned, although it's not clear exactly when. I think Paul S. wants to have one, but it will take setup time and his time is chronically oversubscribed. Others have offered to setup one separately, but he wanted it to integrate with the existing forum.
PJRC needs a couple more full or (better) part time < 30hr/wk people!
(easy for me to say).
 
The precursor to the Wiki was assembling a list of specific topics to seek out topical gems - hopefully all the links above are posted here:

Wiki Coming - Please link worthy posts

Paul did a great deal to make porting the code involve "selecting the board in the Tools menu". Using a specific interface often has examples - but indeed mapping to the ideal Teensy supported LIB takes situational awareness - and often good forum-foo and perhaps follow up post. The leap to that "situational awareness" would be nice if it could be captured in the WiKi.

The situational awareness is the ultimate goal. I try to make notes of things while I'm puzzled because as I get more understanding and experience I forget what was so troubling. Then, if I don't do something for a while, I forget what to do and I'm Googling all over again.


re p#5: Sounded like you started this after getting stuck with a specific problem . . .


Yes. It got me thinking that I'm going to run into similar issues the next time I try to wire up this or that board, and rather than having isolated Q+A in disparate threads it might be nice if the information were collected in one place.

Based on the links posted here that knowledge collection seems to be happening in one for or another. That sort of curation can be a job in itself.
 
Status
Not open for further replies.
Back
Top