c++ - Atmel Studio 7: USART interrupt handler provided by ASF library works once only in case of encountering infinite loop in main()? -
currently, using usart_read_buffer_job function provided asf library. placed function inside while(1) loop below:
int main() { pieces of code initialization; while(1) { usart_read_buffer_job(); while(1) // second infinite loop { other pieces of code; } } }
it works first interrupt handler call. however, after returning handler, no longer able call interrupt handler. program kept running within second infinite loop , not able execute usart_read_buffer_job() again. cause of handler 's malfunction.
in case, purpose jump usart interrupt handler regardless of number of infinite loops being executed in main(). of course, not using asf, issue solved manually set handler still wonder how issue solved other functions provided asf.
looking forward getting response community soon. thank you,
thanks quick response.
the code working on confidentials. hence, share asf library functions , explain briefly how work.
in asf, typically, have 2 functions handling interrupt, namely usart_read_buffer_job , usart_read_job
before using these 2 functions, handler calls defined 2 functions:
usart_register_callback: registers callback function, implemented user.
usart_enable_callback: callback function called interrupt handler when conditions callback type met.
and these 2 functions above placed in initialization code shown in question.
then, depending on design purpose, handlers called whenever character or group of characters received via uart peripherals using usart_read_buffer_job/usart_read_job respectively.
usart_read_buffer_job: sets driver read usart given buffer. if registered , enabled, callback function called.
usart_read_job: sets driver read data usart module data pointer given. if registered , enabled, callback called when receiving completed.
you find more details these functions on http://asf.atmel.com/docs/latest/samd21/html/group__asfdoc__sam0__sercom__usart__group.html
in case, assumming main program stalls due unexpected infinite loops, handlers should still work @ anytime after receiving command invoked uart peripherals , important tasks solve out problems, example.
hope explanation makes previous question clearer. and, hope response of soon.
Comments
Post a Comment