Hello friends,
I am devolopment on mm9z1_638. I use ADC to get current,voltages and temperatures.
I sleep the uC for every 1 minute. There is two condition for wake up.
One is depends on timer and another is current threshold. But every time isrD2DErr interrupt handled and code is stuck in there.
If I not open current threshold, error is not happen.
If a reset uC software run until error occur.
D2DSTAT0 register is : 10010001.
Error context is:
Time Out Error Flag — This read-only flag indicates the initiator has detected a timeout error. This flag is cleared when the ERRIF bit is cleared by writing a 1 to the ERRIF bit.
Also when I test with debugging I saw program stuch at PGAAutoZero(); function.
My sleep code sequence is :
void Sleep()
{
DDRA_DDRA7 = 1;
PTA_PTA7 = 0;
InitSleepTimer();
ADCDisable();
TsenseDisable();
B_GPIO_VSENSE = 0;
ADCLpEnable();
InitSleepCurrent();
CAN_STDBY(STANDBYMODE);
PTA_PTA1 = 0;
PCREnterStopMode();
//sleep here
B_WD_CTL = WD_OFF;
MeasurementStart(); // function is init V,I and T channels and ADCInit
CAN_STDBY(NORMALMODE);
DDRA_DDRA7 = 1;
PTA_PTA7 = 1;
}
void InitSleepTimer()
{
B_GPIO_CTL = B_GPIO_CTL_DIR3M_MASK | B_GPIO_CTL_DIR3_MASK;
// route Timer OC3 to PTB3
B_GPIO_OUT3_TCOMP3 = 1;
// set Timer Ch3 to OC
B_TIOS_IOS3 = 1;
B_TSCR1_TEN = 1;
B_TCTL1 = 0x80; // clear on OC
B_CFORC_FOC3 = 1; // force OC
B_TSCR1_TEN = 0; // disable timer because it will start start of sleep mode
// setup a rising edge in 10s
B_TCTL1 = 0xC0; // set on OC
//B_TC3 = B_TC3 + 60000; // reload 60s
B_TC3 = B_TC3 + 5000;
B_TFLG1_C3F = 1;
B_PCR_WUE_WUPTB3 = 1; //enable wakeup on ptb3 (rising edge)
}
void InitSleepCurrent()
{
B_ACQ_CTH = 100;
B_PCR_WUEH_WUCTH = 1;
}
Error interrupt is :
interrupt VectorNumber_Vd2di_err void isrD2DErr(void) {
while(1) {
if(D2DSTAT0_ERRIF) {
D2DSTAT0_ERRIF = 1; // clear flag
}else{
PCRReset(); // issue an analog die reset
}
}
}
TYPE_DRV638_RETURN PGAAutoZero(void) {
if(!B_ACQ_CTL_CMEN) // current measurement ACQ must be active
return ERR_CONFIG;
B_COMP_CTL = PGAAutoZeroEnableMask; // PGA Input Zero and start PGA Offset compensation sequence
while(!B_COMP_SR_PGAOF) DO_NOTHING; // wait until PGA AutoZero sequence finished
B_COMP_CTL = PGAAutoZeroDisableMask; // disable PGA Input Zero and PGA Offset compensation sequence
B_COMP_SR = B_COMP_SR_PGAOF_MASK ; // clear flag (after disable)
return OK;
}
code stuch at while(!B_COMP_SR_PGAOF) DO_NOTHING;
Please someone can help me.
Best regards.
@WolfgangBihlmayr
yes I saw without debugger. Also i tried sleep mode now. And I read mcu's datasheet that say "Having any analog die IRQ allowed when entering Low-power mode is not recommended".
Now i am trying with this sleep code but error is exist.
void Sleep()
{
DDRA_DDRA7 = 1;
PTA_PTA7 = 0;
InitSleepTimer();
InitSleepCurrent();
TsenseDisable();
B_ACQ_CTL = ACQIntDisableMask;
CAN_STDBY(STANDBYMODE);
PCREnterSleepMode();
//sleep here
B_WD_CTL = WD_256ms; */
B_WD_CTL = WD_OFF;
B_ACQ_CTL = ACQIntEnableMask;
TsenseEnableExtSensor();
TsenseEnableIntSensor();
CAN_STDBY(NORMALMODE);
DDRA_DDRA7 = 1;
PTA_PTA7 = 1;
}
Hi,
The error is most likely related to the VDDH / VDDD2D being 0V, whilst the uC tries to access the D2D interface (read/write to registers on the analog die). This would generate such a D2Derror.
With the debugger connected the uC will not enter STOP mode (limitation of the MM9Z1_638 device). Do you see the same issue without the debugger connected?
Rgds
Wolfgang