HAL - Interupt-driven I2C, USART
Hi,
I am new to the STM32 world and currently working on the following application on a STM32F103CBT6 @72MHz:
1. Collect data from I2C sensor triggered from external interrupt @800Hz
2. Read commands (MODBUS RTU) from USART and respond.
I set up the uC with STM32CubeMX.
ISR for Task 1 is simply:
HAL_I2C_Mem_Read_IT (adxl343_i2c_handle, adxl343_i2c_addr<<1,ADXL343_ACCEL_ZOUT_REG,1, d, 2);
I do not even bother doing anything with the data in uint8_t d[2].
ISR for Task 2, HAL_UART_RxCpltCallback() is:
modb_rx_buff_head = (modb_rx_buff_head+1)%MODB_RX_BUFF_SIZE;
HAL_UART_Receive_IT(&huart2, &(modb_rx_buff[modb_rx_buff_head]), 1);
ISR for Task 2, HAL_UART_TxCpltCallback() is:
// Clear the TX_EN pin on the RS485 interface IC
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_1, GPIO_PIN_RESET);
There are no common variables between both tasks.
Task 1 alone works perfectly (checked w/ oscrilloscope).
Task 2 alone works perfectly .
Task1 + Task2 : uC hangs (either immediately or after a short time)
I tried playing with Interrupt priorities to no avail.
The ISR's are really short. I run the same setup on a 8MHz ATMega328 without problems.
Here are my questions:
1. Can anybody point me to where to start looking for malfunction(s)?
2. Is it worth digging into the HAL stuff? (I have read much discouraging posts on that topic and have not seen a single comparable working example.)
3. If the answer to question 2. is 'no' then should I use the LL/CMSIS stuff or rather go directly down to the registers? (Please, keep i mind that I am new to STM32.)
Any help is appreciated.
