Go Down

Topic: Serial interrupts  (Read 525 times) previous topic - next topic

LBTRONIC

Hi
After a lot of reading about serial interrupts
Subject from both sides in this forums, actually it was really shocking and really
Disappointed that the response from arduino
Supervisor or whatever was not go directly
To response in the correct way to all people
Asking about serial interrupts,.
Dear arduino programmers
It was really a bad thing even to say that
Using delay in loop() will affect the serial
Interrupts routine, do you know that this idea breaks all the micro controller design and architecture for 50 years ago????
What kind of response that ???
Dear where is your arduino hardware interrupt ?????
Can you pls finally tell who's asking this question the true and correct answers without
Turning around and around, is that really
Too much to do ??
Dear when we asking about serial interrupt
It mean we need to know the this way not any other solution,.
Now we are waiting your answer,.
Good day,.

el_supremo

Quote
do you know that this idea breaks all the micro controller design and architecture for 50 years ago?
No it doesn't. The reason that using delay in loop() causes problems with Serial input is that at 9600 baud it takes about one millisecond to transmit one character. If you delay, for example, 50 milliseconds in the loop function, then about 50 characters can be received while the processor is in the delay. BUT by default the Serial input buffer only has room for 32 characters, so you get buffer overrun and no way to do anything about it because you're still stuck in the delay.

BTW. There was no such thing as a micro controller 50 years ago so it would be difficult to break anything related to something that didn't exist.

Pete
Don't send me technical questions via Private Message.

LBTRONIC

Hi
Dear
We talk about interrupt here the problem still not solved ,
There is always a receive interrupt for uart in any mcu as well a transmit interrupt
And for sure they must not affected in  any way with  delay in loop (),
I must tell you that I use uart interrupt for more that 15 years ago in mcu
I think there is miss understand some where and unfortunately arduino use
The easy way but not the correct way to do this !
I even don't know why you insist and still turning around the correct problem,
again not even 1000000 second in  loop () must affect not only serial I interrupt
But any interrupt ,this is why they called interrupts ,OK ,
In some mcu there is also priority interrupt,
I hope that you look carefully to some references even the data sheet for arduino mcu
maybe this will make more things clear to you ,
good luck, .


LBTRONIC

Again
To make things more focused,
The uart interrupt when initialized and a long delay in loop ()
Is used ,in this case if any character or data comes on RX pin
The delay itself is interrupted by the uart ISR saved in  pre defined
Array and return again to complete the delay
This is things should correctly works and this the best and logic way to
make the arduino library,
Not less not more
Good day,.

el_supremo

Why do you think it doesn't?


Pete

Don't send me technical questions via Private Message.

MorganS

"The problem is in the code you didn't post."

Robin2

Have a look at the examples in Serial Input Basics - simple reliable ways to receive data.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

UKHeliBob

Quote
The delay itself is interrupted by the uart ISR saved in  pre defined
Array and return again to complete the delay
How big do you expect the array to be and what should happen when it is full ?
Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

LBTRONIC

Hi
Dear ,

after each complete data received in the array we process
that data, after that we empty the array to be ready for new data ,.
the array itself depend on the application and other things
like connected devices and addresses ,.

if there is a too much things to do in loop() ,we have to use
the UART interrupt to be ready any time receiving serial data
without polling procedures ,.

good day,.

AWOL

I don't understand this topic.
"Pete, it's a fool (who) looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.
I speak for myself, not Arduino.

Robin2

I don't understand this topic.
I'm not sure the OP does either  :)

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

westfw

Quote
After a lot of reading about serial interrupts subject from both sides in this forums,
Which thread in particular?

Most of the requests for information about "Using Serial with Interrupts" seem to be from beginners who are unaware that the Serial ports on Arduino are already interrupt driven.  This means that PROBABLY they don't need to do anything special to achieve the results that they are looking for, other than to understand Serial communications in general (thus the frequent pointers to the Serial  Basics page.)  They would need to understand more before they could even approach using their own interrupt routines.
Also, because of the architecture of the AVR and arduino, it is relatively difficult to change the interrupt handling of the UARTs.  The interrupt vectors are not changeable at runtime, and changing them at compile time would mean removing and replacing several of the Arduino core files; it's a bit like asking to replace the serial driver on a windows machine. ("You don't want to do THAT; you just want to learn how to use the driver that's already there.")



Quote
it was really shocking and really disappointed that the response from arduino supervisor or whatever
There are very few messages on these forums that are from anyone who actually works for Arduino.  They're from unpaid volunteers all over the world.

Quote
The delay itself is interrupted by the uart ISR saved in pre defined Array and return again to complete the delay
    :
 not even 1000000 second in  loop () must affect not only serial I interrupt
Yes, this is how the existing Arduino driver works.  The arrays are here: https://github.com/arduino/ArduinoCore-avr/blob/master/cores/arduino/HardwareSerial.h#L113
There is no time limit; you can delay however long your want, and the driver will move characters from the uart hardware to the buffers in an interrupt service routine and leave them there, waiting.  As long a there is room in the array.   Since the memory available on an Arduino is quite small (2k on an Uno), the buffers are only 64 bytes.
It might be nice if there were a "Serial.readThing()" function that was more data-aware but still non-blocking, and would only return positive when there was a NMEA sentence, SLIP packet, or user-edited line available, rather than just a single character.  And there are occasionally times where it would be more efficient to do this in an interrupt function.  But USUALLY, you can build such things on top of the basic buffering already provided, and it is easier to do, and preferred.

-dev

Quote from: westfw
it is relatively difficult to change the interrupt handling of the UARTs.  The interrupt vectors are not changeable at runtime, and changing them at compile time would mean removing and replacing several of the Arduino core files
...  or just use some other library instead of the built-in HardwareSerial (for Serial, Serial1, etc.).  NeoHWSerial *is* HardwareSerial with just a few mods... like registering an interrupt function at run time.

Quote
It might be nice if there were a "Serial.readThing()" function that was more data-aware but still non-blocking, and would only return positive when there was a NMEA sentence, SLIP packet, or user-edited line available, rather than just a single character.  And there are occasionally times where it would be more efficient to do this in an interrupt function.
Hmm... sounds familiar.  :)

However, in the absence of details (code, libs, devices, etc.), I am also unconvinced that the OP needs this capability.  I suspect the OP is using code that blocks: delay or while loops.
Really, I used to be /dev.  :(

Go Up