@kurtE, I would maintain that the low level should be save/set the number of bits, and transfer, and above that a call that does an 8/16/32/block transfer with all of the dress-up. But then maybe it should be...
Well that's neat, the code. Thank you.
I am very grateful for the help that has been offered, that you know the part and the library so well is a huge help, and I appreciate the reasons for supporting the less...
@joepasquariello Perhaps you are right, I should have stopped at the first line. Let me rephrase.
My sincere feeling is that in an embedded environment, the default API should be close to the hardware and...
The folks at Arduino forum report that command history was added to the serial monitor in version 1.8.10 of the IDE
But, it seems to be missing from my recent install of 1.8.19 with Teensy. Up-arrow in the Serial...
Is there anything wrong with supporting a dedicated or user managed paradigm alongside of the multiple device paradigm?
After all, an MCU on a few centimeters of embedded pcb, is not a desktop. Should so much...
P/S Really, in a dedicated system with one device, even more so that it transfers in blocks, it hardly makes sense to have to save, set, transfer and restore every word.
And for a small MCU system like the...
@joepasquariello Fantastic!!! Thank you so much. So then the hypothesis was right, the setup for 16 bits takes a big part of the 150 nsecs.
BTW those times are from the call to the start of the transfer, yes? ...
@joepasquariello So.... my shower thought this morning.... three new calls for the API, set16bit(), specialtransfer() and restore(). What do you think?
The other thought is that what I should do first is time...
@WMXYZ That is interesting.
One issue is the 710-750nsecs for conversion. readout commences on the first clock after the convert pin is low.
So maybe that is enough. Sync with the clock in code, clear convert...
@joepasquariello Yes, I want to run it as fast as possible.
Re the chip, that is close. The conversion indeed starts on the rising edge. But it takes about 700 nsecs to complete, and then it is available on...
@joepasquariello Thank you, that's a huge time saver.
For a dedicated embedded system, I usually prefer to understand the part and have at its registers. But that does look a time sink in this instance...
Hi,
The following is to ask about a speed up for looping over transfer16() with some other operations in between calls to transfer16(). The essential is that there seems to be about 150 nsec between calling...
@defragster Thank you very much, and also @KurtE and @PaulStoffregen I do very much appreciate the help, and you have all been fantastic.
I called beginTransaction() to set the speed. Is there another way that...
@defragster And if nothing else is using the bus? Actually, this is in preparation for some code that reads frames from a linear CCD, some 2K words per shutter and shutters can run on a clock or triggered from a...
@kd5rxt-mark Its just a test program. I wait to initialize the spi until I am actually testing the spi. That is one of the way you check things, your turn them on one at a time. It ranks right up there next to...
@defragster, yes of course, that is what the logical test does. in this test program, it is called the first time that command is recognized and then not afterwards.
I think that description is consistent with...
So, as it turns out, everything is working great and as spec'd.
Here is the code that I wound up with, for the 16bit transfers from the ADC with the convert pin asserted for 700nsec between transfer. The time from...
@defragster
It has SPI.beginTransaction(settings). Does it need SPI.begin() also? And I guess that means it needs SPI.end() after SPI.endTransaction()? It didnt seem so in the source code.
@defragster Any speed that I set in the SPI above 4MHz locks it up. You can try it with the sketch that I listed. I hope and pray that the SPI gets fixed, getting to the full max speed is super important.
...
Okay, here is a complete sketch.
There are several problems.
1) The datasheet says the max speed is 30MHz, But the fastest the SPI library is only 4 MHz. How do we get the faster speed?
2) Any use of the...
Here are two code snippets, they run from loop. Again, this is a contrived example do demonstration what seems like a bug.
The first works perfectly okay. The second hangs at SPI.transfer16. What I am doing...
Hi
The ADC device, MCP33131D-10 requires SDI be held high during the complete cycle. Below is a screen capture from the datasheet. See Note 1.
How do I do that?
Thank you
@PaulStoffregen Hi Paul, thank you. I think I have go this part under control for the time being. I am about to post another more serious question on another thread/
@defragster Great. So here is what works so far, and what I am thinking to do.
The code snipped below, works. So, the idea is modify the above script to add the following to define the serial number string for...
So, turning on verbose, I managed to capture the following from the IDE. It seems informative, although there are more than a few mysteries, for example why it repeats the compilation three times each time adding one...
Hi,
Is there a production compatible way to set serial numbers for the Teensy 4?
I think the most convenient solution would be if we could write over the serial number in the image flashed to the board.
...
@Defragster
Good to know. very helpful. Thank you.
@PaulStoffregen
Hi Paul, I would like to add a routine as follows, the intent is to resume interrupts after detach. Is this okay? Will it work and...
Re re-entrance in detach(),
I think it can be left as is, and the documentation can say it is not re-entrant. That is easier and more readily compatible with calling it from an isr (a very common use case). We...
I think interrupt pending in this discussion means the status bit is set for the source but the enable mask is set to disable or global interrupts are disabled.
In other words, the condition is present but the...
Okay, I think my work around for the re-entrancy problem in detach, is to bracket detach in the main loop with noInterrupts() ... interrupts() and rely on interrupts being disabled on entry to the ISR.
But, I...
@PaulStoffregen Oops, maybe. Is this atomic? If not, you have a re-entrancy bug. I don't really have time to construct a demonstration today, but I think it is pretty clear that it is so.
gpio &= ~mask;
...
@PaulStoffregen - apologies, I want to make this a separate post. I think it is very important.
Is there a similar issue in the interrupt attach/detach code?
All of the interrupt code for detach or...
@defragster read my edit please, and read this carefully too.
Not clearing a pending interrupt before you re-enable interrupts is a bug and there is no robust solution other than masking the pending interrupt...
@PaulStoffregen Thank you for the fix.
Re the suggestion to move end() to the beginning:
The delay and pin activity are in the intended order. The scope shows test_u1 - that is the interval timer. ...
@joepasquariello cc @PaulStoffregen
No, not really. It is not about my design. It looks a lot like what happens sometimes on not having masked the source of the interrupt before jiumping to the ISR.
But i did...
@joepasquariello Look at the oscilloscope traces. The spacing between the two leading edges in the lower trace, or the duration of the pulse upper trace, should be roughly equal to the value of test_u2 in usecs, in...
Okay I can do that. Here is a self contained program that demonstrates the behavior. In the serial console enter the command "test clock 10 1", and everything is okay. Enter the command "test clock 10 11" and you...
@defragster, That delay to longer than one interval is the point.
Let me try to explain the intent of the example it in a more simple way:
A function is launched by an interval timer, by calling...
P/S, The behavior is not altered by bracketing with noInterrupts(), interrupts().
In other words, the following code produces the same result as the above.
unsigned int test_u1 = 10;
unsigned int test_u2 = 1;...
Consider the following code. In a nut shell, one function launches the other on a timer, and the other then delays for some time and then cancels the timer. This is running on a Teensy 4.0
To make things easy to...
Consider the following ISR, which disables interrupts, increments and checks a counter, conditionally stops an interval timer or detaches interrupts, and re-enables interrupts.
This is a schematic of some code...
I'm sorry, maybe I'm missing it, but I don't see how that addresses the problem.
I need to start a timer and produce an interrupt at the start as well as each clock interval.
At present, both of the periodic...
Okay, TeensyTimerTool doesn;t really solve it. The first frame is acquired by TeensyTimerTool, at about 1 clock period after calling begin(). That won't do for a triggered set of frames. We need the first frame...
Well, I think I found it. Using the TeensyTimerTool, begin a PeriodicTimer in stopped mode and then start it from an ISR launched on a transiton on the digital i/o pin. The start call seems to be a one-linear in...
Hi,
Running on Teensy4, I would like to use a logical level input as a trigger to start clocking a function. The latency between the trigger input and the first call to the function should be as short as feasible,...
@WMXZ Looking at table 50 in the MCU datasheet, "Maser mode SAI timing", it seems like the clock might be a little bit faster, and i can imagine it doing a streaming receive. But I am not sure how you would hand...
I understand all of that. The question is does each of the LPSPI ports have a receive FIFO? Can I use a different port to avoid the LED?
I found the section in the data sheet, Table 2 implies they all have it,...
If I could beg everyone's patience, just this one more time. Here is the interface circuit between the T4 and the digitizer.
Did I use the right pins on the Teensy?
There is a note on the webpage that the first...
Okay, so I am starting on the electrical design. I have a quick question
Which set of pins to use?
The website notes for the Teensy 4.0 say that "he first SPI port features a FIFO for higher sustained speed...
Of course. As it turns out there is not a lot for the CPU to do while the data is coming in, "nothing, ... really nothing" (ala Gertrude Stein).
The worst it could be is if the user would send a command at that...
@Paul That's amazing. The "control waveforms" refers to the ADC? (In the plain DMA, I dont see how to set the convert for each sample, and not only that it has its own timing issues)
The CCD in this...
Yes that is the part. Yes of course, I would try the simple loop, exactly like that, verify and see if it might be fast enough. The T4 has been very impressive so far.
I was just working thru how dma might work,...
On further thought, it sounds like the effort to use FlexSPI exceeds the budget and benefit for this particular project. He will have to live with 16 bits at hopefully 800KS/s or 14 at 1MS/s.
So, any special advise...
@KurtE Thank you. Yes, that is why I felt I needed to ask. To be concrete, the part we are contemplating is the MCP33131D-10, I should preface that I have never programmed one of these before.
What I make out...
I need to use an external 16bit 1MS/s ADC over SPI with the Teensy 4.0. We are going to assert the CONVERT and read the 16 bit data over SPI, hopefully at 1 MS/s.
Will the SPI library support reads at this rate on...
Sorry, I know it is old, can't help chiming in. SAR type ADC's have kickback. There are application notes and tutorials on driving ADCs, it should be there.
I think I got it, The test for high, can come in at any time on the previous high state. I should wait for low and then high.
while (digitalReadFast(fMPinMonitor)){} // It takes two states to get synch'ed
...
I am trying to implement the following timing diagram. The question is, is there a better (but still simple) way to do this?
So, far my idea is to setup a square wave and use a logic gate with the output from...
Thank you Paul. The T4 is wonderful, I am very happy with it for the linear ccd (12 bits is more than enough for a CCD - for rational people).
Which interface would make the most sense for an external ADC, 16...
Hi,
The Teensy 3.2 has been a workhorce for me. However, the significant limitation has been the usb. The K20_120, in the same family, offers a high usb. Could we please have a version of the T3 based on that...
Sigh... well it was great for a moment, the T4 has a 12 bit ADC. And it turns out, on quick perusa, it seems that \all of NXP's M7 line have 12 bit ADCs, though some do also have DAC(s). So it seems so far, that the...
Doctorate in Chemistry and Physics, former faculty in Materials Science at a big ten school, scientist in x-ray diffraction, spectroscopy and instrumentation at a National Lab. Currently working on lasing, lighting and quantum information applications in organic semiconductors.