HCS08GT60 __isflag_int()

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

HCS08GT60 __isflag_int()

4,929件の閲覧回数
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 返答(返信)

971件の閲覧回数
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 件の賞賛
返信

971件の閲覧回数
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 件の賞賛
返信

971件の閲覧回数
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 件の賞賛
返信