PDA

View Full Version : Please Post Code & Details In Your Question!



Paul
01-07-2013, 09:07 PM
Please, when asking a technical question, provide enough information for us to help!



Complete Source Code (or a link to the code)

Screenshot or the exact text of any error messages
Which PJRC product you're using
Part numbers of any other chips or modules + links to their info
Wiring details - how exactly have you connected the hardware (a photo's worth 1000 words)
Software setup, Arduino vs C+makefile, running on Windows, Mac or Linux?Versions?
Any other information needed to reproduce the problem.....


Providing enough detailed information to reproduce your problem saves everyone time and greatly increases the odds we'll be able to help you with a useful answer.

If you haven't connected wires or run code yet, please post your question in the Project Guidance (http://forum.pjrc.com/forums/2-Project-Guidance) forum.

CheapB
02-12-2013, 07:09 PM
is there a way -tags or otherwise - to format attached code? If I copy and paste code in it is wrapping long lines and removing indention.

ZTiK.nl
02-12-2013, 07:15 PM
use the [ CODE] and [ /CODE] tags for that.
If you want to see all tags, click on the 'Go Advanced' button below the Quick Reply field :)

Nantonos
02-13-2013, 03:09 AM
Unfortunately the forum software hides the button that inserts code tags, unless you click 'Advanced'. Its the button that looks like this: #

240

PaulStoffregen
02-13-2013, 07:02 AM
You can also attach the file. Click "go advanced" and then it's Manage Attachments below your message. Often when looking at someone's, I load it into vim, so I get familiar syntax highlighting. But the code tags work nicely for small bits of code.

timochi
08-13-2014, 07:04 AM
When I try to run the movie2serial program, it could not load the file. Im not sure if the path I wrote is in the correct format. The fp.avi and the movie2serial is in the same folder already.
I've try both of this but none of them work.

Movie myMovie = new Movie(this, "/tmp/fp.avi");
Movie myMovie = new Movie(this, "fp.avi");

PaulStoffregen
12-10-2014, 10:49 AM
i have question about Analog input ..


You should start a new thread, in the project guidance section, to discuss this in more detail.



can i read analog output 1-5 v with teensy 3.1


The ADC pins are limited to 3.3V max measurement range. You'll need to use resistors or a circuit to reduce the signal to match Teensy's input range.

defragster
04-20-2015, 02:45 AM
Paul: Can the Forum page top rule be a hyper link to this page/post?

https://forum.pjrc.com/threads/15136-Please-Post-Code-amp-Details-In-Your-Question!?p=17615&viewfull=1#post17615

stevech
06-13-2016, 06:48 PM
I'd suggest that the DMA chaining scheme could interleave the bytes: 1st pass does half, second pass does others. But DMA hardware requires address aligned buffers.

jshooks
07-14-2016, 04:01 AM
I am trying to merge two Audio Workshop tutorial sketches together to run the part 3-2 FFT1024 with the part 3-3 Add a TFT Display. I have a breadboard large enough to incorporate the (2.8 in ILI9341 display), audio board and Teensy 3.2 board. Of course, both tutorial sketches work fine by themselves. So I have attached the combined sketches as one file inwhich I commented out the bar drawing in 3-3 as I was just trying to print one of the FFT numbers (leftNumber) to start with instead of the peak1 or peak2 functions. The sketch compiles except at the end it gives the following error (region 'FLASH' overflow by 3768 bytes):

7618

Not sure how to attach/upload the sketch as I am new to this forum, but here is the section I have imported from the 3-3 sketch into the bottom of the FFT sketch along with inserting the necessary TFT setup and include statements in the top part. Is it possible to print to the display as well as the serial port? I have reduced the variable "n" to an integer for the leftNumber, but somehow it is creating a FLASH overflow?

int leftNumber = (int)n; // Change leftNumber to integer of n

if (msecs > 15) {
// if (n.available() {
msecs = 0;
delay(10); // wait for library to parse WAV inf - is this necessary
// float rightNumber = n;
Serial.print(leftNumber);
Serial.print(", ");
// Serial.print(rightNumber);
// Serial.println();

// draw the verticle bars
// int height = n * 240;
// tft.fillRect(60, 280 - height, 40, height, ILI9341_GREEN);
// tft.fillRect(60, 280 - 240, 40, 240 - height, ILI9341_BLACK);
// height = n * 240;
// tft.fillRect(140, 280 - height, 40, height, ILI9341_GREEN);
// tft.fillRect(140, 280 - 240, 40, 240 - height, ILI9341_BLACK);
// a smarter approach would redraw only the changed portion...

// draw numbers underneath each bar
tft.setFont(Arial_14);
tft.fillRect(60, 284, 40, 16, ILI9341_BLACK);
tft.setCursor(60, 284);
tft.print(leftNumber);
// tft.fillRect(140, 284, 40, 16, ILI9341_BLACK);
// tft.setCursor(140, 284);
// tft.print(rightNumber);
}
// }
}

defragster
07-14-2016, 06:24 AM
... Not sure how to attach/upload the sketch ...

See post #3 or #4 above for CODE insertion. And see post #7 about creating a new thread ... perhaps there or in "Technical Support & Questions"

PaulStoffregen
07-19-2016, 12:45 PM
The sketch compiles except at the end it gives the following error (region 'FLASH' overflow by 3768 bytes):

This means your program is too large to fit into Teensy's flash memory.

The FFT code uses large lookup tables that consume a lot of flash memory. If you're using the example which plays a guitar sound (can't see all of your code... you didn't follow the Forum Rule... so I'm trying to help with blind guessing), that data for the guitar also consumes a lot of memory. The fonts for the display are also large, if you use any of the larger sizes (again, can only see Arial_14, hard to know if you've got any others).

You need to trim some stuff from your program so it'll fit into Teensy's memory. Especially if you have that guitar sound in your code, deleting that should free up plenty of space.

surajjorwekar
09-22-2016, 12:36 PM
https://forum.pjrc.com/threads/37218-Teensy-3-2-Through-hole-damaged-due-to-bad-soldering
Teensy 3.2 Through-hole damaged due to bad soldering

Arfe frederic
03-15-2017, 11:51 AM
I'm searching for weight, dimensions, voltage & amperage for Teensy 3.1 and 3.5. Would you provide me such info please ?

Theremingenieur
07-28-2017, 09:21 AM
Everything is in the data sheets which you can download from the prjc.com website. Attention: The Teensy 3.1 is discontinued in favor of the more robust 3.2

KurtE
08-14-2017, 02:12 PM
@Paul, @Robin - This thread has been spammed a few times.

Wonder if it would make sense, to edit this thread, and maybe remove most everything except the first posting, where you might merge in a few of the details from other postings, like use the # button to get the code tags, which is now also available on the quick reply....

And then lock it.

tonton81
08-14-2017, 03:31 PM
I vote for bumping this thread all the time, it might help people read it eventually since the static red text is ignored lol :)

jrdlm
04-20-2018, 08:29 AM
Hi! I have written a code in Keil and am using Teensy 3.2 and its audio shield. I am experiencing some issues with regards of getting an acknowledgement signal from the audio shield. Any help would be appreciated. Here is the source code



#include <MK20D7.h>
#include "kinetis.h"

#define SET(x,b) x|=(1UL<<b)
#define CLR(x,b) x=x&(~(1UL<<b))
#define CHK(x,b) (x&(1UL<<b))
#define TOG(x,b) x^=(1UL<<b)
uint16_t ana_ctrl;
uint8_t address = 0x0A;
uint8_t A = 0, A1 = 0x14 ;


#define SGTL5000_I2C_ADDR_CS_LOW 0x0A // CTRL_ADR0_CS pin low (normal configuration)
#define SGTL5000_I2C_ADDR_CS_HIGH 0x2A // CTRL_ADR0_CS pin high

void I2C_Write(int x) ;
void I2C_Read( int y);

volatile uint32_t msTicks; /* counts 1ms timeTicks */


/*----------------------------------------------------------------------------
SysTick_Handler
----------------------------------------------------------------------------*/
void SysTick_Handler(void) {
msTicks++; //increment counter necessary in Delay()//
}


/*------------------------------------------------------------------------------
delays number of tick Systicks (happens every 1 ms)
------------------------------------------------------------------------------*/


__INLINE static void Delay (uint32_t dlyTicks) {
uint32_t curTicks;

curTicks = msTicks;
while ((msTicks - curTicks) < dlyTicks);
}


void delay_us(int xyz)
{
uint16_t MN = 18 * xyz;
for (int mn = 0; mn <= MN; mn++)
{
}
}

long a = 1 , b = 0, c = 0, d = 0;

/*---------------------------LED Configuration------------------------------------*/
void Led_Config(void)
{
SIM -> SCGC5 |= (1UL << 11);
PORTC -> PCR[5] |= (1UL << 8);
PORTC -> PCR[5] |= (1UL << 6);
PTC -> PDDR |= (1UL << 5);
PTC -> PDOR |= 0;
}

void Led_On()
{
PTC -> PDOR |= (1UL << 5);
}


void Led_Off()
{
PTC -> PDOR = 0;

}


/*----------------------------I2C COnfiguration---------------------------------------*/
void I2C_config(void)
{
SIM -> SCGC4 |= (1UL << 6);
SIM -> SCGC5 |= (1UL << 10);

PORTB -> PCR[2] |= (1UL << 9); //SCL Initalize//
PORTB -> PCR[3] |= (1UL << 9); //SDA Initalize//

SET(PORTB -> PCR[2], 1);
SET(PORTB->PCR[3], 1); //Pullup enable//

SET(PORTB -> PCR[2], 0); //Pull select//
SET(PORTB->PCR[3], 0);

SET(PORTB -> PCR[2], 2); //Slew Rate Enable//
SET(PORTB->PCR[3], 2);

SET(PORTB -> PCR[2], 6); //Drive Strength Enable//
SET(PORTB->PCR[3], 6);

SET(PORTB -> PCR[2], 5); //Open Drain Enable//
SET(PORTB->PCR[3], 5);

SET(PORTB->PCR[3], 16); //IRQC at rising edge in SDA//
SET(PORTB->PCR[3], 19);

SET(PORTB->PCR[3], 24);
I2C0_F = 0X13;

}

/*----------------------I2S config-------------------------------*/
void I2S_Config()
{
SET(SIM_SCGC6, 15);
SET(SIM_SCGC5, 11);
SET(PORTC->PCR[6], 10);
SET(PORTC->PCR[6], 9);

SET(PORTC->PCR[6], 1);
SET(PORTC->PCR[6], 5);
SET(PORTC->PCR[6], 6);

I2S0_MCR |= 0x40000000;
I2S0_MDR |= 0x0006327C;
}
/*------------------------------------------Start and Stop Signals-------------------------------------------*/
void StartConfig()
{
SET(PTB -> PDOR, 2);//SCL HIGH//
SET(PTB -> PDOR, 3); //SDA HIGH//
delay_us(100);
CLR(PTB -> PDOR , 3); //SDA LOW//
}

void StopConfig()
{
CLR(PTB -> PDOR, 3); //SDA LOW//
delay_us(100);
SET(PTB -> PDOR, 3); //SDA HIGH//
CLR(PTB -> PDOR, 2);//SCL LOW//
}


void ack()
{
while (CHK(PTB -> PDOR, 3));
}

void I2C_Write(x)
{
I2C0_D = x;
ack();

Delay(10);
while (!CHK(I2C0_S, 1));
while ((CHK(I2C0_S, 0)));
SET(I2C0_S, 1);

}


void I2C_Read(y)
{
y = I2C0_D;
}

void Master_Write( uint8_t data)
{

SET(I2C0_S, 1);
SET(I2C0_S, 4);

I2C0_C1 = 0 ;

SET(I2C0_C1, 6);
SET(I2C0_C1, 7);
SET(I2C0_C1, 4);
SET(I2C0_C1, 5);

StartConfig();

if (CHK(I2C0_C1, 5))
{


I2C0_C1 = 0xF4 ;

Delay(5);

if (CHK(I2C0_S, 5))

{

I2C_Write(A1);
I2C_Write(CHIP_ANA_POWER >> 8);
I2C_Write(CHIP_ANA_POWER);
}

else
{

}

}

}



void write(unsigned int reg, unsigned int val)
{
StartConfig();
SET(I2C0_C1, 5);

Master_Write(reg >> 8);
Master_Write(reg);
Master_Write(val >> 8);
Master_Write(val);

CLR(I2C0_C1, 5);

StopConfig();

Led_On();
Delay(200);
Led_Off();
Delay(100);
}





/*----------------------------------------------Main Program Start-----------------------------------------*/
int main(void)
{
uint16_t ana_ctrl;
SystemCoreClockUpdate(); /* Get Core Clock Frequency */
SysTick_Config(SystemCoreClock / 1000); /* Generate interrupt each 1 ms */
Delay(500);

Led_Config();
I2C_config();
I2S_Config();

Master_Write(0x20);

while (1)
{

}
}


void SGTL_enable()
{


Delay(5);

write(CHIP_ANA_POWER, 0x4060); // VDDD is externally driven with 1.8V
write(CHIP_LINREG_CTRL, 0x006C); // VDDA & VDDIO both over 3.1V
write(CHIP_REF_CTRL, 0x01F2); // VAG=1.575, normal ramp, +12.5% bias current
write(CHIP_LINE_OUT_CTRL, 0x0F22); // LO_VAGCNTRL=1.65V, OUT_CURRENT=0.54mA
write(CHIP_SHORT_CTRL, 0x4446); // allow up to 125mA
write(CHIP_ANA_CTRL, 0x0137); // enable zero cross detectors
write(CHIP_ANA_POWER, 0x40BF); // power up: lineout, hp, adc, dac
write(CHIP_DIG_POWER, 0x0073); // power up all digital stuff
Delay(400);
write(CHIP_LINE_OUT_VOL, 0x1D1D); // default approx 1.3 volts peak-to-peak
write(CHIP_CLK_CTRL, 0x0004); // 44.1 kHz, 256*Fs
write(CHIP_I2S_CTRL, 0x0130); // SCLK=32*Fs, 16bit, I2S format
// default signal routing is ok?
write(CHIP_SSS_CTRL, 0x0000); // ADC->I2S, I2S->DAC
write(CHIP_ADCDAC_CTRL, 0x0000); // disable dac mute
write(CHIP_DAC_VOL, 0x3C3C); // digital gain, 0dB
write(CHIP_ANA_HP_CTRL, 0x0000); // set volume (lowest level)
write(CHIP_ANA_CTRL, 0x0122); // enable zero cross detectors

}

tonton81
04-20-2018, 08:30 AM
ouch! code brackets??? :o

Paul
04-20-2018, 08:36 AM
Easy enough. Edited the post.

@Defragster, KurtE & other "plus" users... please feel free to add code tags if you see these messages. Just add a quick note in the reason for editing field.

PaulStoffregen
04-20-2018, 08:44 AM
I am experiencing some issues with regards of getting an acknowledgement signal from the audio shield. Any help would be appreciated.

Looks like you're implementing I2C with bit bashing the GPIO registers. You probably need to add many more software delays, since the chip is much faster than the rise times of those signals. For example, I see busy loops that wait for the low->high transition and then the instant that slowly rising voltage hits the logic threshold, you do stuff on other pins without any extra delay to allow the signal to keep rising well into the logic high noise margin. That sort of thing might work, but on chips this fast you probably need more delays.

Or you could try using the Wire or i2c_t3 libraries for the I2C hardware. Even if you never intend to run Arduino, you could use the code as a guide to get I2C working reliably (if Keil doesn't provide anything that works?)

https://github.com/PaulStoffregen/Wire/blob/master/WireKinetis.cpp

If you don't go with working I2C code, maybe get a cheap logic analyzer or scope with protocol analysis to view the waveforms. That'll almost certainly show where you're not implementing I2C correctly.

jrdlm
04-21-2018, 01:09 PM
I tried what you suggested but the issue hasn't been solved yet. Is there any other way to get this done? I also checked the cpp file you mentioned and found that I have been doing mostly the same things that you have done there.

KurtE
04-21-2018, 02:08 PM
I tried what you suggested but the issue hasn't been solved yet. Is there any other way to get this done? I also checked the cpp file you mentioned and found that I have been doing mostly the same things that you have done there.
Not sure what you are saying here? Did you try by using the Wire library or i2c_t3? Also mostly doing the same things?

Also might help to know what the issues are... You are not getting the signals? At all? Or only in some specific cases?

P.S. - Wish this was on it's own thread instead of this global sticky thread...

jrdlm
06-21-2018, 11:48 AM
I ran into some problems when I connected the Teensy to a DSO. There was no SCL clock signal generated. Can someone take a look at my I2C initialization and start and stop signal codes and point out any problems with it? Thanks.




Hi! I have written a code in Keil and am using Teensy 3.2 and its audio shield. I am experiencing some issues with regards of getting an acknowledgement signal from the audio shield. Any help would be appreciated. Here is the source code



#include <MK20D7.h>
#include "kinetis.h"

#define SET(x,b) x|=(1UL<<b)
#define CLR(x,b) x=x&(~(1UL<<b))
#define CHK(x,b) (x&(1UL<<b))
#define TOG(x,b) x^=(1UL<<b)
uint16_t ana_ctrl;
uint8_t address = 0x0A;
uint8_t A = 0, A1 = 0x14 ;


#define SGTL5000_I2C_ADDR_CS_LOW 0x0A // CTRL_ADR0_CS pin low (normal configuration)
#define SGTL5000_I2C_ADDR_CS_HIGH 0x2A // CTRL_ADR0_CS pin high

void I2C_Write(int x) ;
void I2C_Read( int y);

volatile uint32_t msTicks; /* counts 1ms timeTicks */


/*----------------------------------------------------------------------------
SysTick_Handler
----------------------------------------------------------------------------*/
void SysTick_Handler(void) {
msTicks++; //increment counter necessary in Delay()//
}


/*------------------------------------------------------------------------------
delays number of tick Systicks (happens every 1 ms)
------------------------------------------------------------------------------*/


__INLINE static void Delay (uint32_t dlyTicks) {
uint32_t curTicks;

curTicks = msTicks;
while ((msTicks - curTicks) < dlyTicks);
}


void delay_us(int xyz)
{
uint16_t MN = 18 * xyz;
for (int mn = 0; mn <= MN; mn++)
{
}
}

long a = 1 , b = 0, c = 0, d = 0;

/*---------------------------LED Configuration------------------------------------*/
void Led_Config(void)
{
SIM -> SCGC5 |= (1UL << 11);
PORTC -> PCR[5] |= (1UL << 8);
PORTC -> PCR[5] |= (1UL << 6);
PTC -> PDDR |= (1UL << 5);
PTC -> PDOR |= 0;
}

void Led_On()
{
PTC -> PDOR |= (1UL << 5);
}


void Led_Off()
{
PTC -> PDOR = 0;

}


/*----------------------------I2C COnfiguration---------------------------------------*/
void I2C_config(void)
{
SIM -> SCGC4 |= (1UL << 6);
SIM -> SCGC5 |= (1UL << 10);

PORTB -> PCR[2] |= (1UL << 9); //SCL Initalize//
PORTB -> PCR[3] |= (1UL << 9); //SDA Initalize//

SET(PORTB -> PCR[2], 1);
SET(PORTB->PCR[3], 1); //Pullup enable//

SET(PORTB -> PCR[2], 0); //Pull select//
SET(PORTB->PCR[3], 0);

SET(PORTB -> PCR[2], 2); //Slew Rate Enable//
SET(PORTB->PCR[3], 2);

SET(PORTB -> PCR[2], 6); //Drive Strength Enable//
SET(PORTB->PCR[3], 6);

SET(PORTB -> PCR[2], 5); //Open Drain Enable//
SET(PORTB->PCR[3], 5);

SET(PORTB->PCR[3], 16); //IRQC at rising edge in SDA//
SET(PORTB->PCR[3], 19);

SET(PORTB->PCR[3], 24);
I2C0_F = 0X13;

}

/*----------------------I2S config-------------------------------*/
void I2S_Config()
{
SET(SIM_SCGC6, 15);
SET(SIM_SCGC5, 11);
SET(PORTC->PCR[6], 10);
SET(PORTC->PCR[6], 9);

SET(PORTC->PCR[6], 1);
SET(PORTC->PCR[6], 5);
SET(PORTC->PCR[6], 6);

I2S0_MCR |= 0x40000000;
I2S0_MDR |= 0x0006327C;
}
/*------------------------------------------Start and Stop Signals-------------------------------------------*/
void StartConfig()
{
SET(PTB -> PDOR, 2);//SCL HIGH//
SET(PTB -> PDOR, 3); //SDA HIGH//
delay_us(100);
CLR(PTB -> PDOR , 3); //SDA LOW//
}

void StopConfig()
{
CLR(PTB -> PDOR, 3); //SDA LOW//
delay_us(100);
SET(PTB -> PDOR, 3); //SDA HIGH//
CLR(PTB -> PDOR, 2);//SCL LOW//
}


void ack()
{
while (CHK(PTB -> PDOR, 3));
}

void I2C_Write(x)
{
I2C0_D = x;
ack();

Delay(10);
while (!CHK(I2C0_S, 1));
while ((CHK(I2C0_S, 0)));
SET(I2C0_S, 1);

}


void I2C_Read(y)
{
y = I2C0_D;
}

void Master_Write( uint8_t data)
{

SET(I2C0_S, 1);
SET(I2C0_S, 4);

I2C0_C1 = 0 ;

SET(I2C0_C1, 6);
SET(I2C0_C1, 7);
SET(I2C0_C1, 4);
SET(I2C0_C1, 5);

StartConfig();

if (CHK(I2C0_C1, 5))
{


I2C0_C1 = 0xF4 ;

Delay(5);

if (CHK(I2C0_S, 5))

{

I2C_Write(A1);
I2C_Write(CHIP_ANA_POWER >> 8);
I2C_Write(CHIP_ANA_POWER);
}

else
{

}

}

}



void write(unsigned int reg, unsigned int val)
{
StartConfig();
SET(I2C0_C1, 5);

Master_Write(reg >> 8);
Master_Write(reg);
Master_Write(val >> 8);
Master_Write(val);

CLR(I2C0_C1, 5);

StopConfig();

Led_On();
Delay(200);
Led_Off();
Delay(100);
}





/*----------------------------------------------Main Program Start-----------------------------------------*/
int main(void)
{
uint16_t ana_ctrl;
SystemCoreClockUpdate(); /* Get Core Clock Frequency */
SysTick_Config(SystemCoreClock / 1000); /* Generate interrupt each 1 ms */
Delay(500);

Led_Config();
I2C_config();
I2S_Config();

Master_Write(0x20);

while (1)
{

}
}


void SGTL_enable()
{


Delay(5);

write(CHIP_ANA_POWER, 0x4060); // VDDD is externally driven with 1.8V
write(CHIP_LINREG_CTRL, 0x006C); // VDDA & VDDIO both over 3.1V
write(CHIP_REF_CTRL, 0x01F2); // VAG=1.575, normal ramp, +12.5% bias current
write(CHIP_LINE_OUT_CTRL, 0x0F22); // LO_VAGCNTRL=1.65V, OUT_CURRENT=0.54mA
write(CHIP_SHORT_CTRL, 0x4446); // allow up to 125mA
write(CHIP_ANA_CTRL, 0x0137); // enable zero cross detectors
write(CHIP_ANA_POWER, 0x40BF); // power up: lineout, hp, adc, dac
write(CHIP_DIG_POWER, 0x0073); // power up all digital stuff
Delay(400);
write(CHIP_LINE_OUT_VOL, 0x1D1D); // default approx 1.3 volts peak-to-peak
write(CHIP_CLK_CTRL, 0x0004); // 44.1 kHz, 256*Fs
write(CHIP_I2S_CTRL, 0x0130); // SCLK=32*Fs, 16bit, I2S format
// default signal routing is ok?
write(CHIP_SSS_CTRL, 0x0000); // ADC->I2S, I2S->DAC
write(CHIP_ADCDAC_CTRL, 0x0000); // disable dac mute
write(CHIP_DAC_VOL, 0x3C3C); // digital gain, 0dB
write(CHIP_ANA_HP_CTRL, 0x0000); // set volume (lowest level)
write(CHIP_ANA_CTRL, 0x0122); // enable zero cross detectors

}

Johnsy
07-26-2019, 12:42 PM
I have a teensy 3.2 and the Octo 2811 hooked up to my visual pinball system. I have a two screen layout. As soon as I connect the teensy to the USB port and I try to run a game on pinball x the b-2s screen opens up but any machine that uses the DMD,for example theater of magic or Addams family, DMD does not come up. Once I disconnect the teensy from the USB port and I restart the tables the DMD shows up again. Any other table that does not have DMD open up fine and the b2s work as it should. What could be the problem. Do you have any suggestions.

isaacng97
11-05-2019, 01:11 AM
Hi, I connect 2 teensy 3.5 to make an spectrum analyzer. An audio board is connected to a master Teensy. I sent 4 bands of FFT to the slave Teensy using Serial TX pin 1. Since the data is in float, i converted it to int and parse it into a string and ended it with \n so that at the slave side I can detect an newline and split the data. However I noticed Teensy will stuck after sometimes. The slave data will be used to control the led array, somehow if i remove the led function, slave teensy will not stuck.


//serial from master
if (Serial1.available()) {
// Serial.println(".");
if (Serial1.read() == '\n') {
int_1 = Serial1.parseInt();
int_2 = Serial1.parseInt();
int_3 = Serial1.parseInt();
int_4 = Serial1.parseInt();
}
}



Master to Slave

//convert float to int for slave
// Serial.println();
int1 = 1000 * myFFT.read(47, 93); //2k to 4k
int2 = 1000 * myFFT.read(94, 186); //4k to 8k
int3 = 1000 * myFFT.read(187, 255); //8k to 11k
int4 = 1000 * myFFT.read(256, 511); //11k to 22k

//send to slave
if (currentMillis - previousMillis_2 > 10) {
// save the last time you blinked the LED
previousMillis_2 = currentMillis;
// Serial.print(int1);
Serial1.print(int1); Serial1.print(",");
Serial1.print(int2); Serial1.print(",");
Serial1.print(int3); Serial1.print(",");
Serial1.print(int4); Serial1.print('\n');
}

TxBillbr
09-25-2020, 11:03 PM
I am a new user at Teensy platform. Have done a number other platforms. I get one shot at programming Teensy 4.0. Using VSCode under Win10(64) with Teensy Loader 1.52. Code compiles, downloads, and reboots Teensy on first try. Any combination of pressing button, power reset, hard-reload to default blink doesn't seem to allow another download. Pressing the button gives dim red LED. Log shows timeout. Code is blink with changed timing. Nothing complex. Am I missing a configuration item? Attached are the first-time log and the second time log.2186121862

defragster
09-25-2020, 11:16 PM
I am a new user at Teensy platform. Have done a number other platforms. I get one shot at programming Teensy 4.0. Using VSCode under Win10(64) with Teensy Loader 1.52. Code compiles, downloads, and reboots Teensy on first try. Any combination of pressing button, power reset, hard-reload to default blink doesn't seem to allow another download. Pressing the button gives dim red LED. Log shows timeout. Code is blink with changed timing. Nothing complex. Am I missing a configuration item? Attached are the first-time log and the second time log.2186121862

Not sure if it helps - but TeensyDuino latest release is ver. 1.53

Also there are existing threads that might have focus on this issue - not recalling the context - but there was a recent post on one time programming as you describe it that may help if you discovered it with Forum search - or Bing or gooGle.

TxBillbr
09-26-2020, 01:58 AM
Apparently Teensy Loader doesn't handle going through an external USB3 hub. Running a short usb cable directly to the system (a huge hassle) makes the Auto function work as advertised.

PaulStoffregen
09-26-2020, 03:37 AM
Not all USB hubs are created equal.

I use Teensy regularly through a USB3 hub which is permanently mounted to the side of my desk. I've also used a few others at times. All worked.

Can you give up the name and model number of this USB3 hub? Or a photo if you don't have any other info?

TxBillbr
09-26-2020, 03:40 PM
Powered "Juiced Systems" 8-port. (Also permanently mounted behind my 30" monitor). This is connected to Gigabyte Aorus B540 MB
21866

defragster
09-26-2020, 08:40 PM
Not all USB hubs are created equal.
...

@Paul - I sent you a USB3 Hub that failed after a T_4.? bootloader update - no idea if it is related as that thread long past - seemed like it was an edge case (Restore or Power On/Off???). If you look to repro that might provide ready reference hardware.

The Replacement USB3 HUB 'Atolla' from AMZN (https://www.amazon.com/gp/product/B07G8CMR18) [ same/similar as used by @KurtE ] has worked without issues for all Teensy one or more at a time - as have all other connect methods hubs used here on Win 10 - using IDE and IDE w/TyCommander - not VSCode.

TxBillbr
09-26-2020, 10:10 PM
@Paul and @defragster, thanks for the info. I have a temporary workaround that works great and will do some hub investigation. I'm just happy to be getting to work on my project instead of wrestling the workflow.

sshari.ind@gmail.com
01-08-2021, 08:20 AM
Where can I get the Teensy 4.0 bootloader.I want to use it for my own project.

kd5rxt-mark
01-08-2021, 02:57 PM
Where can I get the Teensy 4.0 bootloader.I want to use it for my own project.

Discussion of Teensy 4.x bootloader <here (https://forum.pjrc.com/threads/57132-Bootloader-Chip-For-Teensy-4-0?p=211811&viewfull=1#post211811)>.

Mark J Culross
KD5RXT