1.

The following piece of code uses __interrupt keyword to define an ISR. Comment on the correctness of the code.

Answer»

__interrupt double calculate_circle_area (double radius){ double circle_area = PI ∗ radius ∗ radius; printf ( 'Area = %f ' , circle_area); return circle_area;}

Following things are wrong with the given PIECE of CODE:

  • ISRs are not supposed to return any VALUE. The given code returns a value of datatype double.
  • It is not possible to pass parameters to ISRs. Here, we are PASSING a parameter to the ISR which is wrong.
  • It is not advisable to have printf inside the ISR as they are non-reentrant and thereby it impacts the performance.


Discussion

No Comment Found