Help with the sine wave extreme point sampling program based on MSP430[Copy link]
I need to make a sine wave extreme point sampling program. The following is my peak sampling program. How can I modify it? My idea is to multiply the array number of the sampled number by the sampling interval time to get the horizontal coordinate of the corresponding point. I don't know if it will work. I am a novice and don't know how to determine the sampling interval. . . #include
#define n 255
int ADC_buf[n];
unsigned char j;
unsigned char i=0;
int g_zhong,ADC_MAX;
float MAX_true;
float ADC_true;
int main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
ADC12CTL0 = ADC12SHT0_2 + ADC12ON; // Sampling time, ADC12 on
ADC12CTL1 = ADC12SHP; // Use sampling timer
ADC12IE = 0x01; // Enable interrupt
ADC12CTL0 |=ADC12ENC;
P6SEL |= 0x01; // P6.0 ADC option select
//P1DIR |= 0x1C; // P1.0 output
P1DIR |= 0x01;
while (1)
{
ADC12CTL0 |= ADC12SC; // Start sampling/conversion
__bis_SR_register(LPM0_bits + GIE); // LPM0, ADC12_ISR will force exit
//__no_operation(); // For debugger
while(i==0)
{
This depends on how you trigger AD. In the case of continuous conversion, the AD conversion time is the soft trigger interval, which is the trigger interval. This is a routine program.
Details
Published on 2018-11-14 13:54
This depends on how you trigger AD. In the case of continuous conversion, the AD conversion time is the soft trigger interval, which is the trigger interval. This is a routine program.
The following is my modified program. The continuous sampling of the extreme points of the sine wave can collect data, but the extreme point MAX_true cannot be obtained. #include
#define n 100
int ADC_buf[n];
unsigned char j;
unsigned char i=0;
int ADC_MAX;
float MAX_true;
int main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
P6SEL |= 0x01; // P6.0 ADC option select
ADC12CTL0 = ADC12SHT0_8 + ADC12ON+ADC12MSC; // Sampling time, ADC12 on
ADC12CTL1 = ADC12SHP+ADC12CONSEQ_2; // Use sampling timer
ADC12IE = 0x01; // Enable interrupt
ADC12CTL0 |=ADC12ENC;
P1DIR |= 0x01;
while (1)
{
ADC12CTL0 |= ADC12SC; // Start sampling/conversion
__bis_SR_register(LPM0_bits + GIE); // LPM0, ADC12_ISR will force exit
while(i==0)
{