Hi everyone!
Did anybody can set an external interrupt on the PORT1? I want to set the Motion Detection Mode on the CMA3000 accelerometer. I've read its datasheet and i've set the following registers:
CTRL = 0x38 ------------> CTRL: [G_RANGE | INT_LEV | MD_EXIT | I2C_DIS | MODE (3:1) | INT_DIS]
MDTHR = 0x0E ---------> 571 + 286 +143 = 1000 mg (I want to set the threshold in 1G, is that correct?)
MDFFTMR = 0x30 -----> 200ms + 1/10s = 300 ms (I want to set the detection time in 300ms, is that correct?)
My current code to configure the accelerometer and port interrupt is the following:
void acc1Init(void){
uint8 readValue;
/* Clear flag and enable P1 interrupts */
P1IFG = 0;
P1IF = 0;
IEN2 = 0x10;
P1IEN |= BV(7);
accWriteReg(CTRL, RANGE_2G | I2C_DIS | MODE_400HZ_MEAS | INT_EN);
WAIT_1_3US(80);
do{
accReadReg(STATUS, &readValue);
WAIT_1_3US(80);
}while(readValue & 0x08);
}
And my ISR:
HAL_ISR_FUNCTION( accFFDPort1Isr, P1INT_VECTOR ){
HAL_ENTER_ISR();
if (P1IFG){
// More code...
}
P1IFG = 0;
P1IF = 0;
HAL_EXIT_ISR();
}
But my problem is that the accelerometer never interrupts and besides the whole system starts working wrong. Any help? Thanks in advance...
Best regards...
Martin R