Teensyduino 1.31 Beta #1 Available

Status
Not open for further replies.
Hi Pete,

I tested the code with Teensy 3.2 with Arduino 1.6.12.

I found GPIOC_PSOR and GPIOC_PCOR works collect, but GPIOD_PDIR does not works .
 
It's been a while since I played around with the pins at the hardware level. I can't remember if Paul had a macro which mapped what you are doing onto the Teensy's 3.2 hardware but the ARM chips have a different way of setting/clearing the port pins than the AVR chips do.
Changing your two macros to this will work:
Code:
#define LED_ON (CORE_PIN13_PORTSET = (1<<5))
#define LED_OFF (CORE_PIN13_PORTCLEAR = (1<<5))

Pete
 
Hi Paul, I've run into issues with Arduino 1.6.12 and TD 1.31-beta1 on Linux x64 when uploading code to a Teensy 3.6. It brings up the TD loader but the IDE errors out after a couple seconds with this (From the terminal the IDE was launched from):

Opening Teensy Loader...

Sketch uses 20,648 bytes (1%) of program storage space. Maximum is 1,048,576 bytes.
Global variables use 3,964 bytes (1%) of dynamic memory, leaving 258,180 bytes for local variables. Maximum is 262,144 bytes.
Opening Teensy Loader...
Unable find Teensy Loader. Is the Teensy Loader application running?
An error occurred while uploading the sketch
Opening Teensy Loader...
Error compiling for board Teensy 3.6.

The loader does appear but it doesn't actually do anything as far as programming the Teensy. If I click the button on the Teensy the loader will correctly program the Teensy with the updated code, it just seems to be a problem communicating between the IDE and loader. Any suggestions?

Thanks-
Larry
 
Do you have any external serial monitor program on USB to the Teensy? If so that needs to be dropped when you compile to upload or the needed communications to the Teensy is blocked from the TeensyLoader and then a button press is required to drop to the bootloader.

The IDE Serial Monitor does this when it is used.
 
Do you have any external serial monitor program on USB to the Teensy? If so that needs to be dropped when you compile to upload or the needed communications to the Teensy is blocked from the TeensyLoader and then a button press is required to drop to the bootloader.

The IDE Serial Monitor does this when it is used.


I assume you mean another program that opens the USB device like minicom; I am not running any other apps that open the serial port and I haven't modified the bootloader, this is just a copy of the Blink sketch I'm using to test with. Is there a particular programmer I should have selected? I just left it as the default: "AVRISP mkII", since there was no Teensy-specific option.

Ok. I've done a little more homework on this and it's a little different than what I was expecting. I should also add that I've moved from running the Arduino IDE remotely over the net (Using X11 remote display) to running it on a local system to avoid any weirdness that might cause.
From what I can tell a fresh, untouched Teensy 3.6 shows up as a raw HID device like /dev/usb/hiddev2 and I have made sure the udev rules were installed from the TD download page. The permissions are correct so opening the device as my user ID is ok. One issue seems to be that there's no way to tell the IDE what port to use (It's grayed out, I expect because there is no /dev/ttyACMx device available). There also seems to be some odd TCP behavior which triggers some messages about syn flooding from the kernel:

Oct 1 05:38:20 acebrix kernel: [27618.756793] TCP: request_sock_TCP: Possible SYN flooding on port 3149. Sending cookies. Check SNMP counters.


The IDE prints these messages:

Opening Teensy Loader...

Sketch uses 16,812 bytes (1%) of program storage space. Maximum is 1,048,576 bytes.
Global variables use 2,496 bytes (0%) of dynamic memory, leaving 259,648 bytes for local variables. Maximum is 262,144 bytes.
An error occurred while uploading the sketch
Error reading Teensy Loader status! (tpc)This error should never happen (when using Arduino). Please report this to paul@pjrc.com, hopefully with enough information to reproduce the problem so it can be understood and fixed!

I'm not clear on whether the kernel messages are also associated with some throttling/blocking behavior and I'll have to look into it further. At any rate it isn't quite a clear-cut as I had hoped. For reference these are the options in the IDE under Tools I have selected:

Board: Teensy 3.6
USB Type: No USB
Port <---- (disabled/grayed out)
CPU Speed: 180 MHz
Programmer: AVRISP mkII


My OS info:

Ubuntu 16.04.1 LTS
Linux acebrix 4.4.0-38-generic #57-Ubuntu SMP Tue Sep 6 15:42:33 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

|Update|
I did some research on what causes the kernel messages and adjusted the kernel values:

net.core.somaxconn (to 2048)
net.ipv4.tcp_max_syn_backlog (to 2048)

This eliminates the messages about syn flooding from the kernel, however the error from TD about TCP problems remains and it doesn't have any effect on the core issue.
|/end update|


Thanks-
Larry
 
Last edited:
I assume you mean another program that opens the USB device like minicom; I am not running any other apps that open the serial port and I haven't modified the bootloader, this is just a copy of the Blink sketch I'm using to test with. Is there a particular programmer I should have selected? I just left it as the default: "AVRISP mkII", since there was no Teensy-specific option.

I never worried about programmer, so I just ckecked my Arduino/TD setup and the programmer is set to ArduinoISP.
You could try this one
 
AFAIK :: The programmer selection is ignored on Teensy as TeensyLoader (teensy.exe) is hardcoded during install.

Indeed 'another program that opens the USB device like minicom' is what I meant. Perhaps you should try that - supposing the Teensy is running a sketch that prints USB output and make sure you have "Tools /USB Type / Serial" selected - like this sketch here :: Can-t-communicate-with-Teensy-3-2-through-Teensyduino?

I'm on Windows - there may be something else in that post that might help you.
 
I never worried about programmer, so I just ckecked my Arduino/TD setup and the programmer is set to ArduinoISP.
You could try this one

Thanks for the suggestion, unfortunately it looks like it ignores which programmer you're using and behaves the same way regardless.
 
Larry: This is your problem. It takes USB coded into the Teensy sketch to respond to the Program request, with No USB the button is required to get its attention:

Board: Teensy 3.6
USB Type: No USB
 
Larry: This is your problem. It takes USB coded into the Teensy sketch to respond to the Program request, with No USB the button is required to get its attention:

Ok, thanks for the info! Is there a particular value I should choose? I thought that was only for sketches that did specific things as a USB device.
 
I typically use the "Serial" - it allows information/debugging spew to come out. That is the default. Unless you run out of room - not that it is large (though it does create some RAM buffers)- it is always safe to just have resident. If you don't send or receive anything it will sit idle, and if you do send or receive it is DMA controlled and faster than most any other interface on the Teensy with low overhead thanks to the DMA- except the new SDIO 4 bit parallel hardware to read/write from a fast enough card.
 
I typically use the "Serial" - it allows information/debugging spew to come out. That is the default. Unless you run out of room - not that it is large - it is always safe to just have resident. If you don't send or receive anything it will sit idle, and if you do send or receive it is DMA controlled and faster than most any other interface on the Teensy with low overhead thanks to the DMA- except the new SDIO 4 bit parallel hardware to read/write from a fast enough card.


Ok, I went ahead and chose Serial and this allows it to present the ACM device /dev/ttyACM0 after programming, which allows me to select that as the port to talk to the Teensy with. Unfortunately it still doesn't help to get it to program the Teensy automatically, I get the "report this error message" every time I restart the IDE and try uploading the blink sketch:

Opening Teensy Loader...

Sketch uses 20,648 bytes (1%) of program storage space. Maximum is 1,048,576 bytes.
Global variables use 3,964 bytes (1%) of dynamic memory, leaving 258,180 bytes for local variables. Maximum is 262,144 bytes.
An error occurred while uploading the sketch
Error reading Teensy Loader status! (tpc)This error should never happen (when using Arduino). Please report this to paul@pjrc.com, hopefully with enough information to reproduce the problem so it can be understood and fixed!
 
Which Linux distro is this?

Localhost networking is used between the utilities Arduino runs and the Teensy Loader program. This is the first time I've ever heard of it failing on Linux. We get this sometimes with zonealarm on Windows, where it prevents local host communication.

Teensy Losder has a Verbose Info window under its help menu. Try looking at that. It should print info about the requests coming from Arduino.

Maybe try on Ubuntu (the only Linux which I actually test and support), or use Mac or Windows for comparison. If you can see a working setup, you'll get a good idea of what that verbose info is supposed to be when things work.

I'm really curious what's wrong on this Linux system. Usually Linux problems are things like missing libs and udev rules.
 
Hi Paul, I'm actually running Ubuntu 16.04.1 LTS (x86-64), so that shouldn't be an issue. The Teensy loader freezes up when it's started from the Arduino IDE; if I click the button on the Teensy it will go through the steps of programming it, but it doesn't respond to keyboard/mouse input. I was just playing around with it and it seems to buffer the keys/clicks until it programs the Teensy, where it will then process them before going back into that frozen, unresponsive state. After using the Teensy button to force it to reprogram the same file over and over I managed to get the logs saved to a file, which I have attached, hope that may help.

I've used other Teensy 3.1 boards before so it isn't so much a new environment, it just doesn't work currently. I've previously installed your udev rules and don't see anything that would tend to point towards missing libraries/dependencies.

|Update|
I've tried launching the loader without the Arduino IDE and it seems to be acting the same way-- by default when launched it freezes and doesn't respond to keys/clicks. Clicking the button on the Teensy "wakes" it up and it becomes responsive until an action is selected. I've included a second log from the console output that I've annotated to show what happens at what point.

I've also noticed a rather odd behavior that occurs while the loader is running: it will suddenly grab focus and acts like I'm trying to move it (a 4-way arrow mouse pointer appears). This happens every couple minutes but I'm not sure what's going on since no messages are logged-- very strange. I'm using KDE as my desktop by the way; I tried it with MATE and the behavior is identical.



Thanks-
Larry
 

Attachments

  • teensy_log.txt
    44.9 KB · Views: 289
  • teensy_log2.txt
    2.9 KB · Views: 324
Last edited:
Any chance you could try it with the default unity desktop? Or with gnome.

Honestly, I have never tested it (or any software I've written) with KDE.
 
When you say the software is unresponsive to clicks, can you be more specific about exactly what you're clicking?

Most of the time, the toolbar icons are disabled, so only a coulpe places are supposed to be responsive under most normal conditions. The new file icon (a document icon with purple hue) is always supposed to be enabled. When you click it, a file open dialog is supposed to appear, to let you open a different hex file. Normally with Arduino this is never needed, since Arduino automatically tells it to open the most recently compiled file.

Anyway, the point is to establish if the gui really is frozen, or if it merely appears that way because most of the controls are not enabled when no Teensy is connected *and* in programming mode.
 
Question about how to set the FTM

I am learning about how to use the FTM. Unfortunately, I could not find the way to capturing
the counter value from FTM0_CH0/CH1. The counter itself works correct, but the value of
FTM0_C0V/C1V are always zero.

Is there anybody konw how to use the ALT4 pins in the correct way?


/* FTM Capture Test */

#define LED 13 // LED on D13
#define LED_ON (CORE_PIN13_PORTSET = (1<<5))
#define LED_OFF (CORE_PIN13_PORTCLEAR = (1<<5))

#define buttonPin01 5 // Button Pin on D5
#define buttonState (CORE_PIN5_PINREG & (1<<7))
#define buttonMask (CORE_PIN5_BITMASK = (1<<7))

#define statePin01 22 //
#define statePin02 23 //
#define PC_STATE1 (CORE_PIN22_PINREG & (1<<1))
#define PC_STATE2 (CORE_PIN23_PINREG & (1<<2))

uint8_t state1 = 0;
volatile int state = LOW;
uint16_t readCount1 = 0;
uint16_t readCount2 = 0;

void setup() {
FTM0_FILTER = 0x07;
FTM0_MODE = 0x05;

FTM0_SC = 0x00; // Set zero
FTM0_CNT = 0x0000; // Reset the count to zero
FTM0_MOD = 0xFFFF; // max modulus = 65535
FTM0_SC = 0x0A; // TOF=0 TOIE=0 CPWMS=0 CLKS=01 PS=010 (divide by 4)
FTM0_CNTIN = 0;

FTM0_C0SC = 0x48; // CHF=0 CHIE=1 MSB=0 MSA=0 ELSB=1 (input capture) ELSA=0 DMA=0
FTM0_C1SC = 0x48; // CHF=0 CHIE=0 MSB=0 MSA=0 ELSB=1 (input capture) ELSA=0 DMA=0

NVIC_ENABLE_IRQ(IRQ_FTM0);

CORE_PIN22_CONFIG = PORT_PCR_MUX(4);
CORE_PIN23_CONFIG = PORT_PCR_MUX(4);

Serial.begin(115200);

pinMode(LED, OUTPUT);
pinMode(buttonPin01, INPUT_PULLDOWN);
pinMode(statePin01, INPUT_PULLDOWN);

attachInterrupt(buttonPin01, blink, HIGH);
attachInterrupt(statePin01, count, RISING);
}

void loop() {
state1 = buttonState;
if(state1 == LOW) {LED_OFF;}
else {LED_ON;};
}

void blink() {
LED_ON ; // turn the LED on (HIGH is the voltage level)
delay(100); // wait for a second
LED_OFF ; // turn the LED off by making the voltage LOW
delay(100); // wait for a second

readCount2 = FTM0_C1V;
Serial.println(readCount2);
}

void count(){
LED_ON ; // turn the LED on (HIGH is the voltage level)
delay(100); // wait for a second
LED_OFF ; // turn the LED off by making the voltage LOW
delay(100); // wait for a second
readCount1 = FTM0_CNT;
Serial.println(readCount1);
}
 
Status
Not open for further replies.
Back
Top