Mercurial > public > ostc4
diff Small_CPU/Src/uart.c @ 921:eb4109d7d1e9 Evo_2_23
Improved mix mode ADC conversion:
Activity of UART sensors may have an impact to ADC measurement. To avoid the ADC trigger was moved into a time window ~300ms after last UART command request => After UART sensor performed measurement but before next measurement is requested. In addition the general ADC measurement cycle has been changed to one second to avoid jitter in the value updates on the display.
author | Ideenmodellierer |
---|---|
date | Sun, 03 Nov 2024 18:19:51 +0100 |
parents | f72613a152dd |
children | 7c996354b8ac |
line wrap: on
line diff
--- a/Small_CPU/Src/uart.c Sun Nov 03 15:44:54 2024 +0100 +++ b/Small_CPU/Src/uart.c Sun Nov 03 18:19:51 2024 +0100 @@ -54,6 +54,7 @@ static uint8_t dmaRxActive; /* Indicator if DMA reception needs to be started */ static uint8_t dmaTxActive; /* Indicator if DMA reception needs to be started */ +static uint32_t LastCmdRequestTick = 0; /* Used by ADC handler to avoid interferance with UART communication */ static uint8_t isEndIndication(uint8_t index); @@ -297,6 +298,7 @@ if(HAL_OK == HAL_UART_Transmit_DMA(&huart1,txBuffer,cmdLength)) { dmaTxActive = 1; + LastCmdRequestTick = HAL_GetTick(); } } } @@ -319,6 +321,7 @@ if(HAL_OK == HAL_UART_Transmit_DMA(&huart1,txBuffer,len)) { dmaTxActive = 1; + LastCmdRequestTick = HAL_GetTick(); } } } @@ -544,11 +547,12 @@ uint8_t ComState = externalInterface_GetSensorState(sensorId + EXT_INTERFACE_MUX_OFFSET); - if((ComState == UART_COMMON_INIT) || (ComState == UART_COMMON_IDLE) || (ComState == UART_COMMON_ERROR) || (ComState == COMMON_SENSOR_STATE_INVALID)) + if(time_elapsed_ms(LastCmdRequestTick, HAL_GetTick()) > 300) /* UART activity should be inactive 300ms after last command */ { active = 0; } return active; } + /************************ (C) COPYRIGHT heinrichs weikamp *****END OF FILE****/