Forum Rule: Always post complete source code & details to reproduce any issue!
Page 72 of 173 FirstFirst ... 22 62 70 71 72 73 74 82 122 172 ... LastLast
Results 1,776 to 1,800 of 4308

Thread: Teensy 4.0 First Beta Test

  1. #1776
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    5,415
    Quote Originally Posted by PaulStoffregen View Post
    Yes, indeed USB is very complicated. The controllers in this new chip are basically the same as the 2nd port on Teensy 3.6 (where we've only supported host mode, never device mode). It's completely different than the main port on all Teensy 3.x boards. The hardware is far more powerful, but also more complex, and that's all on top of the tremendous complexity of USB in general.

    I'm planning to make some changes from the overall USB stack design from Teenxy 3.x, mainly with how memory is allocated. Most of those design choices were made in 2011-2012 for Teensy 3.0 with only 16K RAM. Those choices also revolve around that controller's hardware operating at the USB token level. Now that we have far more RAM, 20X the bandwidth (480 Mbit vs 12 Mbit), and a controller scheme designed around the USB transfer level, I'm planning to do things differently. The main difference will involve the memory allocation. I want to get away from a shared pool of buffers at the device level. The general idea for 4.x is memory allocated by the interface level code.

    So the code for Teensy 3.x isn't a good road map for how I want this to work on Teensy 4.
    Sounds great, but in the mean time wondering how difficult it would be to at least get some basic Serial.read() code to work... Maybe with just one fixed buffer or... Otherwise I will probably continue to do most of my debug work using HardwareSerial ports...

  2. #1777
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    4,098
    Quote Originally Posted by PaulStoffregen View Post
    Yes, indeed USB is very complicated. The controllers in this new chip are basically the same as the 2nd port on Teensy 3.6 (where we've only supported host mode, never device mode). It's completely different than the main port on all Teensy 3.x boards. The hardware is far more powerful, but also more complex, and that's all on top of the tremendous complexity of USB in general.

    I'm planning to make some changes from the overall USB stack design from Teenxy 3.x, mainly with how memory is allocated. Most of those design choices were made in 2011-2012 for Teensy 3.0 with only 16K RAM. Those choices also revolve around that controller's hardware operating at the USB token level. Now that we have far more RAM, 20X the bandwidth (480 Mbit vs 12 Mbit), and a controller scheme designed around the USB transfer level, I'm planning to do things differently. The main difference will involve the memory allocation. I want to get away from a shared pool of buffers at the device level. The general idea for 4.x is memory allocated by the interface level code.

    So the code for Teensy 3.x isn't a good road map for how I want this to work on Teensy 4.
    After going through usb_serial in the core and looking at chapter 55 I got the impression that there was no way I should not be trying to use T3.x as the a roadmap. The blog was interesting reading as a starting point though. Just from reading the beginning of Chap 55 and section 55.4.2.1, kind of gave me that idea that I should just wait. But it was interesting reading some of this.

    Thanks for the direct link to the USB 2.0 spec. Now I have to figure out to create a an index card database of some sort to keep all the tidbits that I see in this thread.

  3. #1778
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    4,098
    @KurtE
    I found this on HCI: http://affon.narod.ru/BT/bluetooth_app_c10.pdf and this on L2cap: https://lost-contact.mit.edu/afs/nad...luetooth_d.pdf. Both I think are part of the huge Bluetooth specification.

  4. #1779
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    5,415
    Quote Originally Posted by mjs513 View Post
    @KurtE
    I found this on HCI: http://affon.narod.ru/BT/bluetooth_app_c10.pdf and this on L2cap: https://lost-contact.mit.edu/afs/nad...luetooth_d.pdf. Both I think are part of the huge Bluetooth specification.
    I think the version I have is the previous 5.0 document, looks like 5.1 is up there now: https://www.bluetooth.org/docman/han...?doc_id=457080
    Download is from this page: https://www.bluetooth.com/specificat...-specification

  5. #1780
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    9,679
    Quote Originally Posted by Frank B View Post
    I've tested if it compiles, not if it works.. did not expect any problems. So it acts differently without "used" ?
    No, the (used) part seems fine - when it faults it has the code to call - just that it is faulting oddly for some reason. I was using this 'simple' code edited for a forum user to confirm.

    opps: I needed to set up a second set to test on T_3.6 and did not have time to do that when I posted those notes. I have put on another T_3.6 as SerialTerminal {echoboth@1843200baud} and connected to T_3.6 running the code that works using USB Serial.

    Problem was the EchoBoth {updated} was indeed doing "HWSERIAL.println(incomingByte);" on the UART - for each char! - but not the USB - DOH!

    Thanks for confirming Kurt - and for debugging help - it seems to be working fine fixing my problem above - both on T4 and T_3.6.
    Quote Originally Posted by KurtE View Post
    Yes HardwareSerial:eek() is implemented, which is very similar to the read function:
    Code:
    int HardwareSerial::peek(void)
    { // }
    
    int HardwareSerial::read(void)
    { //...}
    Here is the [USB, UART] working code to test number entry with parseFloat - will test this against T4 USB when updated:
    Code:
    #define SER_IN Serial1
    void setup() {
    	SER_IN.begin(1843200);
    	while (!SER_IN && millis() < 4000 );
    	SER_IN.println("\n" __FILE__ " " __DATE__ " " __TIME__);
    }
    
    float val;
    void loop() {
    	SER_IN.print("Enter a number - float if you please = ");
    	while (SER_IN.available() == 0) {}
    	val = SER_IN.parseFloat();
    
    	SER_IN.print("You Entered=");
    	SER_IN.println(val);
    	if ( 13 == SER_IN.peek() ) { SER_IN.read(); SER_IN.println("Ate the C_Return!"); }
    	if ( 10 == SER_IN.peek() ) { SER_IN.read(); SER_IN.println("Ate the NewLine!"); }
    }
    BTW: No IDE use on Windows Compile/Upload/Sermon with SublimeText editor and TyComm for those two sketches to 5 Teensy's of 3 diff types with TSET.
    And for Serial4 T4 debug use as Serial4.begin(1843200); - as noted in EchoBoth::
    Code:
    T:\arduino-1.8.8T4_146\hardware\teensy\avr\cores\teensy4\debugprintf.c :: void printf_debug_init(void)
            // LPUART3_BAUD = LPUART_BAUD_OSR(25) | LPUART_BAUD_SBR(8); // ~115200 baud
        LPUART3_BAUD = LPUART_BAUD_OSR(12) | LPUART_BAUD_SBR(1);  // 1843200 baud

  6. #1781
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    5,679
    LOL Aliee.. ordered a analog to spdif converter to test the spdif-input... got a spdif to analog converter today.

  7. #1782
    Senior Member
    Join Date
    Oct 2012
    Location
    Portland OR
    Posts
    676

    ADC input question: is "keeper" GPIO enabled?

    Just accepted my invite to the T4 Beta1 testers and got the hardware; thanks Paul & Robin!

    I tried measuring a slowly changing voltage using the ADC A0 input. My voltage source was 4300 uF of capacitance charged to 3.3V and then slowing discharging through R=11k to ground. Using 12-bit ADC mode, my code averages together 1000 readings and I also set analogReadAveraging(16). I print out the average and standard deviation for each set of 1000. My code is here: https://github.com/jbeale1/DataAcq/b...nsyADCTest.ino

    Everything worked as expected, except there is one small jump (differential nonlinearity) that is near, but not quite at the midpoint. In the enclosed graph, at sample count 497 the standard deviation of that set of 1000 samples jumped to 6 when all others are near 1.5, and you can see a step-offset around count 2078 in the average value as it slopes down. The exact midpoint would be count 2048 which in this experiment comes 5 samples later, so the jump is not precisely at midpoint.
    Click image for larger version. 

Name:	Screenshot from 2019-02-15 17-15-01.png 
Views:	25 
Size:	93.8 KB 
ID:	15919

    I noticed this note in the IMXRT1050 Reference Manual, p.3141 :
    NOTE The ADC input signals connect to GPIO[0:9]. The GPIO default configuration is enabled for keeper. The keeper causes an undesired jump behavior in ADC. To avoid the problem, disable keeper before starting ADC. For detailed information about keeper, refer to the GPIO block.
    https://www.nxp.com/docs/en/referenc...MXRT1050RM.pdf

    I wonder if this could be related? Apart from that one jump the rest of the transfer curve looks smooth, and the ADC has enough noise that averaging together 1000 samples gets you better than 1 LSB of resolution. (Some ADCs get "stuck" on each value, so averaging together many samples still shows 1-LSB steps on a slow ramp, but that's not the case here.)

    regards, john
    Last edited by JBeale; 02-16-2019 at 02:50 AM.

  8. #1783
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    4,098
    @JBeale

    Not 100% sure that keeper is on by default, To check you can do a Serial.println(CORE_PIN14_PADCONFIG, BIN) and bounce it against the IOMUXC_SW_PAD_CTL_PAD_GPIO_AD_B1_02 register in the RM. About ready to crash for the night so I can check in the morning. As to what is causing the bleep I have to leave that to others to answer.

    Regards
    Mike

  9. #1784
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    4,098
    FLEXCAN IMPLEMENTATION CLOCK AND PIN CONFIG

    tonton81 and I have been fighting flexcan on and off for awhile now and just can't seem to get it working. I can't see any signal on pins 0/1 at all for CAN2. With the settings we are using Pin1 is always at 3.3v and pin 0 is at 0v (really like 1.xxx mv). Not sure the clock source is set right or the pin configs are wrong. Think they are but I had that with the Encoder too. Maybe just need another set of eyes. This is what we are using currently:
    Code:
        //Enable CAN2 Clocks
        CCM_CCGR0 |= CCM_CCGR0_CAN2(CCM_CCGR_ON) | CCM_CCGR0_CAN2_SERIAL(CCM_CCGR_ON); 
        Serial.print("CCM_CCGR0: ");Serial.println(CCM_CCGR0, BIN);
    
    	//Set clock source to 24Mhz with a 0 div
        CCM_CSCMR2 = (CCM_CSCMR2 & 0xFFFFFC03) | CCM_CSCMR2_CAN_CLK_SEL(1) |CCM_CSCMR2_CAN_CLK_PODF(0);
    	
        //rx configure pin for flexcan2, pin0 (AD_B0_03)
        CORE_PIN0_CONFIG = 0x10;					// alt 0 is can2, sion = 1
        IOMUXC_FLEXCAN2_RX_SELECT_INPUT = 0x01;		// set pin for input
    	
        Serial.print("IOMUXC_FLEXCAN2_RX_SELECT_INPUT: ");
    	Serial.println(IOMUXC_FLEXCAN2_RX_SELECT_INPUT, BIN);
      
    	//pin1, can2TX AD_B0_02
        CORE_PIN1_CONFIG = 0x10;
        
    	//Set Control pad configurations.
    	//uint32_t fastio =  IOMUXC_PAD_SRE | IOMUXC_PAD_DSE(3) | IOMUXC_PAD_SPEED(3);
    	CORE_PIN0_PADCONFIG = 0x1A081;
        CORE_PIN1_PADCONFIG = 0x1A081;  //0x1f038, 0x1A081, 0x10B0, other configs tried.
    
        Serial.print("Core PINS: "); Serial.print(CORE_PIN0_CONFIG, BIN);
        Serial.print(", "); Serial.println(CORE_PIN1_CONFIG, BIN);
    Just need a sanity check. Because if it right then it is something with the implementation.

  10. #1785
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    4,098
    CMSIS-NN IMAGE RECOGNITION EXAMPLE
    A while ago I ported over one of the CMSIS Neural Network examples to run on a T3.x using the DSP v5. So I decided to do a little benchmark between the T3.6 and T4 for a CIFAR10 image at this point. The CIFAR10 is a image database:
    Code:
    T3.6 @240 MHz - 334ms
    T4 - 76 ms
    Nice difference.

    EDIT: Here's the link to the post to CMSIS-NN, https://forum.pjrc.com/threads/53809...neural+network and neural networks in general

  11. #1786
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    4,098
    Quote Originally Posted by JBeale View Post
    Just accepted my invite to the T4 Beta1 testers and got the hardware; thanks Paul & Robin!

    I tried measuring a slowly changing voltage using the ADC A0 input. My voltage source was 4300 uF of capacitance charged to 3.3V and then slowing discharging through R=11k to ground. Using 12-bit ADC mode, my code averages together 1000 readings and I also set analogReadAveraging(16). I print out the average and standard deviation for each set of 1000. My code is here: https://github.com/jbeale1/DataAcq/b...nsyADCTest.ino

    Everything worked as expected, except there is one small jump (differential nonlinearity) that is near, but not quite at the midpoint. In the enclosed graph, at sample count 497 the standard deviation of that set of 1000 samples jumped to 6 when all others are near 1.5, and you can see a step-offset around count 2078 in the average value as it slopes down. The exact midpoint would be count 2048 which in this experiment comes 5 samples later, so the jump is not precisely at midpoint.


    I noticed this note in the IMXRT1050 Reference Manual, p.3141 :


    I wonder if this could be related? Apart from that one jump the rest of the transfer curve looks smooth, and the ADC has enough noise that averaging together 1000 samples gets you better than 1 LSB of resolution. (Some ADCs get "stuck" on each value, so averaging together many samples still shows 1-LSB steps on a slow ramp, but that's not the case here.)

    regards, john
    I checked this morning and it looks like keeper is enabled by default. But whats interesting is that you only see it once. To disable in setup is relatively easy:
    Code:
    IOMUXC_SW_PAD_CTL_PAD_GPIO_AD_B1_02 = 0xb0;
    This of course is just for A0.

  12. #1787
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    4,098
    @paul

    I picked up the wrong pogo pins for my breakout board - can you tell which ones you used for you breakout board?

    Thanks
    Mike

  13. #1788
    Senior Member+ manitou's Avatar
    Join Date
    Jan 2013
    Posts
    2,191
    Quote Originally Posted by Frank B View Post
    Added a pull-request for MQS.
    My fork has all new changes: https://github.com/FrankBoesing/Audio

    You can directly add small speakers (8 OHM) with a capacitor in series (I used 100uF) - It is not very loud, but in a quite environment it is ok.
    Maybe one of you electronic-specialists could post a simple amplifier? a one - transistor thing?


    I'm not sure if I have the frequencies right - at least I have one more output working now.
    Thanks Frank. I fetched your copy of Audio lib and tested MQS with 100 uf cap from pin 12 to speaker and generated 440 hz sine wave
    Code:
    // teensy4 mqs  frank's audiolib   pins 10/12 rt/left
    // start monitor to hear sound,  hit key to increase freq
    #include <Audio.h>
    
    // GUItool: begin automatically generated code
    AudioSynthWaveformSine   sine1;          //xy=180,469
    //AudioSynthWaveformSineHires   sine1;
    AudioOutputMQS        mqs1;           //xy=380,468
    AudioConnection          patchCord1(sine1, mqs1);
    // GUItool: end automatically generated code
    
    int freq = 1100;
    
    void setup() {
      Serial.begin(9600);
      while (!Serial);
      Serial.println("Setting up");
    
      AudioMemory(12);
      sine1.amplitude(1.0);
      sine1.frequency(440);
      Serial.println("Send Serial Char to increase freq");
    }
    
    void loop()
    {
    #if 0
      if (Serial.available()) {
        Serial.read();
        sine1.frequency(freq);
        Serial.println(freq);
        freq += 100;
      }
    #endif
    }
    With just scope on pin 12, get 352 khz PWM carrier (duty 17%).

    EDIT: also have WAV to MQS sketch
    Last edited by manitou; 06-08-2019 at 10:54 AM.

  14. #1789
    Senior Member
    Join Date
    Oct 2012
    Location
    Portland OR
    Posts
    676
    Quote Originally Posted by mjs513 View Post
    I checked this morning and it looks like keeper is enabled by default. But whats interesting is that you only see it once. To disable in setup is relatively easy:
    Code:
    IOMUXC_SW_PAD_CTL_PAD_GPIO_AD_B1_02 = 0xb0;
    This of course is just for A0.
    Yes! Thank you, I can confirm that adding this line to my setup removed the glitch around count 2078 that I found earlier. Now when you look at the standard deviation along the curve you see only the typical successive-approximation type fingerprint of the MSB transition at 2048 plus the comb pattern of the next few bits down, but they are smaller. Next question: how to deal with this somewhat obscure "feature" which is unlike other Teensy or Aduino parts I'm familiar with? Not clear if the keeper should be disabled by default, as it is useful to keep power dissipation down when A0 is unconnected or on a high impedance node, and the ADC glitch is subtle enough that many people might not realize it's there unless they test carefully.

    Click image for larger version. 

Name:	T4ADC-NoKeeper.png 
Views:	25 
Size:	142.6 KB 
ID:	15927

  15. #1790
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    4,098
    @JBeale,
    Not sure the best way to handle this. There are a couple of options, maybe put it into the initialization function for ADC, but not sure what that would impact. Don't think it would.

    Anyone reading this - thoughts?

  16. #1791
    Senior Member
    Join Date
    Jul 2014
    Posts
    2,330
    Quote Originally Posted by mjs513 View Post
    I checked this morning and it looks like keeper is enabled by default.
    May I ask the question, what means keeper? what is the equivale circuit? I never saw that in electronics, I was checking equivalent text for the T3.x and I could not find this term.

  17. #1792
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,553
    Quote Originally Posted by WMXZ View Post
    May I ask the question, what means keeper?
    It's like a pullup or pulldown resistor. Unlike a fixed resistor which always pulls towards a particular logic level, it weakly pulls the pin in whatever direction it already happens to be. This is a nice advantage if you want low power consumption, since the keeper's pull resistor only has current flowing during the brief moment when the pin changes logic state.

  18. #1793
    Senior Member
    Join Date
    Oct 2012
    Location
    Portland OR
    Posts
    676
    Quote Originally Posted by WMXZ View Post
    May I ask the question, what means keeper?
    You can use a built-in pullup or pulldown to keep an input from floating near Vdd/2 where MOS gates have excess power dissipation. A "keeper" automatically switches between pullup or pulldown depending if the pin is above or below midpoint. Doing this minimizes power draw either way; the docs say minimum power consumption was a priority in the design of this part. But you don't want such a keeper mechanism active on an analog ADC input, because even a very weak pullup/pulldown current puts a (perhaps small) kink in your transfer curve, unless you drive the pin with a very stiff voltage source.

  19. #1794
    Senior Member
    Join Date
    Jul 2014
    Posts
    2,330
    @Paul and JBeale
    Thanks for clarifying this for me.

  20. #1795
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,553
    Quote Originally Posted by mjs513 View Post
    I picked up the wrong pogo pins for my breakout board - can you tell which ones you used for you breakout board?
    I believe they were this one, 12.5 mm height.

    https://www.aliexpress.com/item/100p...910364279.html

    How many do you need? I have plenty left over. We can send you some on Tuesday (...Monday is one of those minor US federal holiday observed only by the government & banks, so no postal service until Tuesday)

  21. #1796
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    4,098
    Quote Originally Posted by PaulStoffregen View Post
    I believe they were this one, 12.5 mm height.

    https://www.aliexpress.com/item/100p...910364279.html

    How many do you need? I have plenty left over. We can send you some on Tuesday (...Monday is one of those minor US federal holiday observed only by the government & banks, so no postal service until Tuesday)
    Wow. Thanks for the offer. I am only testing USB right now, no underside pins, so maybe about 8 or so. Don't want to push my luck

    I do have a question, if I may. I was reading that a minimum I should have a 120uf cap between 5v and gnd, will that do it. Also, could I use 5v to power the second usb connector to get it off the T4?

  22. #1797
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,553
    Quote Originally Posted by mjs513 View Post
    so maybe about 8 or so. Don't want to push my luck
    I have at least 150 left here, so might as well wish for what you want!


    I do have a question, if I may. I was reading that a minimum I should have a 120uf cap between 5v and gnd, will that do it. Also, could I use 5v to power the second usb connector to get it off the T4?
    Trouble with putting a 120 uF cap on the 5V line is that's 12X over the limit the USB spec says for a USB device.

    On the breakout boards, I used a TPS2055A with it's enable pin connected to VIN. That allows a 100 uF (or larger) capacitor for USB host, but limits the current flow to the cap so it (usually) doesn't cause power problems when running from USB device 5V.


    @defragster - Did you get one of the breakout boards?

  23. #1798
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    9,679
    Quote Originally Posted by PaulStoffregen View Post
    ...
    @defragster - Did you get one of the breakout boards?
    Paul, Yes - I did. Used it to confirm KurtE's Serial #1-#8 work and also minimal USB Host samples run - looking to setup USB_HOST(Bt) to test debug_tt for logging USB_Host events. OH - and I ran some examples on FrankB's early Audio work.
    What's up?

  24. #1799
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    4,098
    Quote Originally Posted by PaulStoffregen View Post
    I have at least 150 left here, so might as well wish for what you want!
    Ok, since you have that many i'll take 36 - thank you - you all are the best.

    Quote Originally Posted by PaulStoffregen View Post
    Trouble with putting a 120 uF cap on the 5V line is that's 12X over the limit the USB spec says for a USB device.

    On the breakout boards, I used a TPS2055A with it's enable pin connected to VIN. That allows a 100 uF (or larger) capacitor for USB host, but limits the current flow to the cap so it (usually) doesn't cause power problems when running from USB device 5V.
    Got it - guess I will go with the TPS2055A for the next revision of the board - and until then - no hot swapping

  25. #1800
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    9,679
    Quick note - just pulled KurtE's WIP2-Bluetooth branch of USBHost_T36 on T4 w/Breakout and it recognized this many years old Joystick:
    *** HID Device joystick[0H] - disconnected ***
    *** Device HID1 - disconnected ***
    *** Device HID1 46d:c20a - connected ***
    manufacturer: Logitech Inc.
    product: WingMan RumblePad
    Claim Additional axis: 0 0 0
    *** HID Device joystick[0H] 46d:c20a - connected ***
    manufacturer: Logitech Inc.
    product: WingMan RumblePad
    *** Device HID1 - disconnected ***
    *** HID Device joystick[0H] - disconnected ***
    9 buttons, slider, 2 joys and 4 way direction all came through.
    It has a 'mode' button that confuses things.

    While there I plugged in the logitech mouse that fails to see the wheel - compiled with USBHOST_PRINT_DEBUG and nothing new came out.
    *** Device HID1 46d:c044 - connected ***
    manufacturer: Logitech
    product: USB-PS/2 Optical Mouse
    *** HID Device Mouse1 46d:c044 - connected ***
    manufacturer: Logitech
    product: USB-PS/2 Optical Mouse
    *** Device HID1 - disconnected ***
    *** HID Device Mouse1 - disconnected ***
    Last edited by defragster; 02-17-2019 at 05:09 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •