0

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...

results

my code

askedFeb 19, 2019 at 10:51
Julie96's user avatar
3
  • 1
    I guess you meanstart(1000000).CommentedFeb 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 ?CommentedFeb 19, 2019 at 13:31
  • 1
    Serial print in an ISR is not recommended. Set a flag in the ISR and poll in the loop() instead.CommentedFeb 19, 2019 at 13:32

1 Answer1

1

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.

answeredFeb 19, 2019 at 21:13
Edgar Bonet's user avatar
0

Your Answer

Sign up orlog in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

By clicking “Post Your Answer”, you agree to ourterms of service and acknowledge you have read ourprivacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.