Hi all.
How much is the largest amount of data I can receive at once (I mean in one cycle of the Void loop) through serial ?
Im working with a teensy 4.0 board.
Is the same amount through usb or pins?
Hi all.
How much is the largest amount of data I can receive at once (I mean in one cycle of the Void loop) through serial ?
Im working with a teensy 4.0 board.
Is the same amount through usb or pins?
Depends how you mean, "at once" and "in one cycle"... really you have to explain better.
The cycle time has a minimum that increases as you add code... so how much code? In this situation, how are you processing the incoming stream? Are you waiting for some end marker or terminating condition before continuing the loop() execution, or just collecting what you can and moving on?
You see, there are a lot of things missing from this question...
including, why does it matter, and do you have any code example?
Generally, the maximum throughput of a serial stream is determined by its baud rate.
Hi @Moris526
The default serial buffer size is 64 bytes. (Uno/mega/mini/nano).
You can modify with the definition:
#define SERIAL_BUFFER_SIZE xxx
RV mineirin
You see? If your question is, "how many bytes can I allow to accumulate in the input buffer before processing them?", most of the questions and points I mentioned in my previous post still need thoughtful consideration...
Not to mention... how many bytes can you allow to pile up while you (or some core or library functions) are processing interrupts? ...and... how sure are you of their maximum execution times.
There is no "Void loop"!!!!! There's a function called "loop". It has return-type void.
The question is meaningless as the loop function could take any amount of time to run, from < 1µs to whatever you program it to do - so I think what you actually need to ask is "what's the maximum execution time I should make loop() take so I don't lose incoming serial data?"
And the answer to that is given by the serial buffer size times 10 divided by the baud-rate. 64 bytes and 115200 give 5.5ms. The 10 is the number of bits in a serial character (8 + start + stop).
Thnaks to all for the answers.
Sorry for not being clear with my question.
Im trying to build a controller for a synth, not a programmer student, so my knowledge is sketchy.
Ruilviana got it for me. I meant how much data can I get ready to process in the loop function.
And the answer to that is given by the serial buffer size times 10 divided by the baud-rate. 64 bytes and 115200 give 5.5ms. The 10 is the number of bits in a serial character (8 + start + stop).
Thank you all for your time.
I would not phrase it that way, it is very ambiguous. I would ask, "how frequently must my loop() function run in order not to miss continuously incoming characters at xxxx baud?".
Had you asked that question in your first post, you probably would have had your answer in reply #2.
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.