Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Modify the C code below for an STM32F411RE microcontroller such that it follows the following specifications: Looking at the data, what could have happened to

Modify the C code below for an STM32F411RE microcontroller such that it follows the following specifications: image text in transcribedimage text in transcribed Looking at the data, what could have happened to the device and the temperature sensor after the 900ms mark? C code: #include  #include  #include  uint16_t adc_value = 0x0000; uint16_t temp_bit = 0x0000; uint16_t mask = 0x0000; uint16_t move = 0x0000; void GPIO_init(void); void ADC_init(void); void ADC_enable(void); void ADC_startconv(void); void ADC_waitconv(void); int ADC_GetVal(void); void TempSense(int); void delay_ms(int delay); int main(void) { GPIO_init(); ADC_init(); /* Loop forever */ while (1) { //start adc conversion ADC_enable(); //start conversion ADC_startconv(); //wait for conversion to finish ADC_waitconv(); //store converted data to a variable adc_value = ADC_GetVal(); //monitor temperature here TempSense(adc_value); } } void GPIO_init(void) { //enable GPIOA clock RCC->AHB1ENR |= (1 MODER |= (1 MODER |= (1 APB2ENR |= (1 CCR &= ~(1 CCR &= ~(1 CR1 &= ~(1 CR1 &= ~(1 CR1 |= (1 CR1 |= (1 SMPR2 &= ~(1 SMPR2 &= ~(1 SMPR2 |= (1 CR2 &= ~(1 CR2 &= ~(1 SQR1 &= ~(1 SQR1 &= ~(1 SQR1 &= ~(1 SQR1 &= ~(1 SQR3 |= (1 CR2 |= (1 CR2 |= (1 CR2 |= (1 SR) & (1 DR; //read the value contained at the data register } void TempSense(int adc_value){ //do something useful here } void delay_ms(int delay) { int i; for (; delay > 0; delay--) { for (i = 0; i   For this exercise, assume that we are tasked with developing a way to monitor the operating temperature of a device which the manufacturers claim (from references, datasheets) can safely operate between 15 to a maximum of 60 degrees Celsius. It can withstand temperatures up to 80 degrees Celsius, above which, device functionality cannot be guaranteed. The manufacturer also claims that below 15 degrees Celsius, performance also suffers. To monitor the temperature, we were given a sensor that can accurately measure 0100 degrees Celsius over a sensor output of 03.3V. That means that for example, a sensed temperature of 50 degrees Celsius will result in a voltage output of 1.65V. Implement a function TempSense(), within the given template code that will perform the temperature indication. To verify your work, you can perform transient analysis for at least 1.25 seconds, and should be able to show this: These data are compressed in time to make transient simulations finish faster. Typically, these monitoring activities happen at longer times. The top curve shows the temperature voltage having a range of 03.3V as the output of the temp sensor and input to our ADC pin. The second curve is the current measured by the current sensor 1_2 or the red LED. The third curve is the current for 1_1 or the green LED. High current means the LED is ON, and low current means LED is OFF

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamentals Of Database Management Systems

Authors: Mark L. Gillenson

2nd Edition

0470624701, 978-0470624708

More Books

Students also viewed these Databases questions