I finally solved the problem. When I was pointing X to the north and 60° down, i had something like [0 0 150]. Y to the same direction: [-150 0 0] and Z, [0 150 0].
So I modified the channels in aspirin.h:
#define IMU_MAG_X_CHAN 2 /* X in Z */
#define IMU_MAG_Y_CHAN 0 /* Y in X */ #define IMU_MAG_Z_CHAN 1 /* Z in Y */
And I also modified the sign of Y:
#define IMU_MAG_Y_SIGN -1
After these modifications the AHRS filter measures correctly the yaw: I don't have any more weird transients. Thank you for your help.
I think I have an aspirin V2.0. I'm surprised that I had to change the code in aspirin.h, there is no other way to do that?