1358 views|0 replies

3836

Posts

19

Resources
The OP
 

How to use 12864 to display the signal when the msp430 MCU ad samples 1khz signal... [Copy link]

Where is the sampling result stored?
It seems that adcmen0 can only store one data, how to store multiple data?
Please give me a program!

Read adcmen0 in ad interrupt and store in array or flash
An example
//********************************************************************************
// MSP-FET430F261x Demo - ADC12, Single Channel Extended Sample, TA1 Trigger
//
// Description: Sample and convert A0 using Timer_A as sample trigger in
// Extended Sample mode. Put "Num_of_Results" ADC12MEM0 values in results[]
// and Light LED (P1.0) when done.
//
// MSP430F2618
// ---------------
// | |
// Vin -->|P6.0/A0 |
// | |
//
// RB Elliott / H. Grewal
// Texas Instruments Inc.
// Feb 2005
// Built with IAR Embedded Workbench Version: 3.21A
//*****************************************************************************
#include <msp430x26x.h>
#define Num_of_Results 512
int results[Num_of_Results] = {0};
void ADC_Init(void);
void main(void)
{
WDTCTL = WDTPW | WDTHOLD; //Watchdog failure
ADC_Init(); //Initial ADC12
ADC12CTL0 |= ENC; // Start conversion
__bis_SR_register(LPM0_bits + GIE); // Enter LPM0
}
void ADC_Init(void)
{
P1DIR = 0xff; // set port to outputs for observation
P1OUT = 0; // reset port outputs
P6SEL |= 0x01; // select A0 input Set the acquisition port
ADC12CTL0 = ADC12ON+REF2_5V+REFON; // Setup ADC12 various settings
ADC12CTL1 = CONSEQ_2+SHS_1; // Timer triggers sampling
ADC12MCTL0 = INCH_0 + SREF_1;
ADC12IE = 0x0001; // Enable ADC12IFG.0
TACCR0 = 1500; // Delay to allow Ref to settle
TACCTL0 |= CCIE; // Compare-mode interrupt.
TACTL = TASSEL_1 | MC_1; // TACLK = ACLK, Up mode.
__bis_SR_register(LPM3_bits + GIE); // Wait for delay, Enable interrupts
TACCTL0 &= ~CCIE; // Disable timer
P2SEL |= BIT3; // Set for Timer A1
P2DIR |= 0x08;
TACCR0 = 7; // Init TACCR0 w/ sample prd=CCR0+1
TACCR1 = 4; // Trig for ADC12 sample & convert
TACCTL1 = OUTMOD_3; // Set/reset
TACTL = TACLR | MC_1 | TASSEL_1; // ACLK, clear TAR, up mode
}
// Timer_A0 Interrupt Service Routine
#pragma vector=TIMERA0_VECTOR
__interrupt void ta0_isr(void)
{
TACTL = 0;
__bic_SR_register_on_exit(LPM3_bits);
}
// ADC12 Interrupt Service Routine
#pragma vector=ADC12_VECTOR
__interrupt void ADC12ISR (void)
{
static unsigned int index = 0; //A variable that keeps entering interrupts but retains its value
results[index++] = ADC12MEM0; // Move results to the array
if (index == 512)
{
ADC12CTL0 &= ~ENC; // Stop conversion 关ad
ADC12CTL0 = 0;
ADC12IE = 0;
index = 0;
P1OUT |= 0x01;
}
}

This post is from Microcontroller MCU
 

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews

Room 1530, Zhongguancun MOOC Times Building, Block B, 18 Zhongguancun Street, Haidian District, Beijing 100190, China Tel:(010)82350740 Postcode:100190

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list