STM32H745 discovery evk Missed External Interrupt in FreeRTOS
Hello,
I’ve just started using FreeRTOS with an ARM Cortex m7 core. I’m using a sensor that provides an interrupt at every 62.5uS. based on that interrupt I have to read the 27-byte sensor data over SPI for that I have created one task(Read sensor data task) as below.
My issue is, that my task is not synchronized with the interrupt. That means whenever the first interrupt occurs the task runs to read sensor data using SPI and parsed the data, before completion of reading and parsing data the other interrupts occur.
As per the sensor datasheet: DOUT is latched out at the SCLK rising edge. DRDY is pulled high at the SCLK falling edge. Note that DRDY goes high on the first SCLK falling edge, regardless of whether data are being retrieved from the device or command is being sent through the DIN pin.
DRDY is the interrupt that active low. here I have attached the datasheet snap.
I have configured coreM7 CPU clock 400Mhz. And code optimization level is 0.
So I want to know what is the time required to run one instruction on CoreM7 CPU.
Also, I want to know the time of context switching from ISR to task wakeup. (I am using vTaskNotifyGiveFromISR())
Could you please help me to find out the best approach to achieve read data without losing interrupt and task synchronization?
I have used HAL API to configure interrupt and ISR.
I am using SPI with DMA HAL API to read sensor data.
Below I have attached the pseudo-code of my task and ISR.
ISR
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
{
switch(GPIO_Pin)
{
case SPI1_INT_Pin: /* drdy interrupt handling for */
/* When device is in normal conversion mode */
drdy_interrupt_count++; /* Interrupt count for receive all data */
break;
default:
break;
}
}
Sensor data read task
void Task(void *argument)
{
/* Infinite loop */
for(;;)
{
{
parsed_count++;
low_level_send_rdata_cmd(); /*Send RDATA command to receive 28 bytes from */
parse_data(); /*Parsed raw data and convert into mVolt */
printf('parsed data');
}
}
}