Forum Rule: Always post complete source code & details to reproduce any issue!
Page 35 of 74 FirstFirst ... 25 33 34 35 36 37 45 ... LastLast
Results 851 to 875 of 1849

Thread: Project: SPI_MSTransfer

  1. #851
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    5,373
    Evening. Just got back to this again

    It might just fix the issues with the board combos I am using. Like you said, "just finding the sweet spot" where it works - basically tuning the combo so it work.

  2. #852
    Senior Member
    Join Date
    Dec 2016
    Location
    Montreal, Canada
    Posts
    3,379
    im thinking of getting rid of the slave contructor in favor of the preloaded slave object

    example:

    with no constructors, just the #include, you should be able to just run slave.begin() in setup() to activate it
    the master will definately keep its constructor, as it points to the slave(s)

    I did the same with AsyncUDP when i ported it to teensy, using the “Udp” object was able to access the udp protocol and callbacks without instantiating it, because the library enabled the object internally

    also, if its segregated properly, we might also be able to do cascading , ex, a slave being both master and slave

    that can also potentially extend your bus range over longer legths using “transfer16 repeaters”

  3. #853
    Senior Member
    Join Date
    Dec 2016
    Location
    Montreal, Canada
    Posts
    3,379
    Welp, I got F&F's and toggling, digitalread/write, everything basically, with a SPISettings of 1KHz (1000)

    its a bit of a tricky scenario, for high speed the DSPI seems to be finishing the transfers before the line is cut off, at other speeds the CS is dropped before the line is done transferring
    I verified this by testing (currently) with a delayMicroseconds(25); (i tried 5 but that failed) right before the first command in SPI_deassert func.
    Secondly, the timeout increases the lower SPI speed you go, so while the problem with the line deasserting before the transfer is finished, this one also threw me off,


    i have the led toggling at 1 sec intervals and loop at 0ms
    the auto resend needed to be upped to 500 as the response can be up to 4xx to validate at 1khz setting, so I put a value of 1000uS for the timeout at a safety margin

    Code:
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11783
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11783
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    LED STATE: 0
    ^LTF&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11783
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11783
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11783
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11783
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11783
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11783
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11783
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11783
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11783
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11783
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11783
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    LED STATE: 1
    ^LTF&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11783
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11783
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11783
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11783
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11783
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11783
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11783
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11782
    F&F (OT=0)micros() _time==11783
    Code:
      0.000000,    0.0342,    0.0342,1961463.625000,1961520.875000,34236.0000,  185.0324,  185.0351,  185.0378,34240.0000,34241.0000,34242.0000
      0.000000,    0.0343,    0.0343,1964213.750000,1964271.125000,34284.0000,  185.1621,  185.1648,  185.1675,34288.0000,34289.0000,34290.0000
      0.000000,    0.0343,    0.0343,1966964.000000,1967021.250000,34332.0000,  185.2917,  185.2944,  185.2971,34336.0000,34337.0000,34338.0000
      0.000000,    0.0344,    0.0344,1969714.250000,1969771.500000,34380.0000,  185.4211,  185.4238,  185.4265,34384.0000,34385.0000,34386.0000
      0.000000,    0.0344,    0.0344,1972464.375000,1972521.750000,34428.0000,  185.5505,  185.5532,  185.5559,34432.0000,34433.0000,34434.0000
      0.000000,    0.0345,    0.0345,1975214.625000,1975271.875000,34476.0000,  185.6798,  185.6825,  185.6852,34480.0000,34481.0000,34482.0000
      0.000000,    0.0345,    0.0345,1977964.750000,1978022.125000,34524.0000,  185.8090,  185.8117,  185.8144,34528.0000,34529.0000,34530.0000
      0.000000,    0.0346,    0.0346,1980715.000000,1980772.250000,34572.0000,  185.9382,  185.9409,  185.9435,34576.0000,34577.0000,34578.0000
      0.000000,    0.0346,    0.0346,1983465.125000,1983522.500000,34620.0000,  186.0672,  186.0699,  186.0726,34624.0000,34625.0000,34626.0000
      0.000000,    0.0347,    0.0347,1986215.375000,1986272.625000,34668.0000,  186.1961,  186.1988,  186.2015,34672.0000,34673.0000,34674.0000
      0.000000,    0.0347,    0.0347,1988965.625000,1989022.875000,34716.0000,  186.3250,  186.3277,  186.3304,34720.0000,34721.0000,34722.0000
      0.000000,    0.0348,    0.0348,1992403.375000,1992460.625000,34776.0000,  186.4859,  186.4886,  186.4913,34780.0000,34781.0000,34782.0000
      0.000000,    0.0348,    0.0348,1995153.500000,1995210.875000,34824.0000,  186.6146,  186.6172,  186.6199,34828.0000,34829.0000,34830.0000
      0.000000,    0.0349,    0.0349,1997903.750000,1997961.000000,34872.0000,  186.7431,  186.7458,  186.7485,34876.0000,34877.0000,34878.0000
      0.000000,    0.0349,    0.0349,2000653.875000,2000711.250000,34920.0000,  186.8716,  186.8743,  186.8770,34924.0000,34925.0000,34926.0000
      0.000000,    0.0350,    0.0350,2003404.125000,2003461.375000,34968.0000,  187.0000,  187.0027,  187.0053,34972.0000,34973.0000,34974.0000
      0.000000,    0.0350,    0.0350,2006154.375000,2006211.625000,35016.0000,  187.1283,  187.1310,  187.1336,35020.0000,35021.0000,35022.0000
      0.000000,    0.0351,    0.0351,2008904.500000,2008961.750000,35064.0000,  187.2565,  187.2592,  187.2619,35068.0000,35069.0000,35070.0000
      0.000000,    0.0351,    0.0351,2009592.000000,2009649.375000,35076.0000,  187.2885,  187.2912,  187.2939,35080.0000,35081.0000,35082.0000
      0.000000,    0.0351,    0.0351,2010279.625000,2010336.875000,35088.0000,  187.3206,  187.3233,  187.3259,35092.0000,35093.0000,35094.0000
      0.000000,    0.0351,    0.0351,2013029.750000,2013087.125000,35136.0000,  187.4487,  187.4513,  187.4540,35140.0000,35141.0000,35142.0000
      0.000000,    0.0352,    0.0352,2015780.000000,2015837.250000,35184.0000,  187.5766,  187.5793,  187.5820,35188.0000,35189.0000,35190.0000
      0.000000,    0.0352,    0.0352,2018530.250000,2018587.500000,35232.0000,  187.7046,  187.7072,  187.7099,35236.0000,35237.0000,35238.0000
      0.000000,    0.0353,    0.0353,2021280.375000,2021337.750000,35280.0000,  187.8324,  187.8350,  187.8377,35284.0000,35285.0000,35286.0000
      0.000000,    0.0353,    0.0353,2024030.625000,2024087.875000,35328.0000,  187.9601,  187.9628,  187.9654,35332.0000,35333.0000,35334.0000
      0.000000,    0.0354,    0.0354,2026780.750000,2026838.125000,35376.0000,  188.0877,  188.0904,  188.0931,35380.0000,35381.0000,35382.0000
      0.000000,    0.0354,    0.0354,2029531.000000,2029588.250000,35424.0000,  188.2153,  188.2180,  188.2206,35428.0000,35429.0000,35430.0000
      0.000000,    0.0355,    0.0355,2032281.250000,2032338.500000,35472.0000,  188.3428,  188.3454,  188.3481,35476.0000,35477.0000,35478.0000
      0.000000,    0.0355,    0.0355,2035031.375000,2035088.625000,35520.0000,  188.4702,  188.4728,  188.4755,35524.0000,35525.0000,35526.0000
      0.000000,    0.0356,    0.0356,2037781.625000,2037838.875000,35568.0000,  188.5975,  188.6001,  188.6028,35572.0000,35573.0000,35574.0000
      0.000000,    0.0356,    0.0356,2040531.750000,2040589.125000,35616.0000,  188.7247,  188.7273,  188.7300,35620.0000,35621.0000,35622.0000
      0.000000,    0.0357,    0.0357,2043282.000000,2043339.250000,35664.0000,  188.8518,  188.8544,  188.8571,35668.0000,35669.0000,35670.0000
      0.000000,    0.0357,    0.0357,2046032.125000,2046089.500000,35712.0000,  188.9788,  188.9815,  188.9841,35716.0000,35717.0000,35718.0000
      0.000000,    0.0358,    0.0358,2048782.375000,2048839.625000,35760.0000,  189.1058,  189.1084,  189.1111,35764.0000,35765.0000,35766.0000
      0.000000,    0.0358,    0.0358,2051532.625000,2051589.875000,35808.0000,  189.2327,  189.2353,  189.2379,35812.0000,35813.0000,35814.0000
      0.000000,    0.0359,    0.0359,2054282.750000,2054340.000000,35856.0000,  189.3595,  189.3621,  189.3647,35860.0000,35861.0000,35862.0000
      0.000000,    0.0359,    0.0359,2057033.000000,2057090.250000,35904.0000,  189.4861,  189.4888,  189.4914,35908.0000,35909.0000,35910.0000
      0.000000,    0.0359,    0.0359,2059783.125000,2059840.500000,35952.0000,  189.6128,  189.6154,  189.6180,35956.0000,35957.0000,35958.0000
      0.000000,    0.0360,    0.0360,2062533.375000,2062590.625000,36000.0000,  189.7393,  189.7419,  189.7446,36004.0000,36005.0000,36006.0000
      0.000000,    0.0360,    0.0360,2065283.500000,2065340.875000,36048.0000,  189.8657,  189.8684,  189.8710,36052.0000,36053.0000,36054.0000
      0.000000,    0.0361,    0.0361,2067346.250000,2067403.500000,36084.0000,  189.9605,  189.9632,  189.9658,36088.0000,36089.0000,36090.0000
      0.000000,    0.0361,    0.0361,2068033.750000,2068091.000000,36096.0000,  189.9921,  189.9947,  189.9974,36100.0000,36101.0000,36102.0000
      0.000000,    0.0361,    0.0361,2068721.250000,2068778.625000,36108.0000,  190.0237,  190.0263,  190.0289,36112.0000,36113.0000,36114.0000
      0.000000,    0.0362,    0.0362,2071471.500000,2071528.750000,36156.0000,  190.1499,  190.1526,  190.1552,36160.0000,36161.0000,36162.0000
      0.000000,    0.0362,    0.0362,2074221.750000,2074279.000000,36204.0000,  190.2761,  190.2787,  190.2814,36208.0000,36209.0000,36210.0000
      0.000000,    0.0362,    0.0362,2076971.875000,2077029.250000,36252.0000,  190.4022,  190.4048,  190.4075,36256.0000,36257.0000,36258.0000
      0.000000,    0.0363,    0.0363,2079722.125000,2079779.375000,36300.0000,  190.5282,  190.5308,  190.5335,36304.0000,36305.0000,36306.0000
      0.000000,    0.0363,    0.0363,2081784.750000,2081842.000000,36336.0000,  190.6227,  190.6253,  190.6279,36340.0000,36341.0000,36342.0000
      0.000000,    0.0364,    0.0364,2085222.500000,2085279.750000,36396.0000,  190.7800,  190.7826,  190.7852,36400.0000,36401.0000,36402.0000
      0.000000,    0.0364,    0.0364,2087972.625000,2088030.000000,36444.0000,  190.9057,  190.9084,  190.9110,36448.0000,36449.0000,36450.0000
      0.000000,    0.0365,    0.0365,2090722.875000,2090780.125000,36492.0000,  191.0314,  191.0340,  191.0367,36496.0000,36497.0000,36498.0000
      0.000000,    0.0365,    0.0365,2093473.125000,2093530.375000,36540.0000,  191.1570,  191.1596,  191.1622,36544.0000,36545.0000,36546.0000
      0.000000,    0.0366,    0.0366,2096223.250000,2096280.625000,36588.0000,  191.2825,  191.2851,  191.2877,36592.0000,36593.0000,36594.0000
      0.000000,    0.0366,    0.0366,2098973.500000,2099030.750000,36636.0000,  191.4079,  191.4106,  191.4132,36640.0000,36641.0000,36642.0000
      0.000000,    0.0367,    0.0367,2101723.750000,2101781.000000,36684.0000,  191.5333,  191.5359,  191.5385,36688.0000,36689.0000,36690.0000
      0.000000,    0.0367,    0.0367,2104473.750000,2104531.250000,36732.0000,  191.6586,  191.6612,  191.6638,36736.0000,36737.0000,36738.0000
      0.000000,    0.0368,    0.0368,2107224.000000,2107281.250000,36780.0000,  191.7837,  191.7863,  191.7889,36784.0000,36785.0000,36786.0000
      0.000000,    0.0368,    0.0368,2109974.250000,2110031.500000,36828.0000,  191.9088,  191.9114,  191.9140,36832.0000,36833.0000,36834.0000
      0.000000,    0.0369,    0.0369,2112724.500000,2112781.750000,36876.0000,  192.0338,  192.0365,  192.0391,36880.0000,36881.0000,36882.0000
      0.000000,    0.0369,    0.0369,2115474.750000,2115532.000000,36924.0000,  192.1588,  192.1614,  192.1640,36928.0000,36929.0000,36930.0000
      0.000000,    0.0370,    0.0370,2118224.750000,2118282.250000,36972.0000,  192.2836,  192.2862,  192.2888,36976.0000,36977.0000,36978.0000
      0.000000,    0.0370,    0.0370,2120975.000000,2121032.250000,37020.0000,  192.4084,  192.4110,  192.4136,37024.0000,37025.0000,37026.0000
      0.000000,    0.0371,    0.0371,2123725.250000,2123782.500000,37068.0000,  192.5331,  192.5357,  192.5383,37072.0000,37073.0000,37074.0000
      0.000000,    0.0371,    0.0371,2125788.000000,2125845.250000,37104.0000,  192.6266,  192.6292,  192.6318,37108.0000,37109.0000,37110.0000
      0.000000,    0.0371,    0.0371,2126475.500000,2126532.750000,37116.0000,  192.6577,  192.6603,  192.6629,37120.0000,37121.0000,37122.0000
      0.000000,    0.0371,    0.0371,2127850.500000,2127907.750000,37140.0000,  192.7200,  192.7226,  192.7252,37144.0000,37145.0000,37146.0000
      0.000000,    0.0372,    0.0372,2130600.750000,2130658.000000,37188.0000,  192.8445,  192.8471,  192.8497,37192.0000,37193.0000,37194.0000
      0.000000,    0.0372,    0.0372,2133351.000000,2133408.250000,37236.0000,  192.9689,  192.9715,  192.9741,37240.0000,37241.0000,37242.0000
      0.000000,    0.0373,    0.0373,2136101.250000,2136158.500000,37284.0000,  193.0932,  193.0958,  193.0984,37288.0000,37289.0000,37290.0000
      0.000000,    0.0373,    0.0373,2138851.250000,2138908.750000,37332.0000,  193.2175,  193.2201,  193.2227,37336.0000,37337.0000,37338.0000
      0.000000,    0.0374,    0.0374,2141601.500000,2141658.750000,37380.0000,  193.3417,  193.3443,  193.3468,37384.0000,37385.0000,37386.0000
    OT _time had to be adjusted to "> 12000" due to the fact it takes long time at slow speed (11782)

  4. #854
    Senior Member
    Join Date
    Dec 2016
    Location
    Montreal, Canada
    Posts
    3,379
    Anyone care to test this?

    Code:
    to test.zip
    If your doing 8+ mhz you can change these variables for testing in H

    Code:
    #define _transfer_slowdown_while_reading 0
    #define _delay_before_deassertion 25
    The first one seems to be working, omitting it from the library causes crashes, so I presume 0 is doing some delayMicroseconds housekeeping behind scenes
    Second one is you increase it if you have problems, it's micros time before CS is raised. For high speed, setting it at 0 works, at low speeds, (1khz lol?) 25 seems to work..

    im beginning to wonder why digitalwrite(fast) is faster than the SPI bus can complete (master end of course)..

    11782 micros for ~ 30 bytes (buffer & overhead) at 1khz, definately not good for aHRS

    would be nice to find actual completion before deasserting, so the delay can go byebye, library uses the core transfer16 method for SPI transfers

    EDIT: still 0 OT at 1khz
    Last edited by tonton81; 03-23-2018 at 03:58 PM.

  5. #855
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    5,373
    I'll give it a shot with my crazy set up in a little bit - have guys here installing new floor

    EDIT: Test 1. T3.5 @168 and T3.2 at 120, getting traffic but:
    Code:
    F&F (OT=1998)micros() _time==12625
    F&F (OT=1999)micros() _time==12625
    F&F (OT=2000)micros() _time==12625
    PacketID: 55
    Length: 48
    Got message......
    F&F (OT=2001)micros() _time==12625
    F&F (OT=2002)micros() _time==12625
    PacketID: 55
    No led blinking. Going to try 144 and 120, that seemed to work before

    EDIT2: Same thing at 144/120. At least it works and no hanging.

    EDIT3: Same/same at 144/72. One thing I forgot to mention is that there are no errors on the slave side. Only OTs on the master for all three tests. For this one it does blink but intermittently.
    Last edited by mjs513; 03-23-2018 at 04:29 PM.

  6. #856
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    11,837
    It works for me - I have an update to the tvMASTER.ino :: TVmaster.ino.txt

    I see no errors - but 30500 where I tested is slow One F&F is 11,784 uS. The above update overshoots but accounts for that and works at 30 MHz too.

    NOTE: At 30 MHz SPI the 51 uS is now 76 to 78 uS

    NOTE: At lower speeds the 500 Hz F&F taking soooo long makes the pinToggle miss the time test - so it will not be 10 Hz change as the transfer goes over perhaps 1 ms

    Here are the edits I made to SPI_MSTransfer\SPI_MSTransfer.cpp to make the RETRY case output more viewable in the SerMon::
    Code:
    bool SPI_MSTransfer::command_ack_response(uint16_t *data, uint32_t len) {
      uint8_t resend_count = 0; uint32_t timeout = micros(); uint16_t _crc = 0;
      while ( 1 ) {
        _crc = spi_port->transfer16(0xFFFF);
        if ( _crc == 0xF00D ) {
          spi_port->transfer16(0xBEEF); break;
        }
        else if ( _crc == 0xBAAD ) {
          spi_port->transfer16(0xBEEF); SPI_deassert(); return 0;
        }
        if ( micros() - timeout > 1000 ) {
          resend_count++;
          if ( resend_count > 3 ) {
            if ( debugSerial != nullptr ) {
              Serial.print("DBG: [S_CS "); Serial.print(chip_select);
              Serial.print("] FAIL_RES #"); Serial.print(resend_count);
              Serial.print(" Tx ABORT. "); delay(1000);
            }
            break;
          }
          if ( debugSerial != nullptr ) {
            Serial.print("FAIL_Res #"); Serial.print(resend_count);
            Serial.print(" RETRY..."); delay(1000);
          }
          timeout = micros();
        }
      }
      return 1;
    }

  7. #857
    Senior Member
    Join Date
    Dec 2016
    Location
    Montreal, Canada
    Posts
    3,379
    ok will merge your edits, yeah turn 25 to 0 for your use, its only needed for those picky deassertion speeds

    i think we'll make 25 as default for now, so it wont affect majority of users. if a user wanted the boost he could adjust it manually
    (unless we find that deassert glitch )

    i changed the modulo to > 1000 works better, that modulo threw me off too while debugging
    Last edited by tonton81; 03-23-2018 at 05:07 PM.

  8. #858
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    11,837
    Did you say the break happened about 8 Mhz?

    I did this quick AUTO ADJUST so 30 MHz returns to 51 or 52 uS in SPI_MSTransfer.cpp::
    Code:
    // { remove _delay_before_deassertion #define from the header }
    uint32_t _delay_before_deassertion = 25;  
     // ...
    
    SPI_MSTransfer::SPI_MSTransfer(const char *data, uint8_t cs, SPIClass *SPIWire, uint32_t spi_bus_speed) {
      chip_select = cs; spi_port = SPIWire; _master_access = 1; _spi_bus_speed = spi_bus_speed;
      ::pinMode(cs, OUTPUT); // make sure CS is OUTPUT before deassertion.
      ::digitalWriteFast(cs, HIGH); // deassert the CS way before SPI initializes :)
      if ( spi_bus_speed > 8000000 ) _delay_before_deassertion = 0;
    Nobody should have to edit the library to get proper performance.

  9. #859
    Senior Member
    Join Date
    Dec 2016
    Location
    Montreal, Canada
    Posts
    3,379
    Mike, the OT is because you have a > 1000 counter, for sure slower speeds are triggering it and are not failing, so its still counted

    thats why i said before change OT _timer to > 12000 instead of > 1000 for 1khz, otherwise OT will count +1 every loop

    yeah tim, that works too, although, im afraid of "picky" setups due to the SPI issue, what can work for us doesnt necessarily work for mike, as an example, and the library will be controlling it, not the user

  10. #860
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    5,373
    Just loaded up the Tvmaster/slave with the changes that defragster posted as well as the change to the .cpp file. Right now with the T3.5 at 168Mhz and T3.2 at 120Mhz oc'd it's happily chugging along at 1Khz SPI. No OT's or errors on the slave and its blinking happily.
    Master:
    Code:
    F&F (OT=0) OT_CALC==3000000  micros() _time==12625
    F&F (OT=0) OT_CALC==3000000  micros() _time==12626
    F&F (OT=0) OT_CALC==3000000  micros() _time==12626
    F&F (OT=0) OT_CALC==3000000  micros() _time==12626
    ^LTF&F (OT=0) OT_CALC==3000000  micros() _time==12625
    F&F (OT=0) OT_CALC==3000000  micros() _time==12625
    F&F (OT=0) OT_CALC==3000000  micros() _time==12625
    F&F (OT=0) OT_CALC==3000000  micros() _time==12625
    F&F (OT=0) OT_CALC==3000000  micros() _time==12625
    F&F (OT=0) OT_CALC==3000000  micros() _time==12625
    Slave:
    Code:
    54456.00, #, #, #, #, #, #, #, #, #, #, #,20085,0
    54468.00, #, #, #, #, #, #, #, #, #, #, #,20086,0
    54480.000000,    0.0545,    0.0545,3121645.750000,3121703.000000,54485.0000,  233.4224,  233.4245,  233.4267,54489.0000,54490.0000,54491.0000
    54492.00, #, #, #, #, #, #, #, #, #, #, #,20087,0
    54504.00, #, #, #, #, #, #, #, #, #, #, #,20088,0

  11. #861
    Senior Member
    Join Date
    Dec 2016
    Location
    Montreal, Canada
    Posts
    3,379
    magic bug found! wheres my cookie? lol

    see mike, 12625 > 1000, thats what incremented your OT heheh

  12. #862
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    5,373
    New name = cookie monster

    Now the real test, no overclocking T3.5 (120Mhz) and T3.2(72Mhz):
    Code:
    F&F (OT=0) OT_CALC==3000000  micros() _time==11788
    F&F (OT=0) OT_CALC==3000000  micros() _time==11788
    F&F (OT=0) OT_CALC==3000000  micros() _time==11789
    F&F (OT=0) OT_CALC==3000000  micros() _time==11789
    F&F (OT=0) OT_CALC==3000000  micros() _time==11788
    Chugging happily along. No ot's or errors. Going to let run for awhile.

    BTW: did you notice anything interesting with the times?

  13. #863
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    11,837
    Quote Originally Posted by tonton81 View Post
    Mike, the OT is because you have a > 1000 counter, for sure slower speeds are triggering it and are not failing, so its still counted

    thats why i said before change OT _timer to > 12000 instead of > 1000 for 1khz, otherwise OT will count +1 every loop

    yeah tim, that works too, although, im afraid of "picky" setups due to the SPI issue, what can work for us doesnt necessarily work for mike, as an example, and the library will be controlling it, not the user
    @Tony: As Mike Notes - the provided tvMaster.ino automates a working (hack) adjustment to the perceived timeout - it Overshoots - but at least no false OT's! I can do a PULL request - or you can upload with your updates.

    I think you should do the provided VARIABLE solution. If it needs user adjustment - it can be made as easily ( and perhaps more understandably ) to that variable than to a #define. Pushing the variable on the stack versus pushing the constant to delaymicroseconds() is trivial. In fact you could add that as an option extra param here::

    SPI_MSTransfer teensy_gpio = SPI_MSTransfer("Serial", SPI_MST_CS, &SPI_MST_BUS, SPI_SPEED );

    becomes::

    SPI_MSTransfer teensy_gpio = SPI_MSTransfer("Serial", SPI_MST_CS, &SPI_MST_BUS, SPI_SPEED, _delay_before_deassertion );

    and

    SPI_MSTransfer::SPI_MSTransfer(const char *data, uint8_t cs, SPIClass *SPIWire, uint32_t spi_bus_speed, uint32_t _DBD=25) {
    // ...
    _delay_before_deassertion = _DBD;

  14. #864
    Senior Member
    Join Date
    Dec 2016
    Location
    Montreal, Canada
    Posts
    3,379
    Should we just do a method rather than keep overloading the constructor? its getting pretty big
    the method would allow you to dynamically change it at runtime

    we could even make an automated sync version, where it increments until the crashes stop and keeps its value for all further transactions

  15. #865
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    11,837
    Quote Originally Posted by tonton81 View Post
    Should we just do a method rather than keep overloading the constructor? its getting pretty big
    That is up to you - it is a one time thing and it is part of the usage - it is easy to cut and paste - the _DBD is tied to SPI_SPEED so it should be side by side wherever it is.

    In fact for ideal usage perhaps combine my two edits above?

    Code:
    SPI_MSTransfer::SPI_MSTransfer(const char *data, uint8_t cs, SPIClass *SPIWire, uint32_t spi_bus_speed, uint32_t _DBD=0xffff) {
    // ...
    if ( _DBD != 0xffff ) _delay_before_deassertion = _DBD; 
    else if ( spi_bus_speed > 8000000 ) _delay_before_deassertion = 0;
    // else if ( spi_bus_speed > 4000000 ) _delay_before_deassertion = 15;
    else _delay_before_deassertion = 25;

  16. #866
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    5,373
    My two cents. Do the method to keep it simple for most users with the constructor. Assuming you are still doing the auto change to 25?

  17. #867
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    11,837
    A method can work similarly. In fact the method could allow changing the spi_bus_speed on the fly too?

  18. #868
    Senior Member
    Join Date
    Dec 2016
    Location
    Montreal, Canada
    Posts
    3,379
    well auto or default
    for auto i'd have to write an initiation scan for the slave on startup, which would poll maybe 25 or so frames, if a crash occurs, the rate is increased by 1, and loops through, once its solid, we'll pad an additional maybe 1-2 extra for a little margin
    but for this we have to call it on per slave connection, its doable but tedius. its easier to add just variable of value with a method and call it a day

    yes we can change SPI speed on the fly, currently, each object has it's own speed, this was done for multiple slaves having multiple bus speeds

  19. #869
    Senior Member
    Join Date
    Dec 2016
    Location
    Montreal, Canada
    Posts
    3,379
    besides for most user cases, using tim's example of 75uS rate, that kind of difference wouldnt be noticable to the general users, so a default of 25 i think is okay, with a method to change it dynamically

  20. #870
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    11,837
    I was wondering about an equivalent to 'if ( Serial() )' - where the Master would sent a 'PING' to search for a slave?

    teensy_gpio.Online();

    Then the program could control and be aware of run-away retries?

    Perhaps that could be part of the adjustment method so the sketch gets immediate feedback: teensy_gpio.Online( spi_bus_speed, _DBD );

  21. #871
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    5,373
    That would be a nice feature, additional insurance.

    EDIT - forgot over 116k with no errors or OTs. It now seems to be working for normal Teensy speeds - which I could not get to work before with my setup as well as very low SPI bus.

  22. #872
    Senior Member
    Join Date
    Dec 2016
    Location
    Montreal, Canada
    Posts
    3,379
    yeah but you gonna sprinkle that all over your code? why not just do it in events, but that will cause unnecessary traffic

    the auto detection still needs to be implemented, so the functions self-disable when a slave goes offline, and events() re-enables them when a slave is found. this will give non-block mode for full loop() speed for master
    Its what i want to add only once things are fixed first with stability
    Run away retries could also be tracked by timeouts, however, if your slave is offline, this is bad, as the library will block the loop X timeouts per function

    online() would return bool for offline/online state (1/0)

    thats part of the detection ill be working on

  23. #873
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    11,837
    It is working ( and has been ) very well! Now it is more speed tolerant and since the aHRS finishes in 51 uS it is ready to test/refine with a stable base now!

    I was only looking to see lower speeds work so we could see what the max distance wire length could be pushed to. Another recent poster was looking for 2 meters.

    SPI is a nice fast spec - this adds a good protocol and function with CRC checks on it - which I saw was blasted as why i2c and others are better than the raw SPI spec provides for.

    Could this even be bastardized [for Smart Teensy SPI_MST Slaves] to have the Master use a common CS for 2 or more slaves with a shutup and listed broadcast command, and a everybody but Slave X listen/ignore - I want to talk to X? All those Slave isr()'s would still go HOT - but perhaps the SPI_int could shutoff until the next CS change during 'not my message' cases?

    Also for T_3.6/3.5 utility it would be good to have the Slave cover all SPI0/SPI1/SPI2. Even the T_LC can do SPI0 & SPI1? I'll wire up my T_LC .... soon.

    <edit> Perhaps teensy_gpio.Online(); could have two modes? TEST NOW and LAST RESULT. So any teensy_gpio.xxx() could be gated with teensy_gpio.Online( 0 ); and then in loop() when

    if ( !teensy_gpio.Online( 0 ) ) teensy_gpio.Online( 1 ); // if offline - test for online ?

    And when a normal teensy_gpio.xxx(); fails it would mark it as OFFLINE.

  24. #874
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    5,373
    Ok. Up to 260K and still no errors or OT's. Think it works Sorry, don't have a LC to test with

  25. #875
    Senior Member
    Join Date
    Dec 2016
    Location
    Montreal, Canada
    Posts
    3,379
    the LC i believe uses different registers, hopefully the different formatting will make it work, and we could ifdef that for capability

    broadcast is something we discussed a month or so back, technically, F&F "should" work currently if you assert the lines manually and fire a single F&F message, you'll have to deassert the CS pin after not belonging to that object

    if you can test if that works with 2 slaves great, we could simple have the library keep an array of constructed CS pins, and we could use a method to mass enable/mass disable them

Posting Permissions

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