HCS08GT60 __isflag_int()

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

HCS08GT60 __isflag_int()

4,599 次查看
StevePratt
Contributor I
I am trying to use the __isfalg_int() macro to poll the level of the ext int pin, I keep getting compiler errors? How can i do this? Is the following format correct?
 
static void test(void)
{
   if (__isflag_int()) goto label;
   
       
label:   
}
Warning : C1801: Implicit parameter-declaration for '__isflag_int'
GPS_Buoy_Receiver.c line 1680  
Error   : C2801: ';' missing
GPS_Buoy_Receiver.c line 1683  
Error   : C2450: Expected:  { IDENT auto break case const continue default do extern for goto if register return static switch typedef
volatile while __asm __interrupt     
GPS_Buoy_Receiver.c line 1684  
Error   : Compile failed
 
标签 (1)
0 项奖励
回复
3 回复数

641 次查看
CrasyCat
Specialist III
Hello
 
Which processor are you targeting?
Intrinsic function __isflag_int is available in CodeWarrior HC08 V5.0 and V3.1.
 
I have used following code there and it links without trouble:
 if(__isflag_int())
 {
     var = 2;
 } else
 {
     var = 1;
 } 
 
CrasyCat
0 项奖励
回复

641 次查看
CompilerGuru
NXP Employee
NXP Employee
as final comment, after all the real things have been said by the other repliers.
The original sample does not compile because in ANSI-C, there has to be a statement after a label. So "void bug() {l:}" is illegal, void ok(void) { label:; } compiles.
But try to avoid labels & goto in the first place.
0 项奖励
回复

641 次查看
alex_spotw
Contributor III
Hi:

Chances are you're not including the .h file where the _isflag_int() function is declared (which is indicated by the Warning).


Warning : C1801: Implicit parameter-declaration for '__isflag_int'


I would suggest enable the compile option 'Error on Implicit declaration', which will catch these errors and will prevent many headaches.

Also, it is strongly suggested not to use the 'goto' statement. It leads to bad programming habits.

I would do something like


static void test(void)
{
if(EXT_INT_GetVal() == FALSE)
{
// External INT pin is LOW
// Do action
}
else
{
// External INT is HIGH
// Do other action
}
}



The EXT_INT_GetVal() function can autogenerated if you have Processor Expert. Otherwise, you can create you own version by checking the IRQF flag in the IRQSC register (assuming you enable the Ext IRQ function and set up the correct edge/level).

Regards,

Alex R.

Message Edited by alex_spotw on 03-28-200604:16 PM

0 项奖励
回复