- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
We are implementing UART and timer peripherals using interrupt
At Power ON variables/flags which are used in UART or Timer ISR are declared as '0' and in ISR value for these variables is set to '1' on ISR successful execution of ISR. Though variables are getting updated in ISR but their updated values are not available in main loop or other functions.
Variables are defined as 'Volatile' even tried with no optimization option but still remains same.
Code is tested with PSoC created 4.1 and PSoC created 4.3.
Please help to resolve the issue.
Code for timer and UART is attached for reference
With Regards,
Harshal Belan
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
By any chance, have you seen following topic?
global variables updated in ISR does not updated in main loop
I wonder if the attachment of my last response can work for you or not.
The main.c was
=================
#include "project.h"
volatile uint8 gb_char = 0;
volatile char flag = 0 ;
CY_ISR(Uart_Rx_Interrupt)
{
UART_ClearRxInterruptSource(UART_INTR_RX_NOT_EMPTY) ;
if (UART_SpiUartGetRxBufferSize()) {
gb_char = UART_UartGetChar();
if(gb_char == 0x23)
{
flag = 1;
UART_SpiUartWriteTxData(gb_char);
}
}
}
void Uart_Initialize (void)
{
UART_Start();
UART_SpiUartClearRxBuffer() ;
UART_SpiUartEnableIntRx(UART_INTR_RX_NOT_EMPTY) ;
Uart_isr_StartEx(Uart_Rx_Interrupt);
}
int main(void)
{
CyGlobalIntEnable; /* Enable global interrupts. */
Uart_Initialize();
for(;;)
{
if(flag == 1)
{
// flag = 0 ;
led17_Write(1);
}
if(flag == 0)
{
led17_Write(0);
}
}
}
=================
moto
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
By any chance, have you seen following topic?
global variables updated in ISR does not updated in main loop
I wonder if the attachment of my last response can work for you or not.
The main.c was
=================
#include "project.h"
volatile uint8 gb_char = 0;
volatile char flag = 0 ;
CY_ISR(Uart_Rx_Interrupt)
{
UART_ClearRxInterruptSource(UART_INTR_RX_NOT_EMPTY) ;
if (UART_SpiUartGetRxBufferSize()) {
gb_char = UART_UartGetChar();
if(gb_char == 0x23)
{
flag = 1;
UART_SpiUartWriteTxData(gb_char);
}
}
}
void Uart_Initialize (void)
{
UART_Start();
UART_SpiUartClearRxBuffer() ;
UART_SpiUartEnableIntRx(UART_INTR_RX_NOT_EMPTY) ;
Uart_isr_StartEx(Uart_Rx_Interrupt);
}
int main(void)
{
CyGlobalIntEnable; /* Enable global interrupts. */
Uart_Initialize();
for(;;)
{
if(flag == 1)
{
// flag = 0 ;
led17_Write(1);
}
if(flag == 0)
{
led17_Write(0);
}
}
}
=================
moto