This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
This is the code I am using to generate PWM via ADC on target board of MSP430 ez430-Rf2500. The PWM doesn not vary rather it attains a 50% duty cycle after the ADC moves from 0 to any other value.
Its works as for ADC= 0 PWM =0 ; ADC<=1024 PWM =50%
I require a code in which there is variation of PWM with ADC ; from 0 to 100% duty cycle.
Require immediate help.
"
#include "msp430x22x4.h"
void main(void)
{
WDTCTL = WDT_MDLY_32; // WDT ~27ms interval timer
IE1 |= WDTIE; // Enable WDT interrupt
ADC10CTL0 = ADC10SHT_2 + ADC10ON;
ADC10AE0 |= 0x01; // P2.0 ADC option select
ADC10DTC1 = 0x01; // 1 conversion
P1DIR |= 0x04; // P1.2 = output
P1SEL |= 0x04; // P1.2 = TA1 output
TACCR0 = 1024 - 1; // PWM Period
TACCTL1 = OUTMOD_7; // TACCR1 reset/set
TACCR1 = 512; // TACCR1 PWM Duty Cycle
TACTL = TASSEL_2 + MC_1; // SMCLK, upmode
while(1)
{
__bis_SR_register(LPM0_bits + GIE); // LPM0, WDT_ISR will force exit
ADC10SA = (unsigned int)&TACCR1; // Data transfer location
ADC10CTL0 |= ENC + ADC10SC; // Start sampling
}
}
#pragma vector = WDT_VECTOR
__interrupt void WDT_ISR(void)
{
__bic_SR_register_on_exit(LPM0_bits); // Exit LPM0
}
"
**Attention** This is a public forum