Hi Kerry,
I have verified with stronger pullups but can't see any differens, the big issue seems like when you are powering up the board during debug it will halt directly after main and the bus is busy, when application runs in release mode it will start to send and receive, however it might stop or it will run for days as I read the pressure and temperature from LPS25HB. Due to high current(17mA) I'm not using LSM6DS3(but it actually worked for days) so that IC is removed. I'm not using the eeprom but it's mounted on the board. The circuit board is small and very short traces to I2C so that is not an issue. Yes, I'm using MCUXpresso IDE + SDK 2.3.1 MKL02xx, and I try to avoid using any drivers since they manage to occupie to much flash, but I'm also aware of the risk of it, specially timing and handling error regarding I2C. It's difficult to accept that it has been working for days and now it's not and no changes on the hardware so far. Below is the main code all the way to the while loop.
void main(void)
{
__disable_irq();
BOARD_InitBootClocks();
DBG_Init();
IRQ_PORT_Init();
UART0_Init();
TPM1_Init();
I2C_Init();
SysTick_Init();
/* set position */
i2c.rx_buff_ptr = EE_BLOCK0;
/* read block 0, 8 bytes from address eeprom block 0 - 7 */
I2C_BlockRead(ADR_24LC02B, EE_BLOCK0, &i2c.rx_buff[i2c.rx_buff_ptr], EE_BLK_SIZE);
/* verify ram if eeprom formatted */
if(!(Verify_Eeprom(&i2c.rx_buff[EE_BLOCK0])))
{
/* init 8 bytes(1 page) */
Init_eeprom_var(EE_BLOCK0);
/* set tx pointer */
i2c.tx_buff_ptr = EE_BLOCK0;
/* write 8 cleared bytes to page 0 in eeprom */
I2C_BlockWrite(ADR_24LC02B, EE_BLOCK0, &i2c.tx_buff[i2c.tx_buff_ptr], EE_BLK_SIZE);
}
else
{
/* set position */
i2c.rx_buff_ptr = EE_BLOCK0;
/* read config from i2c buffer */
sens.cnf_sim = i2c.rx_buff[i2c.rx_buff_ptr++];
/* read offset pwm_2 */
Sens16.u8[0U] = i2c.rx_buff[i2c.rx_buff_ptr++];
Sens16.u8[1U] = i2c.rx_buff[i2c.rx_buff_ptr];
sens.offs_pwm2 = Sens16.u16;
}
/* set aligned pwm */
TPM1_Chn_Init(TPM_CHN1, ALIGNED_PWM);
TPM1_Chn_Init(TPM_CHN0, ALIGNED_PWM);
/* set 0% duty cycle */
Set_TPM1_CnV(TPM_CHN1, 0U);
Set_TPM1_CnV(TPM_CHN0, 0U);
/* tpm counter increments on every counter clock */
Start_TPM1_Count(CLK_INC);
/* send info to operator */
Uart_Tx_String(&F_msg1[0], true);
Uart_Tx_String(&F_msg2[0], true);
Uart_Tx_String(&F_msg3[0], true);
/* enable UART0 Interrupt */
NVIC_EnableIRQ(UART0_IRQn);
Enable_UART0_Rx_Irq();
/* init correct index */
uart.log_out = L_PRESS_LPS25;
/* setup measurement with LPS25HB */
Setup_LPS25HB();
/* start mode state */
Change_State(_INT1_LPS25HR, _ONE_TASK);
/* enable SysTick vector */
NVIC_EnableIRQ(SysTick_IRQn);
/* enable global irq flag */
__enable_irq();
//////////////////////////////////////////////////////////////////////////////////////
// Function : Main loop //
//////////////////////////////////////////////////////////////////////////////////////
while(1)
{
if(uart.cmnd_status & _NEW_CMND)
{
Disable_UART0_Rx_Irq();
Uart_Cmnd_Handler();
uart.cmnd_status &= ~_NEW_CMND;
uart.rx_ptr = 0U;
Enable_UART0_Rx_Irq();
}
else if(uart.cmnd_status & _RSP_CMND)
{
Uart_Tx_Char(uart.uart_txbuff[uart.tx_ptr++]);
if(uart.tx_ptr >= _UART_BUFF_SIZE)
{
uart.tx_ptr = 0U;
uart.cmnd_status &= ~_RSP_CMND;
}
}
}
}
Regards
Claes