Page 1 of 1

Can i use switch case in ISR

PostPosted: Tue Jun 23, 2009 9:38 am
by anjali
I’m using PIC microcontroller can I use switch case in UART receive interrupt service routine pls. guide.

Re: Can i use switch case in ISR

PostPosted: Thu Jun 25, 2009 5:13 pm
by violin
I’m using PIC microcontroller can I use switch case in UART receive interrupt service routine pls. guide.

This is not a valid microcontroller question. The only sole purpose of this type of wording is an obvious attempt to confuse!!!

Re: Can i use switch case in ISR

PostPosted: Mon Jul 06, 2009 4:04 am
by santhoshM
Hi anjali,

We can use switch case in ISR. No restrictions, unless theres any sort of time critical constraints in our project.
In such cases its always a good practise not to included much of codes in ISR. I would suggest you to move the received data into a variable/array, 've a global flag to indicate the data reception in UART, check for the flag in main flow and process the data as per your requirement.

Cheers,
Santhosh :)

Re: Can i use switch case in ISR

PostPosted: Mon Sep 18, 2017 11:23 am
by shujat2
Yes You can use Switch case in ISR without any interrupt.It isn't uncommon with switch statements in an ISR, to decide which of several actions to perform, depending on the reason for the interrupt.
switch (CommandState)
{
case (0):
random code here
break;
}
But I prefer If-else Statement
if(Command State==0)
{
random code here
}
Content Details: http://www.cetpainfotech.com/technology/matlab-training