Cypress Perform

Home > Design Support > Cypress Developer CommunityTM > Cypress Forums > PSoC® 1 > flag processing in main not work but in ISR yes!!!!

Bookmark and Share
Cypress Developer CommunityTM
Forums | Videos | Blogs | Training | Rewards Program | Community Components



flag processing in main not work but in ISR yes!!!!
Moderator:
ARVI

Post Reply
Follow this topic



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

appavito posted on 04 Feb 2012 8:02 AM PST
Member
2 Forum Posts

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;
}
}




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

H L posted on 04 Feb 2012 06:18 PM PST
Top Contributor
679 Forum Posts

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



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

Bob Marlowe posted on 05 Feb 2012 11:14 PM PST
Top Contributor
1768 Forum Posts

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

Bob






ALL CONTENT AND MATERIALS ON THIS SITE ARE PROVIDED "AS IS". CYPRESS SEMICONDUCTOR AND ITS RESPECTIVE SUPPLIERS MAKE NO REPRESENTATIONS ABOUT THE SUITABILITY OF THESE MATERIALS FOR ANY PURPOSE AND DISCLAIM ALL WARRANTIES AND CONDITIONS WITH REGARD TO THESE MATERIALS, INCLUDING BUT NOT LIMITED TO, ALL IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT OF ANY THIRD PARTY INTELLECTUAL PROPERTY RIGHT. NO LICENSE, EITHER EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, IS GRANTED BY CYPRESS SEMICONDUCTOR. USE OF THE INFORMATION ON THIS SITE MAY REQUIRE A LICENSE FROM A THIRD PARTY, OR A LICENSE FROM CYPRESS SEMICONDUCTOR.

Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Terms and Conditions of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Terms and Conditions of this site. Cypress Semiconductor and its suppliers reserve the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.

Spec No: None; Sunset Owner: GRAA; Secondary Owner: RAIK; Sunset Date: 01/01/20