This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

code crashes when I include I2C1_IRQ_handler

Hi guys,

I using 

keil uvisionV5.35.0.0

arm_compiler : V6.16

We are developing a project on STM32L071CZYx MCU. which has 

flash memory: 192kB

RAM: 20KB

The code perfectly works when it is in separate project but we need to combine both the project.

In 1st project We have configured I2C1 has a slave. i have attached code for the irq_handler 

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
void I2C1_IRQHandler(void)
{
I2C1->CR1 &= ~(I2C_CR1_RXIE |I2C_CR1_ADDRIE | I2C_CR1_STOPIE | I2C_CR1_TXIE);
switch((I2C1->ISR &(I2C_ISR_STOPF | I2C_ISR_ADDR |I2C_ISR_RXNE | I2C_ISR_TXIS)))
{
case 0x08: //address match
dev_addr = ((I2C1->ISR >> 16 ) & 0xFE); // assigning Recieved slave address
if(I2C1->ISR & I2C_ISR_DIR)
{
// Slave address with Read bit
if(i2c_state == I2C_GOT_CONTROL_WORD_ADDR)
{
i2c_state = I2C_REPEATED_START;
}
else
{
i2c_state = I2C_RD_STARTED;
}
__HAL_I2C_CLEAR_FLAG(&hi2c1,(I2C_FLAG_ADDR ));
I2C1->CR1 |= (I2C_CR1_TXIE); // enabling Transmitter Interrupt
//slave Tx
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

and 1st project alone uses :

==============================================================================

Total RO Size (Code + RO Data) 9188 ( 8.97kB)
Total RW Size (RW Data + ZI Data) 3704 ( 3.62kB)
Total ROM Size (Code + RO Data + RW Data) 9228 ( 9.01kB)

==============================================================================

And the 2nd project alone uses:

stack memory : 10.5kB

==============================================================================

Total RO Size (Code + RO Data) 146028 ( 142.61kB)
Total RW Size (RW Data + ZI Data) 19440 ( 18.98kB)
Total ROM Size (Code + RO Data + RW Data) 146188 ( 142.76kB)

==============================================================================

and the combined code uses :

we have removed the 1280 bytes of global variable(array) and we got,

and even increase the stack memory to : 12kB

==============================================================================

Total RO Size (Code + RO Data) 146028 ( 142.61kB)
Total RW Size (RW Data + ZI Data) 19440 ( 18.98kB)
Total ROM Size (Code + RO Data + RW Data) 146188 ( 142.76kB)

==============================================================================

In the combined project code crashes when we include 1st projects I2C_IRQ_handler but without it works fine with polling method but we can't include all the required features in it. I have many method like increasing stack size and reducing global variable but nothing worked. I will be thankful if I get an information. and even attached an error pic.

0