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 STM board in C coding language using UART TX and RX To gather the temperature, we are using a NTC k 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:
TIMHandleTypeDef htim; TIMHandleTypeDef htim; UARTHandleTypeDef huart; uintt previousData; Initialize perviousData for a byte uintt dataTx; Initialize dataRx for a byte void SystemClockConfigvoid; static void MXGPIOInitvoid; static void MXTIMInitvoid; static void MXUSARTUARTInitvoid; static void MXTIMInitvoid; int mainvoid HALInit; SystemClockConfig; Initialize all configured peripherals MXGPIOInit; MXTIMInit; MXUSARTUARTInit; MXTIMInit; HALTIMBaseStartIT&htim; Start Tim HALTIMBaseStartIT&htim; Start Tim HALUARTTransmitIT&huartuintt; Start UART Transmission while ifdataTx previousDataWhen dataTx does not equal previousData HALUARTTransmitIT&huartuintt dataTx, sizeofdataTx; Transmit new data if HALRCCClockConfig&RCCClkInitStruct, FLASHLATENCY HALOK ErrorHandler; static void MXTIMInitvoid TIMMasterConfigTypeDef sMasterConfig ; htimInstance TIM; Used calculator to initialize flash per second htimInit.Prescaler ; htimInit.CounterMode TIMCOUNTERMODEUP; htimInit.Period ; htimInit.AutoReloadPreload TIMAUTORELOADPRELOADDISABLE; if HALTIMBaseInit&htim HALOK ErrorHandler; sMasterConfig.MasterOutputTrigger TIMTRGORESET; sMasterConfig.MasterSlaveMode TIMMASTERSLAVEMODEDISABLE; if HALTIMExMasterConfigSynchronization&htim &sMasterConfig HALOK ErrorHandler; static void MXTIMInitvoid TIMMasterConfigTypeDef sMasterConfig ; htimInstance TIM; Used calculator to initialize flashes per second htimInit.Prescaler ; htimInit.CounterMode TIMCOUNTERMODEUP; htimInit.Period ; htimInit.AutoReloadPreload TIMAUTORELOADPRELOADDISABLE; if HALTIMBaseInit&htim HALOK ErrorHandler; sMasterConfig.MasterOutputTrigger TIMTRGORESET; sMasterConfig.MasterSlaveMode TIMMASTERSLAVEMODEDISABLE; if HALTIMExMasterConfigSynchronization&htim &sMasterConfig HALOK ErrorHandler; static void MXUSARTUARTInitvoid huartInstance USART; Initialized USART huartInit.BaudRate ; huartInit.WordLength UARTWORDLENGTHB; huartInit.StopBits UARTSTOPBITS; huartInit.Parity UARTPARITYNONE; huartInit.Mode UARTMODETX; huartInit.HwFlowCtl UARTHWCONTROLNONE; huartInit.OverSampling UARTOVERSAMPLING; if HALUARTInit&huart HALOK ErrorHandler; static void MXGPIOInitvoid GPIOInitTypeDef GPIOInitStruct ; GPIO Ports Clock Enable HALRCCGPIOACLKENABLE; HALRCCGPIOCCLKENABLE; HALRCCGPIOBCLKENABLE; Configure GPIO pin Output Level HALGPIOWritePinGPIOA GPIOPINGPIOPIN GPIOPINSET; void HALTIMPeriodElapsedCallbackTIMHandleTypeDef htim ifhtimInstance TIM dataTxU ; Alternate first bit of dataTx between and
HALGPIOWritePinGPIOA GPIOPINdataTx & U; Write PA as the first bit of DataTx
ifhtimInstance TIMWhen the Tim period is complete
dataTxU ; Alternate first bit of dataTx between and
HALGPIOWritePinGPIOA GPIOPINdataTx & U; Write PA as the second bit of DataTx
HALUARTTransmitIT&huartuintt dataTx, sizeofdataTx; Transmit the full byte of dataTx through uart
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
