Question: Hi , I need help editing my code to match the following criteria below. It is on a STM 3 2 board in C coding

Hi, I need help editing my code to match the following criteria below. It is on a STM32 board in C coding language using UART TX and RX. To gather the temperature, we are using a NTC 10k thermister. For triggering the LEDs I wanted to use a case statement to trigger the LEDs at a certain temperature. I am also using an ADC example code I want to get the value of the temperature I can attach below.
UART receiving code:
TIM_HandleTypeDef htim6; TIM_HandleTypeDef htim7; UART_HandleTypeDef huart3; uint8_t previousData[1]={0}; //Initialize perviousData for a byte uint8_t dataTx[1]={0}; //Initialize dataRx for a byte void SystemClock_Config(void); static void MX_GPIO_Init(void); static void MX_TIM6_Init(void); static void MX_USART3_UART_Init(void); static void MX_TIM7_Init(void); int main(void){ HAL_Init(); SystemClock_Config(); /* Initialize all configured peripherals */ MX_GPIO_Init(); MX_TIM6_Init(); MX_USART3_UART_Init(); MX_TIM7_Init(); HAL_TIM_Base_Start_IT(&htim6); //Start Tim6 HAL_TIM_Base_Start_IT(&htim7); //Start Tim7 HAL_UART_Transmit_IT(&huart3,(uint8_t*)1,1); //Start UART Transmission while (1){ if(dataTx[0]!= previousData[0]){//When dataTx does not equal previousData HAL_UART_Transmit_IT(&huart3,(uint8_t*) dataTx, sizeof(dataTx)); //Transmit new data }}} if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2)!= HAL_OK){ Error_Handler(); }} static void MX_TIM6_Init(void){ TIM_MasterConfigTypeDef sMasterConfig ={0}; htim6.Instance = TIM6; //Used calculator to initialize 1 flash per second htim6.Init.Prescaler =671; htim6.Init.CounterMode = TIM_COUNTERMODE_UP; htim6.Init.Period =62499; htim6.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; if (HAL_TIM_Base_Init(&htim6)!= HAL_OK){ Error_Handler(); } sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET; sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE; if (HAL_TIMEx_MasterConfigSynchronization(&htim6, &sMasterConfig)!= HAL_OK){ Error_Handler(); }} static void MX_TIM7_Init(void){ TIM_MasterConfigTypeDef sMasterConfig ={0}; htim7.Instance = TIM7; //Used calculator to initialize 2 flashes per second htim7.Init.Prescaler =671; htim7.Init.CounterMode = TIM_COUNTERMODE_UP; htim7.Init.Period =31249; htim7.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; if (HAL_TIM_Base_Init(&htim7)!= HAL_OK){ Error_Handler(); } sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET; sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE; if (HAL_TIMEx_MasterConfigSynchronization(&htim7, &sMasterConfig)!= HAL_OK){ Error_Handler(); }} static void MX_USART3_UART_Init(void){ huart3.Instance = USART3; //Initialized USART3 huart3.Init.BaudRate =9600; huart3.Init.WordLength = UART_WORDLENGTH_8B; huart3.Init.StopBits = UART_STOPBITS_1; huart3.Init.Parity = UART_PARITY_NONE; huart3.Init.Mode = UART_MODE_TX; huart3.Init.HwFlowCtl = UART_HWCONTROL_NONE; huart3.Init.OverSampling = UART_OVERSAMPLING_16; if (HAL_UART_Init(&huart3)!= HAL_OK){ Error_Handler(); }} static void MX_GPIO_Init(void){ GPIO_InitTypeDef GPIO_InitStruct ={0}; /* GPIO Ports Clock Enable */__HAL_RCC_GPIOA_CLK_ENABLE(); __HAL_RCC_GPIOC_CLK_ENABLE(); __HAL_RCC_GPIOB_CLK_ENABLE(); /*Configure GPIO pin Output Level */ HAL_GPIO_WritePin(GPIOA, GPIO_PIN_0|GPIO_PIN_5, GPIO_PIN_SET); void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim){ if(htim->Instance == TIM6){ dataTx[0]^=(1U 0); //Alternate first bit of dataTx between 0 and 1
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_0,((dataTx[0]>>0) & 1U)); //Write PA0 as the first bit of DataTx
}
if(htim->Instance == TIM7){//When the Tim7 period is complete
dataTx[0]^=(1U 1); //Alternate first bit of dataTx between 0 and 1
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_5,((dataTx[0]>>1) & 1U)); //Write PA5 as the second bit of DataTx
}
HAL_UART_Transmit_IT(&huart3,(uint8_t*) dataTx, sizeof(dataTx)); //Transmit the full byte of dataTx through uart3
}
Hi , I need help editing my code to match the

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!