Forum Rule: Always post complete source code & details to reproduce any issue!

Search:

Type: Posts; User: joepasquariello

Page 1 of 10 1 2 3 4

Search: Search took 0.01 seconds.

  1. I think that's correct. It's not just...

    I think that's correct. It's not just TeensyThreads, but rather any RTOS with a stack per task. And T4.x is okay because it uses smalloc() rather than malloc?

    I tried this malloc alternative...
  2. I tried a few more things, including having the...

    I tried a few more things, including having the thread stacks on the stack of the main thread, and I think the fundamental problem is the same. If you call malloc() with different stack pointers, you...
  3. Yes, it’s very strange. Seems to act differently...

    Yes, it’s very strange. Seems to act differently for changes that shouldn’t matter.
  4. Doing some or occasional malloc from main thread...

    Doing some or occasional malloc from main thread seems to “unlock” the heap for malloc by the other threads, but I don’t think it’s meant to work that way, and it works only “accidentally”. It never...
  5. If you run the last program I posted, you can see...

    If you run the last program I posted, you can see that all of heap can eventually be used even without a large initial malloc by main thread.
  6. In my testing, there is nothing magic about a...

    In my testing, there is nothing magic about a preliminary allocation from main thread.
  7. It seems like even if it works, it's not going to...

    It seems like even if it works, it's not going to work as expected when the stack pointer for all threads other than the main thread is below the top of the heap. Can you comment on that? One of your...
  8. I had the same experience. Made a small, valid...

    I had the same experience. Made a small, valid change to a working program, and the program stopped working completely. What I think I see in the test results are that malloc() only works (for some...
  9. I guess I don't understand this part. In my test...

    I guess I don't understand this part. In my test program (update below), the blocks are allocated in order from lowest to highest address, but with some failures among threads other than the main...
  10. malloc() will report that no memory is available...

    malloc() will report that no memory is available if the requested allocation will collide with the stack, as defined by the value of the stack pointer at the time of the call to malloc(). With...
  11. Yes, many pitfalls. It seems like dynamic...

    Yes, many pitfalls. It seems like dynamic allocation will work only if it is limited to the main thread, where the stack pointer is the system stack pointer. Probably a good idea to also limit...
  12. malloc() works as expected in the main thread...

    malloc() works as expected in the main thread (loop), but not in the thread created via addThread(). Something to do with that thread's stack having been allocated from the heap?
  13. I also ran the code on 3.5 and got the error. If...

    I also ran the code on 3.5 and got the error. If I move the malloc() code from the thread function to loop(), it runs okay there until memory is exhausted, so there is something about how threads and...
  14. I think I began using the library below to reduce...

    I think I began using the library below to reduce code size associated with printf(), but the documentation makes a point to that it is not only small, but also thread-safe and does not use malloc()....
  15. Useful doc, thanks.

    Useful doc, thanks.
  16. Replies
    9
    Views
    160

    Others know more about this than me, but I think...

    Others know more about this than me, but I think the short answer is the T4 processor is a lot more complex than the one on UNO or DUE. See section 28.2 of the processor reference manual for a...
  17. Replies
    352
    Views
    59,409

    @luni, it looks to me like the new setPeriod() in...

    @luni, it looks to me like the new setPeriod() in your fixFTM branch will do what you want. Because you have FTMEN=0 in the FTMx_MODE registers, and you are using output compare, writes to the CV...
  18. Replies
    352
    Views
    59,409

    I checked the source code, and it looks like...

    I checked the source code, and it looks like setPeriod() is not implemented for FTM, so that may explain why that function is not doing what you want. It looks like t1.trigger() will do what you...
  19. Replies
    352
    Views
    59,409

    With a PeriodicTimer, the timer starts when you...

    With a PeriodicTimer, the timer starts when you call begin(), so you could call t1.begin() in the hw_interrupt function instead of in setup(), and then stop the timer after 10 calls to...
  20. I think that's a good idea. Nice to have the...

    I think that's a good idea. Nice to have the option of using the stable IDE 1.x, but get the faster build times, while IDE 2.0 is maturing.
  21. Installed IDE 2.0 for the first time last week...

    Installed IDE 2.0 for the first time last week (rc9) on Windows 7 64-bit. Today when I started IDE 2.0, it notified me that rc9.1 was available. Download/install was fully automatic, so that was...
  22. Replies
    57
    Views
    779

    You're welcome. Yes, it seems a good idea to be...

    You're welcome. Yes, it seems a good idea to be able to modify the output pulse width and also to be able to reinitialize the input period measurement. In this case we can do that with a single...
  23. Replies
    57
    Views
    779

    Hi Biff. Here's an update that does a couple of...

    Hi Biff. Here's an update that does a couple of new things. It processes serial input from the Arduino console and looks for valid numerical characters. When newline is found (user hits enter), the...
  24. Not sure if one is preferred. Either should work....

    Not sure if one is preferred. Either should work.



    memset() is a standard library function, defined as shown below. The address (s) is type void*, value (c) is type int, and size (n) is size_t...
  25. Thanks very much for the info. I've seen...

    Thanks very much for the info. I've seen preallocation mentioned in that other thread, so I'll have to read about it. Good luck at Salt Lake, and let us know how it goes.
  26. Replies
    57
    Views
    779

    You're welcome. I was kinda glad to have a reason...

    You're welcome. I was kinda glad to have a reason to understand the FTM module better. The way that I ended up doing it is not obvious in looking at the code. FTM0 ch4 (pin 6) does input capture on...
  27. Thanks for the insights. Just a great application...

    Thanks for the insights. Just a great application and must be a lot of fun to see it all work. There are some recent threads discussing best practice for SD logging, and that's something I need to do...
  28. Replies
    57
    Views
    779

    Please try this one. I might have been in the...

    Please try this one. I might have been in the middle of a change when I did my last copy/paste. I confirmed that this builds for T3.2, though I'm testing on T3.5


    ...
  29. Replies
    57
    Views
    779

    Okay. Try this one, which (I think) sync's the...

    Okay. Try this one, which (I think) sync's the output pulse on each rising edge of the input. However, if you do single triggers, you will likely get output pulses in between your input pulses. This...
  30. Replies
    57
    Views
    779

    @Biff, I figured out how to use the COMBINE mode...

    @Biff, I figured out how to use the COMBINE mode PWM on two FTM channels to generate the output signal without interrupts. The code below does that, and you can set the output width from 1% (or even...
  31. Very cool. Can you tell us a little about the...

    Very cool. Can you tell us a little about the hardware and software? I'm curious what is the control frequency, how many analog I/O, whether you are using on-board ADC or external, etc.
  32. Replies
    57
    Views
    779

    I'm guessing that's because you're really close...

    I'm guessing that's because you're really close to the boundary between OK and too short. I'm not sure exactly what variables exist from one run to the next, but I do think it's possible that the...
  33. Replies
    57
    Views
    779

    [QUOTE=Biff;309883]@joe, trying the 5% duty cycle...

    [QUOTE=Biff;309883]@joe, trying the 5% duty cycle works well at 50 kHz (see first figure below). But if I increase the frequency to 55 kHz, the duty cycle breaks, and becomes closer to 100% (see...
  34. Replies
    57
    Views
    779

    @Biff, glad that's working for you. The method I...

    @Biff, glad that's working for you. The method I had hoped to get down to 2% on the output was to use the COMBINE feature to couple together two FTM channels to produce both the rising and falling...
  35. Replies
    57
    Views
    779

    Here's a bug fix for the version that uses FTM...

    Here's a bug fix for the version that uses FTM input capture and output compare. The fix is that variable "input_period" must be 16-bit unsigned to avoid error on roll-over of the 16-bit FTM counter....
  36. Replies
    57
    Views
    779

    Updated version w/ more and better comments and...

    Updated version w/ more and better comments and elimination of a few "magic number" constants. Use variable "output_width_pct" to set output width as % of input period.

    EDIT: On further reading of...
  37. Replies
    57
    Views
    779

    Here is a program that does what you want, as I...

    Here is a program that does what you want, as I understand it. It uses 3 pins

    - pin 3 is 50 kHz PWM to simulate the 50 kHz input signal
    - pin 9 is the input signal (FTM0 ch2) and does input...
  38. Replies
    57
    Views
    779

    That helps. Tomorrow I'll take a shot at using...

    That helps. Tomorrow I'll take a shot at using FTM for both input (input capture on rising edge only) and output (output compare for rising/falling edges of output). We should only need the rising...
  39. Replies
    57
    Views
    779

    You said previously that the output rising edge...

    You said previously that the output rising edge could be at the same time or soon after the input rising edge. And now you're saying the output pulse width depends on something other than the input...
  40. https://github.com/mjs513/NewPing_t4

    https://github.com/mjs513/NewPing_t4
  41. Replies
    57
    Views
    779

    I take your sentence above to mean that the...

    I take your sentence above to mean that the RISING edge of the output pulse can start "any time after the (rising edge of the) input pulse". Can you say something about the requirements for the...
  42. Replies
    57
    Views
    779

    FreqMeasureMulti can definitely be used to...

    FreqMeasureMulti can definitely be used to measure the period and high time of the input pulse, but unless you modify the library, there is no hook into the rising/falling edge ISRs. If you brought...
  43. The frequency and high time of any PWM signal is...

    The frequency and high time of any PWM signal is based on a clock frequency. In the case of T4.0, the clock frequency of the PWM module is F_CPU/4, so for your F_CPU=528MHz, the PWM clock frequency...
  44. There have been a number of posts lately where...

    There have been a number of posts lately where anti-virus software was getting in the way. Can you turn off your AV and try again?
  45. It's complex enough that I would try simplifying...

    It's complex enough that I would try simplifying the program to either identify the source or eliminating some of the stuff. Since nobody is going to have your board or sensors, try taking out all of...
  46. Replies
    57
    Views
    779

    I had to read your last sentence a few times, but...

    I had to read your last sentence a few times, but now I get it, and yes, I think that's a good idea. The OP didn't say there was a specified delay from rising edge of input to rising edge of output,...
  47. Replies
    57
    Views
    779

    The method we've been trying is the best I can...

    The method we've been trying is the best I can think of that doesn't involve developing any low-level code. If it needs to be better, I would want to get away from the digital input interrupt and use...
  48. Replies
    57
    Views
    779

    Hi Kurt. Just a note that my comment in the line...

    Hi Kurt. Just a note that my comment in the line that defines PWM_FREQUENCY is incorrect. 50 kHz signal has a period of only 20 us, not 200 us. According to the OP's spec, the output pulse must have...
  49. Replies
    57
    Views
    779

    And here's one more update that (I think) sets...

    And here's one more update that (I think) sets the priority of the OneShotTimer to 0, which should further reduce the jitter.



    #include "TeensyTimerTool.h"

    #define PWM_SIGNAL_PIN (3) // must...
  50. Replies
    57
    Views
    779

    Here's an update with additional code in setup()...

    Here's an update with additional code in setup() to increase the priority of the digital input interrupt to 0 (highest). This should help reduce variability in the measurement of the input pulse...
Results 1 to 50 of 500
Page 1 of 10 1 2 3 4