Forum Rule: Always post complete source code & details to reproduce any issue!
Page 32 of 41 FirstFirst ... 22 30 31 32 33 34 ... LastLast
Results 776 to 800 of 1017

Thread: Teensy 4.0 First Beta Test

  1. #776
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    5,049
    Ok, I give it a try:

    https://github.com/PaulStoffregen/co...onder?expand=1

    This adds disable() to EventResponder.
    It does two things:
    - adds if (!disabled ) to yield and prevents calling of runFromYield
    - switches to minimal void systick(void) interrupt, without calling the millisTimer.

    I don't think this gets accepted, but if I don't try...

    What do you think, Kurt?

  2. #777
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    3,821
    Quote Originally Posted by defragster View Post
    Kurt - that example shows answers to some questions I had - passing the &Serial# nicely. Will give it a look.

    Question - what is the Rx and Tx connect scheme for the ports?
    Currently T1->r2, t2->R3, t3->r5, t5->r6, t6->r7, t7->R8, T8->R1
    Note I skipped Serial4
    Serial4 I have hooked up to PC with USB to Serial adapter... Currently Adafruit CP2104 version...

  3. #778
    Senior Member+ manitou's Avatar
    Join Date
    Jan 2013
    Posts
    1,789
    I tried 12.5mhz but that didn't work. Will try 4 and 8Mhz as a test then play with delay. May have to dig deeper into what they are doing with SPI in their library. Now to rehook up the BME280 chip.
    Another possible approach would be to compare T3.2 scope of SPI CLK talking to the BME820 to the scope of T4 SPI CLK and see if you can notice gaps or delays that are controlled by CCR.

    Yes, Paul added code for setting SPI CLK, though I didn't know he updated the deprecated setFrequency. The current T4 SPI lib does not have code to set polarity and bit order, so i'm not surprised the deprecated functions haven't been updated. Registers default to Mode0 and MSB which is what most devices use (including BME20). With T4 so fast, it still might be a problem with setting CS, so a delayMicros(10) after CS HIGH and before CS LOW might work, and maybe delays between spixfer() ....

  4. #779
    Senior Member
    Join Date
    Jul 2014
    Location
    New York
    Posts
    2,190
    Kurt -- Tim

    Since SD.h is working decided to hook up my EMIC2 text-2-speech board to the T4 and put a file on the sd card to be played by the EMIC2, figure good verification for both. Anyway, it worked, it found the card, the correct file and played it. I am attaching a recording from my phone (frankly its not a very good recording), need something to do better recordings, just for fun.Voice 001.zip

    I have it hooked up to an amplified speaker so getting some static. I modified the library awhile ago to work with Teensies, don't even know if it would work on a avr board anymore

  5. #780
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    18,981
    Quote Originally Posted by KurtE View Post
    Serial port area: You have 6 pins per Serial port, With RX/TX/GND - Wondering what the other three pin are...
    On the breakout board, the other 3 pins have no connection.

    I supposed I could have used only 3 pin headers and wires, but I used 6 pins with 3 unused so this FTDI cable with a 6 pin socket can plug in.


  6. #781
    Senior Member
    Join Date
    Jul 2014
    Location
    New York
    Posts
    2,190
    Another possible approach would be to compare T3.2 scope of SPI CLK talking to the BME820 to the scope of T4 SPI CLK and see if you can notice gaps or delays that are controlled by CCR.

    Yes, Paul added code for setting SPI CLK, though I didn't know he updated the deprecated setFrequency. The current T4 SPI lib does not have code to set polarity and bit order, so i'm not surprised the deprecated functions haven't been updated. Registers default to Mode0 and MSB which is what most devices use (including BME20). With T4 so fast, it still might be a problem with setting CS, so a delayMicros(10) after CS HIGH and before CS LOW might work, and maybe delays between spixfer() ....
    Will play with the BME280 more tomorrow - getting tired and getting late.

  7. #782
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    7,360
    Quote Originally Posted by KurtE View Post
    Currently T1->r2, t2->R3, t3->r5, t5->r6, t6->r7, t7->R8, T8->R1
    Note I skipped Serial4
    Serial4 I have hooked up to PC with USB to Serial adapter... Currently Adafruit CP2104 version...
    Thanks Kurt, Okay that is how I read the open comment yesterday - then I wired 8 serials as loopback with each Tx><Rx and - prepared to edit the code - but that worked with FrankB's code - so I went with it as it was simple to not wire but jumper I even started to expand the code to have loopBack() and loopCross() in the same code to do either selectively with the same sketch and had to remove that ...

    You version does not work as wired so will get wires out. I've hacked out debug as it wasn't good for much except 'status spew' as USB was working. I put it through a Teensy as that seemed way more cool.

    FrankB - I'd vote for the EvResponder.disable()- taking out overhead and just doing stuff that could be done as well or better under user control. With a T4 leaving loop so many more times/sec seems overkill - instead of 1-2 million on T_3.x it can be 10-20 million loop() exits/sec. Maybe it should have an .enable() in case a user wants to selectively pause it during some portion of the code.

  8. #783
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    3,821
    Quote Originally Posted by defragster View Post
    You version does not work as wired so will get wires out.
    What I did, and figured out that my T4 was lifting off, was start off the program and have T1 connected to R1, Should do the send/receive no errors... Assuming that works hook up
    T1->R2, T2->R1 see if it still works, move from R1, to R3 and then try T3 to R1... and if works move from R1 to R5...

  9. #784
    Senior Member
    Join Date
    Dec 2016
    Location
    Montreal, Canada
    Posts
    2,879
    For watchdog, should we make a library or make it part of the core? I updated the definitions in imxrt.h and submitted a pull request, and have working code, and enabled the vector table for the callback

    Note:
    Watchdog Interrupt Count Time-out (WICT) field determines, how long before the counter time-out must
    the interrupt occur. The reset value is 0x04 implies interrupt will occur 2 seconds before time-out. The
    maximum value that can be programmed to WICT field is 127.5 seconds with a resolution of 0.5 seconds.
    I keep it set at 2 seconds, and able to print to Serial4 output before the reset occurs. This very good to safely handle tasks before reset.

    Basically with a watchdog of 10 seconds and interrupt of 2 seconds before, the interrupt fires at 8 seconds and final reset happens at 10 seconds. Theoretically your timeout is more like 8 seconds max to feed the dog.
    Last edited by tonton81; 01-12-2019 at 02:33 AM.

  10. #785
    Senior Member xxxajk's Avatar
    Join Date
    Nov 2013
    Location
    Buffalo, NY USA
    Posts
    489
    SPI SDcard timings from UHS3.0's implementation.
    Click image for larger version. 

Name:	Screenshot from 2019-01-11 21-25-52.png 
Views:	19 
Size:	41.4 KB 
ID:	15565

  11. #786
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    7,360
    Quote Originally Posted by KurtE View Post
    What I did, and figured out that my T4 was lifting off, was start off the program and have T1 connected to R1, Should do the send/receive no errors... Assuming that works hook up
    T1->R2, T2->R1 see if it still works, move from R1, to R3 and then try T3 to R1... and if works move from R1 to R5...
    The problem is my Jumper of each port looping back to itself - I haven't grabbed the needed wires to chain them along yet - just had an idea for an easy to remove scheme ... but the row to row spacing it not on 0.1" spacing

    Found set of short F to F jumper wires ... now I need to copy this machine to my laptop ...

    Update: Jumper wires installed and working perfectly - #define SPD 2400000 Delta is 2 or 3 ms:
    Loop: 62011 Delta time: 2, CB Out: 320, CB In: 320
    Output to Serial and Serial4 included in line ports 1 to 8 with debug off.
    Last edited by defragster; 01-12-2019 at 07:42 AM.

  12. #787
    Senior Member+ manitou's Avatar
    Join Date
    Jan 2013
    Posts
    1,789
    Quote Originally Posted by mjs513 View Post
    Will play with the BME280 more tomorrow - getting tired and getting late.
    data sheet says max SPI is 10mhz

    EVK CCR settings for 8mhz 0x696968xx
    (xx EVK SPI peripheral clock frequency differs from T4) 08 for T4
    Last edited by manitou; 01-12-2019 at 03:19 AM.

  13. #788
    Senior Member xxxajk's Avatar
    Join Date
    Nov 2013
    Location
    Buffalo, NY USA
    Posts
    489
    UHS3.0 speed test, on MAX3421E SPI USB host (USB Host mini).
    Click image for larger version. 

Name:	Screenshot from 2019-01-11 22-14-38.png 
Views:	15 
Size:	49.1 KB 
ID:	15566

  14. #789
    Senior Member
    Join Date
    Dec 2016
    Location
    Montreal, Canada
    Posts
    2,879
    Quote Originally Posted by tonton81 View Post
    For watchdog, should we make a library or make it part of the core? I updated the definitions in imxrt.h and submitted a pull request, and have working code, and enabled the vector table for the callback

    Note:

    I keep it set at 2 seconds, and able to print to Serial4 output before the reset occurs. This very good to safely handle tasks before reset.

    Basically with a watchdog of 10 seconds and interrupt of 2 seconds before, the interrupt fires at 8 seconds and final reset happens at 10 seconds. Theoretically your timeout is more like 8 seconds max to feed the dog.
    Just tested another thing, you can actually feed the watchdog from within the ISR to prevent the maximum threshold from being reset as well

  15. #790
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    7,360
    Quote Originally Posted by tonton81 View Post
    For watchdog, should we make a library or make it part of the core? I updated the definitions in imxrt.h and submitted a pull request, and have working code, and enabled the vector table for the callback
    ...
    That sounds like it could be useful for some set of users - it was a visited topic of interest on T_3.x at least once. If the core is going to include a uniform way to handle high and over temp then having uniform a way to setup and feed a watchdog seems like it could be similarly useful.

    Anther note I wanted to make was to consider dropping the CPU speed down on an unhandled fault - when it goes into a while(1) it may as well drop the speed and voltage. If/when/as I revisit my debug_t4 I might see how that plays out.

  16. #791
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    5,049
    There was a Arduino SD benchmark... very old, many years.. I can't find it anymore. Who has a link for me?

  17. #792
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    5,049
    Next time we need a sub-forum for beta-testing... it's very hard to find something in this thread...

  18. #793
    Senior Member
    Join Date
    Jul 2014
    Location
    New York
    Posts
    2,190
    Maybe this is what you are talking about Frank:
    https://forum.pjrc.com/threads/45823...ght=benchmarks

  19. #794
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    5,049
    Attention, Windows only:

    In case someone wants to try GNU Arm Embedded Toolchain 8-2018-q4-major, I uploaded a working version here: https://drive.google.com/file/d/1ORKyt_FSqn2kgP0ngY3UguLcdzgfQJ6u/view
    The problem with the original version is, that objcopy throws an error "64-bit address xyz out of range for Intel Hex file", due to a bug. I took the objcopy from gcc-7 major and now it works.
    The download includes the additional teensy libraries, too.

    1) Extract the zip to Arduino\hardware\tools
    2) To use it, edit the board.txt file, and set teensy4b.build.toolchain=arm8/bin/

    I tried a few sketches, it works suprisingly good - some throw additional warnings (which is good).

    @mjs513, thank you!
    Code:
    File size 5MB
    Buffer size 100 bytes
    Starting write test.  Please wait up to a minute
    Write 257.67 KB/sec
    Maximum latency: 149300 usec, Minimum Latency: 0 usec, Avg Latency: 387 usec
    
    Starting read test.  Please wait up to a minute
    Read 786.29 KB/sec
    Maximum latency: 4090 usec, Minimum Latency: 0 usec, Avg Latency: 127 usec
    - half speed of T3.6 ... oops.. ok, there is some potential to optimize it. it just uses the SPI-library functions.

  20. #795
    Senior Member
    Join Date
    Jul 2014
    Location
    New York
    Posts
    2,190
    BME280 and SPI

    @manitou

    Yes, Paul added code for setting SPI CLK, though I didn't know he updated the deprecated setFrequency. The current T4 SPI lib does not have code to set polarity and bit order, so i'm not surprised the deprecated functions haven't been updated. Registers default to Mode0 and MSB which is what most devices use (including BME20). With T4 so fast, it still might be a problem with setting CS, so a delayMicros(10) after CS HIGH and before CS LOW might work, and maybe delays between spixfer() ....
    Looking at SPI.cpp looks like it is on the todo list, setClock,
    // TODO: make these implement settings - for now, just fixed config
    How for the good news, I added the delayMicros to the library and now its working. So that seemed to do the trick Thanks for the suggestion. Maybe that needs to get into the core to fix the issues with timings.

    EDIT: Haven't tested this yet but going through the SPI.h file I extracted Paul's method for setting the divider and CCR and put it into standalone function as well. Just wanted to get a sanity check before I screwed it up:
    Code:
    void setClockFreq(uint32_t clock)
    {
    	uint32_t ccr; // clock config, pg 2660 (RT1050 ref, rev 2)
    	uint32_t tcr; // transmit command, pg 2664 (RT1050 ref, rev 2)
    
    	uint32_t d, div, clkhz = 528000000/7;  // LPSPI peripheral clock
    	if (clock == 0) clock =1;
    		d= clkhz/clock;
    	if (d && clkhz/d > clock) d++;
    	if (d > 257) d= 257;  // max div
    	if (d > 2) {
    		div = d-2;
    	} else {
    		div =0;
    	}
    	LPSPI4_CCR = LPSPI_CCR_SCKDIV(div);
    	LPSPI4_TCR = LPSPI_TCR_FRAMESZ(7);    // TCR has polarity and bit order too
    }
    EDIT2:
    Code:
    data sheet says max SPI is 10mhz
    
    EVK CCR settings for 8mhz 0x696968xx
    (xx EVK SPI peripheral clock frequency differs from T4) 08 for T4
    If I put 10Mhz into the above function it returns 06 vs the 08? d returns 8. Not sure why the d-2?
    Last edited by mjs513; 01-12-2019 at 02:05 PM.

  21. #796
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    3,821
    @mjs513... I just added some more support into SPI library. So the clock polarity and mode should be handled in the settings.
    Also put in calls for setBitOrder and setDataMode. Note The setData mode does not do anything, neither did it on T3.x?

    Updated my SPI branch in the Pull Request with this: https://github.com/KurtE/SPI/tree/T4_Add_more_support

  22. #797
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    3,821
    And for what it is worth... I have tried SPI at 30mhz... It appears like it is running at about 25...

    Here is test run with 30mhz and LSBFIRST...

    Click image for larger version. 

Name:	screenshot.jpg 
Views:	6 
Size:	38.8 KB 
ID:	15572

  23. #798
    Senior Member+ manitou's Avatar
    Join Date
    Jan 2013
    Posts
    1,789
    Quote Originally Posted by mjs513 View Post
    [B] If I put 10Mhz into the above function it returns 06 vs the 08? d returns 8. Not sure why the d-2?
    Yes, I provided setClockFreq snippet (post #454). If you look at the ref manual, the CCR DIV is treated as +2, so if DIV is 0, peripheral clock is divided by 2. If DIV is 1, clock is divided by 3 ... So if you want the clock divided by 8, you put 6 in the CCR DIV field.

  24. #799
    Senior Member+ manitou's Avatar
    Join Date
    Jan 2013
    Posts
    1,789
    Quote Originally Posted by KurtE View Post
    And for what it is worth... I have tried SPI at 30mhz... It appears like it is running at about 25...
    The discrete SPI dividers for 75 mhz are 2,3,4,5 .... which gives SPI CLK of 37.5, 25, 18.75 ... the setClockFreq algorithm picks the divider less than or equal to user-requested frequency

  25. #800
    Senior Member
    Join Date
    Jul 2014
    Location
    New York
    Posts
    2,190
    @KurtE
    Finally learning details about SPI that I never got into before. I had downloaded your changes in the Pull request awhile ago and changing the clock in SPIsettings is working perfectly. Put together a test sketch on using transactions (mirrors the one on teensy SPI page) and tested changing the clock against the various clock speeds (60mhz down to 500000hz).

    at 40Mhz the clk pulses look more like sine waves with freq of about 38Mhz, MOSI looks pretty good, just getting spikes on the leading and trailing edges
    Code:
    at 30Mhz reading 25.5Mhz, clk beginning to look like nice squares waves, MOSI still good (yep same as you got)
    at 10 MHz reading 9.43Mhz, guess would call it ringing in the square wave pulse for the clock, MOSI still good but still with the spikes
    at 20 Mhz reading 18.86Mhz, clk getting better, looking like a nice square wave, MOSI still good with the spikes
    at 4 Mhz reading 3.97 Mhz, clock nice square wave,  MOSI still good but still with the spikes
    I tried using a modified version of the DigitalPotControl example but that didn't seem to work, didn't see anything on the scope. Still trying to figure that out. By the time T5 comes out maybe I know what I am doing Thanks for the patience.

    Mike

    EDIT: was wrong. Still doesn't work

    EDIT2: Just a quick comparison of waveforms between the T3.2 and T4. On the T3.2 at 30Mhz looks more like the waveform on the T4 at 20Mhz
    Last edited by mjs513; 01-12-2019 at 05:07 PM.

Posting Permissions

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