MpAlarmXSet in C langage

I try to use MpAlarmXSet in C langage

Here is my code :

#include <bur/plctypes.h>
#include <string.h>

#ifdef _DEFAULT_INCLUDES
#include <AsDefault.h>
#endif

void _INIT ProgramInit(void)
{
  MpAlarmXCore_0.Enable = 1;
  MpAlarmXCore_0.MpLink = &(gAlarmXCore);
  
  MpAlarmXCore(&MpAlarmXCore_0); 
}

void _CYCLIC ProgramCyclic(void)
{
	if (Temperature >= 50)
	{
		MpAlarmXSet(&gAlarmXCore,'Mod1Test'); 
	}
	
	MpAlarmXCore(&MpAlarmXCore_0); 
}


void _EXIT ProgramExit(void)
{

}

When Temperature >= 50 my PLC is now in service mode.

The errors in the logger are :

Error 6804 Memory access violation occurred

Error / Processor Exception 25348 EXCEPTTION Data Abort

Could you give me the correct syntax please

Erwan

Hi,

can’t test it right now, but are you sure about the pointer to mpLink when calling mpAlarmXSet (line: MpAlarmXSet(&gAlarmXCore,‘Mod1Test’); )

In the help, there’s no pointer documented, so please try gAlarmXCore instead of &gAlarmXCore :

Best regards!

Hi,

If I use gAlarmXCore instead of &gAlarmXCore I have an error during the build :

Incompatible type for argument 1 of ‘MpAlarmXSet’

Here is the link to use mapp functions :

My syntax seems correct, i don’t see the problem !

Okay, but the Exception 25348 backtrace in the logger points to that code line?
If yes, what’s about the string? As I remember, in C strings have to be double-quoted → does “Mod1Test” instead of ‘Mod1Test’ work?

Best regards!

3 Likes

Went ahead and tested this on my side, and Alex is right, in which you’re currently using the incorrect string callout.

Incorrect:

MpAlarmXSet(&gAlarmXCore,’Mod1Test’);

Correct:

MpAlarmXSet(&gAlarmXCore,”Mod1Test”);

This should allow you to compile and trigger the alarm.

Also, If you look at the example from the help explorer link you posted, it also shows that you would use “ “ when using C. using ‘ ‘ would be for when you’re coding in ST.

2 Likes

Hi @Erwan_Boulch , when you have time read this best practice page in the Help to avoid the activation of your alarm in each cycle:


Ciao
Valerio

It works with double quoted.

Thanks a lot for the support

Best regards

Erwan

1 Like