flag processing in main not work but in ISR yes!!!!

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

HI my problem is this:

i set a flag (CmdCpuFlag) inside an ISR of uart. on the main inside while(1) ceck the status by CeckCmdFlag() of this flag and if is ==1 send one char on uart.

IF I WRITE CeckCmdFlag() INSIDE THE ISR (UartData_C) WORKING.
IF I WIRTE CeckCmdFlag() INSIDE THE WHILE(1) (UartData_C) NOT WORKING. !!!

WHY????? I SET THE FLAG AND INSIDE WHILE(1) CECK IF THIS FLAG IS SETTED send char and reset the flag to 0... NOTHING MORE!!!


#include <m8c.h> // part specific constants and macros
#include "PSoCAPI.h" // PSoC API definitions for all User Modules
#include <stdlib.h>
#include <string.h>

#pragma interrupt_handler UartData_C

BYTE comm=0;
unsigned char CmdCpuBuffer[255];
char CmdCpuFlag=0;

void UartData_C(void)
{
static char Cmd=0,Count=0,DataCount;
Cmd=UART_1_cReadChar();
CmdCpuBuffer[Count]=Cmd;
if (Count==1)
{
DataCount=Cmd+3;
}

if (Count>1)
{
DataCount--;
if(DataCount==0)
{
CmdCpuFlag=1;
Count=0;
}
}
Count++;
UART_1_PutChar(Cmd);

}


void main()
{
M8C_EnableGInt;
M8C_EnableIntMask(INT_MSK0,INT_MSK0_GPIO);
Timer16_1_EnableInt();
Timer16_1_Start();
UART_1_CmdReset();
UART_1_IntCntl(UART_1_ENABLE_RX_INT);
UART_1_Start(UART_1_PARITY_NONE);

while(1)
{
CeckCmdFlag();
}
}



void CeckCmdFlag(void)
{
if(CmdCpuFlag==1)
{
UART_1_PutChar(0x09);
UART_1_PutChar(0x09);
UART_1_PutChar(0x09);
CmdCpuFlag=0;
}
}

0 Likes
2 Replies
Anonymous
Not applicable

 It is hard to read your code without the formatting. how about post your project here for people to check

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

The problem was already solved in the PSoCDeveloper F<orum, this is a double post.

   

Bob

0 Likes