大家好。
我们为客户制造的150种热湿度计存在问题、我们使用的是 MSP430G2955。
由于电路由电源适配器和锂电池供电、因此电路始终处于打开状态、通过按下连接到 P1.1的按钮并保持按住6秒钟来完成点火、 另一个按钮连接到 P1.0、根据按下该按钮的时间长度、将器件置于设置模式。
当我加载固件并使用调试器执行测试时、器件会正确打开、当我拔下电源插头并在没有 FET 编程器的情况下将其打开时、器件也会正确打开、但在一天之后器件无法打开、我不知道原因。
我已经尝试了所有操作、使用 while 循环、并将其从此处读取 P1IN、中断、组合中断和读取引脚的状态。 当使用中断时、我注意到 GIE 位没有明显的原因变为零、所以我执行了一个例程来持续检查中断的状态并将其复位。
我最后尝试的是每小时连续重启微控制器、以防止它随着时间的推移而变得无响应、我再次启用 WDT、 但即使所有这些设置都是相同的、在一两天后、器件停止响应、并且不会开启。
此时、我仍然不知道正在发生什么、我不知道它是否会影响附近有钕磁铁(它们用于将器件粘附到冰箱中)的事实。
由于代码范围很广(超过4、000条线路)、我只连接参考点火开关的线路。电路有两个电压调节器、第一个电压调节器使 MSP430G2955始终保持开启、第二个电压调节器在微控制器引脚 P4.7启用时接通电路的其余部分。 很抱歉、代码太乱了、有时是多余的、但我对它做了很多修改、但仍然没有正确调试、这是程序目前的状态。
void Hab_int()
{
if (__get_SR_register() & GIE){__delay_cycles (1);} // GIE
else{__bis_SR_register(GIE);}
if (P1DIR & BIT0){P1DIR &=~BIT0;} // pulsadores
if (P1DIR & BIT1){P1DIR &=~BIT1;}
if (P1SEL & BIT0){P1SEL &=~BIT0;} // Func Especiales
if (P1SEL & BIT1){P1SEL &=~BIT1;}
if (P1SEL2 & BIT0){P1SEL2 &=~BIT0;} // Func Especiales
if (P1SEL2 & BIT1){P1SEL2 &=~BIT1;}
if (P1IE & BIT1){__delay_cycles (1);} // hab interrupcion P1.1
else {P1IE |= BIT1;}
if (P1IES & BIT1){P1IES &=~BIT1;} // Interrupción por flanco de subida
if (P1IFG & BIT1){P1IFG &= ~(BIT1);} // baja flag de interrupción de P1.1
}
void confini()
{
Hab_int();
retardo_ver(); ////delay 2 seg
P3DIR |=BIT7;
P3OUT |=BIT7; //Linea CS
P3DIR |=BIT6;
P3OUT |=BIT6; //Linea RD
P3DIR |=BIT5;
P3OUT |=BIT5; //Linea WR
P3DIR |=BIT4;
P3OUT |=BIT4; //Linea DATA
P1DIR |=BIT5;
P1DIR &=~BIT4;
P1OUT |=BIT5; // pines de comunicacion con el ESP
P4DIR |=BIT6;
P4OUT |=BIT6; // Tx Texas y Rx SIM7070
P2DIR &=~BIT3; //Rx Texas y Tx SIM7070
P4DIR &=~BIT5;
P4DIR |=BIT4;
P4OUT |=BIT4; //CTS entrada RTS salida
P3DIR &=~BIT3;
P3DIR |=BIT2;
P3OUT |=BIT2; //pines bluetooth
P2SEL |=BIT2; //canal ADC para el voltaje de la bateria
P4DIR |=BIT3;
P4OUT &=~BIT3; // pin pwrkey
P4DIR &=~BIT1; //señal de bateria
retardo_ver(); //1/2tiempo necesario pin pwrkey
P4OUT |=BIT3;
retardo_ver();
P4OUT &=~BIT3; //pulso en pwrkey
LCD_comando(2)
;retardo_com(); //comando LCD_off
LCD_comando(1);
retardo_com(); //comando Sys_en
LCD_comando(24);
retardo_com(); //comando RC-256K
LCD_comando(43);
retardo_com(); //comando Bias 1/3, 4 comunes
LCD_comando(227);
retardo_com(); //comando normal
LCD_comando(3);
retardo_com(); //comando LCD_on
retardo_tecla();
operativo1=0;
operativo2=0;
operativo3=0;
operativo4=0;
operativo5=0;
operativo7=0;
temporal1=0;
temporal2=0;
temporal3=0;
temporal4=0;
return;
}
int main(void)
{
__delay_cycles (1000);
WDTCTL = WDTPW | WDTHOLD;
__delay_cycles(1000000UL);
BCSCTL1 = CALBC1_8MHZ;
DCOCTL = CALDCO_8MHZ;
contreset=0;
estado=0;
retardo_tecla(); //espero para que se estabilice el inicio
SDA_configsal;
SCL_configsal;
SCL_bajo;
SDA_bajo;
retardo_ver();
limite=LEER_Ver(0x98); //I read the EEPROM memory address where I store if the device is on (1) or off (0)
while (1)
{
Hab_int();
while (estado==0)
{
P1DIR=0;
P2DIR=0;
P3DIR=0;
P4DIR=0x01; //dejo el 4.0 como salida para el pin de activacion
P4OUT&=~BIT0; // Turn off the device
retardo_ver(); //doy tiempo para que se apaguen bien los modulos
P1DIR &=~BIT0;
P1DIR &=~BIT1; // pulsadores
SDA_configsal;
SCL_configsal;
SCL_bajo;
SDA_bajo;
retardo_com(); // estado inicial I2C
if (limite=='1')
{
P4OUT|=BIT0; //Turn on the device
confini();
for(cont=0;cont<32;cont++) //Clear the LCD Screen
{
escribir_LCD(cont,0);tbit (30000);
}
estado=10;
}
else{estado=5;}
}
while (estado==5)
{
retardo_med();
Hab_int();
contreset++;
if (contreset==5900)
{
WDTCTL = WDTPW;
retardo_med(); //delay 1 seg
contreset=0;
}
}
while (estado==8)
{
if (P1IN & BIT1)
{
sostenedor=0;
configura=0; //Blanqueo el registro para el tiempo de encendido
while (sostenedor<=40)
{
retardo_tecla();
if (P1IN & BIT0){configura++;}
if (P1IN & BIT1){sostenedor++;}
else{sostenedor=100;}
}
if(sostenedor<99)
{
P4OUT|=BIT0; //Turn On the device
P1DIR &=~BIT1;
P1DIR &=~BIT0;
confini();
apagador=0;
ESC_Ver(0x98,'1'); I write 1 in the EEPROM memory address where I store the state of the device.
for(cont=0;cont<32;cont++)
{
escribir_LCD(cont,0);
tbit (30000);
} //Blanqueo la pantalla
if (configura==0){estado=10;}
else
{
if (configura<12){estado=140;}
else
{
if (configura<25){estado=100;}
else{estado=40;}
}
}
retardo_tecla();
}
else{estado=5;}
}
else{estado=5;}
retardo_tecla();
}
......... more program
#pragma vector=PORT1_VECTOR
__interrupt void P1_ISR(void)
{
char registro;
char sostenedor;
char contadort;
if (P1IFG & BIT1) // comprobar fuente de la interrupción P1.1
{
registro=LEER_Ver(0x98); //indico en memoria que el dispositivo esta apagado
if (registro=='1')
{
sostenedor=0; //Blanqueo el registro para el tiempo de encendido
while (sostenedor<=12)
{
retardo_tecla();
P1DIR &=~BIT1;
if (P1IN & BIT1){sostenedor++;}
else{sostenedor=100;}
}
if(sostenedor<99)
{
ESC_Ver(0x98,'0'); //indico en memoria que el dispositivo esta apagado
limite=LEER_Ver(0x98); //
estado=0;
P4OUT&=~BIT0; //turn off the device
apagador=10;
retardo_ver();
P1DIR=0;
P2DIR=0;
P3DIR=0;
P4DIR=0x01; //dejo el 4.0 como salida para el pin de activacion
P1DIR &=~BIT1;
P1DIR &=~BIT0; // pulsadores
P1IE |= BIT1; // habilita la interrupción de P1.1
P1IES &=~BIT1; // Interrupción por flanco de subida
P1IFG &= ~(BIT1); // baja flag de interrupción de P1.1
}
}
else
{
estado=8;
}
P1IFG &= ~BIT1; // puesta a cero del flag de interrupción P1.1
}
else
{
estado=0;
apagador=10;
ESC_Ver(0x98,'1'); //indico en memoria que el dispositivo esta encendido
P4DIR|=BIT7;
retardo_tecla();
P4OUT |=BIT7;
retardo_tecla();
}
return;
}