I'm trying to call an interrupt routine (let's call it handler() ) every second on my arduino DUE. I thought the simplest way to do this was to usethis library but it seems that i don't know how to use it...
- 1I guess you mean
start(1000000).Edgar Bonet– Edgar Bonet2019-02-19 11:26:23 +00:00CommentedFeb 19, 2019 at 11:26 - yep............... this is embarassing ahahah Do you have a guess on why wasn't it working with start(1000) ? is Serial.print too long to execute ?Julie96– Julie962019-02-19 13:31:33 +00:00CommentedFeb 19, 2019 at 13:31
- 1Serial print in an ISR is not recommended. Set a flag in the ISR and poll in the loop() instead.Mikael Patel– Mikael Patel2019-02-19 13:32:50 +00:00CommentedFeb 19, 2019 at 13:32
1 Answer1
You are trying to print 6 characters ("test\r\n"), i.e. 60 bitsincluding the start and stop bits, 1000 times per second. This requiresa baud rate of at least 60 kbit/s, yet the serial port has beenconfigured for only 9.6 kbit/s. Something has to give...
As Mikael Patel wrote in a comment, it is generally inadvisable toSerial.print() from within an ISR. It is supposed to work, though, aslong as you don't fill theSerial output buffer. The problem is thatyour code does fill the buffer, as it is writing to it faster than theUART can empty it. Once the buffer is full, the program willmalfunction.
Explore related questions
See similar questions with these tags.


