AnsweredAssumed Answered

Discovery F4/STM32f407VG sometimes gets Stuck/Stoned

Question asked by anton.bogdan on Oct 11, 2014
Latest reply on Oct 11, 2014 by Clive One
Hi guys, i am quite new to the ARM platform ( i think i have 6-7 months since i started playing with my ST board)
Yesturday i started working on a small library for BMP085 sensor.  My whole work is done in C, using IAR compiler.
The code works well, but my main concern is why after random periods 10-30 minutes, its stops.. if i reset from the button on the board, it works again...
I had this isue even on other projects

In the future i plan do make a little quadcopter using this discovery board, and i`m starting to get woried, supose its in the air, and the soft halts...
Where is this halting comes? And how can i prevent such halts?

Thanks


This is my current project

#define rAddr 0xEF
#define wAddr 0xEE
 
 
int16_t AC1=8340;
int16_t AC2=-1232;
int16_t AC3=-14440;
int16_t AC4=-31743;
int16_t AC5=24449;//old 32757;
int16_t AC6=25123;// old 23153;
int16_t MB=-32768;
int16_t MC=-11075;// old -8711;
int16_t MD=2432;// old 2868;
int16_t B1=5498;
int16_t B2=67;   
 
char txt3[15];
char txt2[15];
char txt4[15];
 
 
 
 
void get_raw_pressure(){
int oss=3;
long UT,UP;
 
i2c_send_cmd(wAddr,0xF4,0x2E);
delay_nms(5);
i2c_start_com();
i2c_wrAddr(wAddr);  
i2c_Wrbyte(0xF6);
I2Cx->CR1 |= I2C_CR1_STOP;
i2c_start_com();
i2c_rdAddr(rAddr);
uint8_t tMSB = i2c_rdAck();  
uint8_t tLSB  = i2c_rdNack();
UT=(tMSB<<8)+tLSB;
//UT=27898;
I2Cx->CR1 |= I2C_CR1_STOP;
//////////////////
i2c_send_cmd(wAddr,0xF4,(0x34+(oss<<6)));
delay_nms(15);
i2c_start_com();
i2c_wrAddr(wAddr);  
i2c_Wrbyte(0xF6);
I2Cx->CR1 |= I2C_CR1_STOP;
i2c_start_com();
i2c_rdAddr(rAddr); 
uint8_t hMSB = i2c_rdAck();
uint8_t lMSB = i2c_rdAck();  
uint8_t LSB  = i2c_rdNack();
I2Cx->CR1 |= I2C_CR1_STOP;
UP = ((hMSB<<16)+(lMSB<<8)+LSB)>>(8-oss);
 
 
long X1,X2,X3,B6,B3,B5;
unsigned long B4,B7;
long pp;
float tt;
 
 
X1=(UT-AC6)*AC5>>15;
X2=(MC<<11)/(X1+MD);
B5=X1+X2;
tt=(B5+8)>>4;
tt /=10;
 
sprintf(txt2,"%f",tt);
lcd_char(2,1,txt2);
 
 
///// presure calculation
B6=B5-4000;//-1600 k
X1=(B2*((B6*B6)>>12))>>11;// k
X2=(AC2*B6)>>11;//k
X3=X1+X2; //57 k
B3=(((AC1*4+X3)<<oss)+2)>>2;//k
X1=(AC3*B6)>>13;//k
X2=(B1*((B6*B6)>>12))>>16;
X3=((X1+X2)+2)>>2;
B4=(AC4*(uint32_t)(X3+32768))>>15;
B7=((uint32_t)(UP-B3)*(50000>>oss));
if(B7<0x80000000){pp=(B7<<1)/B4;} else { pp=(B7/B4)<<1;}//70003
X1=(pp>>8)*(pp>>8);
X1=(X1*3038)>>16;
X2=(-7357*pp)>>16;
int32_t pres=pp+((X1+X2+3791)>>4);
 
 
// pres /=100;
float    hpa=pres/100; // convert pascal to hecta Pascal
//calculate altitude
float  altitude = 1 - pow( (hpa/1013.25),0.1903 );
       altitude *= 44330;
 
sprintf(txt4,"%d",pres);
lcd_char(1,1,txt4);
 
 
sprintf(txt3,"%f",altitude);
lcd_char(3,1,txt3);
 
       }
               
 
 
int main(void){
SystemInit();
SysTick_Init();
lcd_init();
Serial_I2c_Init();
 
while(1){
get_raw_pressure();
delay_nms(300);
}
}
 
   


Outcomes