AnsweredAssumed Answered

[KL46Z] Magnetometer MAG3110 interrupt

Question asked by Rafal Jablonski on Dec 9, 2017
Latest reply on Dec 12, 2017 by Rafal Jablonski

I have a problem with configuring MAG3110  interrupts. The PTD1 pin is always HIGH.

 

#include "mbed.h"
#include "MAG3110.h"
MAG3110 mag(PTE25, PTE24);
Serial pc(USBTX, USBRX);
MotionSensorDataCounts mag_raw;
InterruptIn mag_interrupt(PTD1);

void flip() {
    mag.getAxis(mag_raw);
    float x;
    x = ((float) mag_raw.x) / 10.0f;
    pc.printf("Mag x=%4.1f\r\n", x);
    wait(1.0);
}

int main(void){
    pc.baud(9600);
    mag.enable();
    mag_interrupt.rise(&flip);
    while(1) {
      sleep();
    }
}

Outcomes