I'm sampling a port every 1 µs using IntervalTimer. In my main loop I'm processing the samples and for the most part each sample is processed right after the ISR collected it. It's acceptable if the processor falls behind as it can quickly catch up again, it can process about 4 samples between interrupts where a new sample is created. I also need to print data to the serial port on occasion. I'm using Serial1 for this (Serial1.write) and I'm trying to write one character between processing the samples. My main loop does only 2 things: A) Check if there is a new sample that needs to be processed and if yes do so, B) see if there is any data that needs to be written to the serial port and if yes, write the next byte. Right now I'm just using anywhere from 1 to 4 bytes with long pauses in-between so I'm not worried about the FIFO and I doubt it matters but the baud rate is set to 230,400 baud.
I have 2 issues/questions.
1: Writing a byte to the hardware serial port seems to take unusually long, about 1 µs. I can run a ton of code in that amount of time so I'm not sure why this takes so long. Is there a faster way? I don't care about RX on this port and I don't even have to use the FIFO, I just want to write one byte and start the UART transmission.
2: When I'm writing the byte right now, sometimes it delays my 1 µs IntervalTimer interrupt by a small amount. My interrupt cannot be delayed. The serial write is a low priority for me, I don't care if that gets delayed. Is there a way to reduce the priority of the serial function and/or increase the priority of the IntervalTimer ISR?
Many thanks for any help!
I have 2 issues/questions.
1: Writing a byte to the hardware serial port seems to take unusually long, about 1 µs. I can run a ton of code in that amount of time so I'm not sure why this takes so long. Is there a faster way? I don't care about RX on this port and I don't even have to use the FIFO, I just want to write one byte and start the UART transmission.
2: When I'm writing the byte right now, sometimes it delays my 1 µs IntervalTimer interrupt by a small amount. My interrupt cannot be delayed. The serial write is a low priority for me, I don't care if that gets delayed. Is there a way to reduce the priority of the serial function and/or increase the priority of the IntervalTimer ISR?
Many thanks for any help!