Help with section of code for MSP430 I\'m able to get the average of temperature
ID: 3866268 • Letter: H
Question
Help with section of code for MSP430
I'm able to get the average of temperature my problem is the PWM
if temperature below 78'F no light turns on
When the average temperature reading is at a level corresponding to 78 0F, a PWM signal (duty cycle = 0.1) is sent to the LED. (At this time, the LED is dim).
The duty cycle changes proportionally to the temperature measured until it reaches 88 0F, at which time, a PWM signal with duty cycle = 0.95 is sent to the LED. Test your circuit using a heating tool to change temperature to above 88 0F. Observe if the system output is correct. (The LED changes its brightness until it reaches the brightest - 95% of the duty cycle). The duty cycle is fixed to 95% when the temperature is above 88 0F.
When the temperature reading is back to below 88 0F and then below 78 0F, the PWM signal becomes smaller and smaller and then disappears. Again observe the corresponding output.
PWM code that I have:
P2SEL |= BIT1;
TA1CCR0 = period - 1; //Set PWM for LED at P1.X
TA1CCR1 = period * D;
TA1CCTL1 = OUTMOD_7;
TA1CTL = TASSEL_2|MC_1;
Explanation / Answer
#include int main(void) { volatile int i; // stop watchdog timer WDTCTL = WDTPW | WDTHOLD; // set up bit 0 of P1 as output P1DIR = 0x01; // intialize bit 0 of P1 to 0 P1OUT = 0x00; // loop forever for (;;) { // toggle bit 0 of P1 P1OUT ^= 0x01; // delay for a while for (i = 0; i < 0x6000; i++); } }Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.