I know that serial is being handle on interrupts in DUE - but data goes to buffer - I would like to handle data right away instad of polling from buffer.
How can I receive data via interrupts on arduino DUE ?
Thanks in advance.
EDIT:
or eventualy how can I adjust arduino code to make libarary from above working ?
Here are errors I have when I try to use it:
In file included from src/main.cpp:80:0:
/home/xx/xx/modules/home-controller/libraries/common/NeoHWSerial/NeoHWSerial.h:64:0: warning: "SERIAL_5N1" redefined [enabled by default]
#define SERIAL_5N1 0x00
^
In file included from /home/xx/.platformio/packages/framework-arduinosam/variants/arduino_due_x/variant.h:39:0,
from /home/xx/.platformio/packages/framework-arduinosam/cores/sam/Arduino.h:201,

from src/main.cpp:79:
/home/xx/.platformio/packages/framework-arduinosam/cores/sam/USARTClass.h:29:0: note: this is the location of the previous definition
#define SERIAL_5N1 USARTClass::Mode_5N1
^
What would you have this interrupt do with the Serial data? It has to read it into something. I've seen lots of people try to write new serial interrupt code, but all any of them are ever doing is the same thing the serial interrupt was already doing. You have to collect the data into some buffer. What's the difference between collecting it into the serial buffer or collecting it into some other buffer?
lonas:
I know that serial is being handle on interrupts in DUE - but data goes to buffer - I would like to handle data right away instad of polling from buffer.
You may want to do it that way, but its not likely to help you.
You have a need to process the serial at a particular time, as indicated by the interrupt happening? Then
just call the relevant handling function from the ISR (making sure its variables are volatile). It can then pull
stuff from the buffer.
If loop() is running often enough (nothing hogs the processor), just poll the buffer there and any other state
you need, no ISR needed, just keep your system from being overloaded and everything progresses nicely.
Maybe you are calling delay() somewhere? That's probably a problem worth solving if so.
I need to receive data with interrupts because I've implemented RS485 multimaster protocol.
When one device start transmission it's sending to all of devices negotiation character - after which no device should send anything till bus will be free - so that negotiation character have to be read as fast as possbile (without poll) - and set lock on device to do not send anything till bus is free.
MarkT:
You may want to do it that way, but its not likely to help you.
You have a need to process the serial at a particular time, as indicated by the interrupt happening? Then
just call the relevant handling function from the ISR (making sure its variables are volatile). It can then pull
stuff from the buffer.
so how can I acheive that ?
I tried for example like this - but it seems not work
I saw that USART1 have some handling for RS485 - another issue here is I need to use Serial0 - because in near future I will have to upload code via rs485 to DUE
Serial.read() is already handled by interrupts. When the handler is called, the status register is cleared and the received data pulled from UART_RHR :