- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi all,
I am using some ISR for UART UART SCB Mode ver 3.2 and using the following code
uint8 flag = 0;
CY_ISR(uartInterrupt)
{
uint32 source = 0;
flag = 1;
UART_UartPutString("\nFlag = 1\r\n");
source = UART_GetRxInterruptSourceMasked();
UART_ClearRxInterruptSource(source);
UART_UartPutChar(UART_UartGetChar());
/* `#END` */
}
int main()
{
uint32 ch;
UART_Start();
UART_SCB_IRQ_StartEx(uartInterrupt);
//UART_RX_ISR_StartEx(uartInterrupt);
/* Transmit string through UART */
CyGlobalIntEnable; /* Uncomment this line to enable global interrupts. */
UART_UartPutString ("\r\n***********************************************************************************\r\n");
UART_UartPutString ("UART Initialisedr\r\n");
for (;;)
{
ch = UART_UartGetChar();
if(flag == 1)
{
flag = 0;
ch = UART_UartGetChar();
UART_UartPutChar(ch);
UART_UartPutString("\nFlag = 0\r\n");
}
}
}
Observation :
1. Control is not coming out from ISR "CY_ISR(uartInterrupt)"
2. Could not able to clear interrupt
Please help
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Generally:
Do not use lengthy code in an interrupt handler. Sending data over the UART is very slow compared to normal CPU speed.
Do not recurse in an interrupt handler. It is not quite clear due to some missing information if you do something like that.
Every global variable that is changed in an interrupt handler should be declared as "volatile". so you need
volatile uint8 flag = 0;
This will prevent you from compiler optimizing-out redundant accesses to the variable flag. See here.
Can you please post your complete project so that we all can have a look at all of your settings. To do so, use
Creator->File->Create Workspace Bundle (minimal)
and attach the resulting file.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Generally:
Do not use lengthy code in an interrupt handler. Sending data over the UART is very slow compared to normal CPU speed.
Do not recurse in an interrupt handler. It is not quite clear due to some missing information if you do something like that.
Every global variable that is changed in an interrupt handler should be declared as "volatile". so you need
volatile uint8 flag = 0;
This will prevent you from compiler optimizing-out redundant accesses to the variable flag. See here.
Can you please post your complete project so that we all can have a look at all of your settings. To do so, use
Creator->File->Create Workspace Bundle (minimal)
and attach the resulting file.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Bob
Can you address the issue with ref to attached code?
Sham