TRAPS_halt_on_error!

Author
IvanP
New Member
  • Total Posts : 29
  • Reward points : 0
  • Joined: 2014/11/14 05:00:13
  • Location: 0
  • Status: offline
2017/10/05 08:10:42 (permalink)
0

TRAPS_halt_on_error!

Hello,
i have a big problem, my project generate "TRAPS_halt_on_error" on I2C.
The TRAPS_error_code is 2.

This is my state machine to write in EEPROM 24LC64.
prototypes:
void to_eeprom(struct StatusEEPROM *,struct structEEPROM *,void *punta, unsigned char dim, unsigned int start_position);
 
Declaration:
#define DIM_EEPROM 8
struct StatusEEPROM{
uint8_t status;
};
struct StatusEEPROM StEEPROM;
// ***** area parametri da salvare in EEPROM *****
struct structEEPROM {
unsigned char AddH;
unsigned char AddL;
unsigned int Offset;
unsigned int Amp;
unsigned char DataEven;
unsigned char checksum ;
};
struct structEEPROM ParamEEPROM; //reserve place in RAM
 

In main program call:
to_eeprom (&StEEPROM,&ParamEEPROM,&ParamEEPROM.AddH, DIM_EEPROM, 0);
 
Function:
void to_eeprom(struct StatusEEPROM *eep,struct structEEPROM *dati,void *punta, unsigned char dim, unsigned int start_position){

unsigned char n;
uint8_t i;
static uint8_t StateWriteEEPROM;
static uint8_t CountWriteEeprom = 0;
static uint8_t writeBuffer[18];

if (SalvaParam == 0)return;

switch (StateWriteEEPROM){
case 0:
eep->status = WRITE_EEPROM_START;

dati->checksum = 0;
for (n = 0; n < (dim -1); n++) {
dati->checksum = dati->checksum ^ ((unsigned char*)punta)[n] ^ 0x89;
}
for (i = 0; i < dim;i++){
writeBuffer = ((unsigned char*)punta);
}
I2C1_MESSAGE_STATUS status = I2C1_MESSAGE_PENDING;

// dati->AddH = (start_position >> 8); // high address
// dati->AddL = (uint8_t)(start_position); // low address
// I2C1_MasterWrite(&dati->AddH,dim,MC24LC64_ADDRESS,&status);
I2C1_MasterWrite(writeBuffer,dim,MC24LC64_ADDRESS,&status);
t_gen_eeprom = SLAVE_I2C_TIMEOUT_RISPOSTA;
StateWriteEEPROM++;
break;
case 1:
if (status == I2C1_MESSAGE_FAIL && t_gen_eeprom == 0){
CountWriteEeprom++;
StateWriteEEPROM = 0;
if (CountWriteEeprom == 5)eep->status = N_MAX_WRITE_EEPROM;
break;
}

while(status == I2C1_MESSAGE_PENDING){
eep->status = WRITE_EEPROM_PENDING;
break;
}

if (t_gen_eeprom != 0 && status == I2C1_MESSAGE_COMPLETE){
t_writeEEPROM = 10; //10ms attesa fine scrittura
StateWriteEEPROM++;
}
if (t_gen_eeprom == 0){
eep->status = TIMEOUT_EEPRROM;
}
break;
case 2:
if (t_writeEEPROM == 0){
StateWriteEEPROM = 0;
SalvaParam = 0;
eep->status = WRITE_EEPROM_OK;
}
break;
}
}
#1

1 Reply Related Threads

    IvanP
    New Member
    • Total Posts : 29
    • Reward points : 0
    • Joined: 2014/11/14 05:00:13
    • Location: 0
    • Status: offline
    Re: TRAPS_halt_on_error! 2017/10/13 03:33:10 (permalink)
    0
    SOLVED
    I moved "I2C1_MESSAGE_STATUS status = I2C1_MESSAGE_PENDING;" out of switch case and FUNCTION.
    Ivan
    #2
    Jump to:
    © 2017 APG vNext Commercial Version 4.5