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.
代码见附件.
以下是问题:
1.需要存放数据的变量,他设置了unsigned int DMA_DST; 这个变量的位置是在flash还是RAM中的?再结合__data16_write_addr((unsigned short) &DMA0DA,(unsigned long) &DMA_DST); 最终是将ADC12MEM0的值存放到了哪里?是RAM?
2.Timer_B选择了SMCLK和Up-mode,SMCLK是默认值1048576Hz,TBCCR1用来触发ADC12,那么TBCCR0和TBCCR1设置的是多长的时间?是(32768/65534)*1048576 = 524304Hz吗?
3.ADC12CTL1并没有设置SHP,就是用SHI来控制采样频率,那谁控制采样结束呢?
Thanks
/* --COPYRIGHT--,BSD_EX * Copyright (c) 2012, Texas Instruments Incorporated * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * * Neither the name of Texas Instruments Incorporated nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ******************************************************************************* * * MSP430 CODE EXAMPLE DISCLAIMER * * MSP430 code examples are self-contained low-level programs that typically * demonstrate a single peripheral function or device feature in a highly * concise manner. For this the code may rely on the device's power-on default * register values and settings such as the clock configuration and care must * be taken when combining code from several examples to avoid potential side * effects. Also see www.ti.com/grace for a GUI- and www.ti.com/msp430ware * for an API functional library-approach to peripheral configuration. * * --/COPYRIGHT--*/ //****************************************************************************** // MSP430F552x Demo - DMA0, Single transfer using ADC12 triggered by TimerB // // Description: This software uses TBCCR1 as a sample and convert input into // the A0 of ADC12. ADC12IFG is used to trigger a DMA transfer and DMA // interrupt triggers when DMA transfer is done. TB1 is set as an output and // P1.0 is toggled when DMA ISR is serviced. // ACLK = REFO = 32kHz, MCLK = SMCLK = default DCO 1048576Hz // // MSP430F552x // ----------------- // /|\| XIN|- // | | | 32kHz // --|RST XOUT|- // | | // | P1.0|-->LED // | P5.7|-->TB1 output // | | // | P6.0|<--A0 // // Bhargavi Nisarga // Texas Instruments Inc. // April 2009 // Built with CCSv4 and IAR Embedded Workbench Version: 4.21 //****************************************************************************** #include <msp430.h> unsigned int DMA_DST; // ADC conversion result is stored in this variable int main(void) { WDTCTL = WDTPW+WDTHOLD; // Hold WDT P1OUT &= ~BIT0; // P1.0 clear P1DIR |= BIT0; // P1.0 output P5SEL |= BIT7; // P5.7/TB1 option select P5DIR |= BIT7; // Output direction P6SEL |= BIT0; // Enable A/D channel A0 //Setup Timer B0 TBCCR0 = 0xFFFE; TBCCR1 = 0x8000; TBCCTL1 = OUTMOD_3; // CCR1 set/reset mode TBCTL = TBSSEL_2+MC_1+TBCLR; // SMCLK, Up-Mode // Setup ADC12 ADC12CTL0 = ADC12SHT0_15+ADC12MSC+ADC12ON;// Sampling time, MSC, ADC12 on ADC12CTL1 = ADC12SHS_3+ADC12CONSEQ_2; // Use sampling timer; ADC12MEM0 // Sample-and-hold source = CCI0B = // TBCCR1 output // Repeated-single-channel ADC12MCTL0 = ADC12SREF_0+ADC12INCH_0; // V+=AVcc V-=AVss, A0 channel ADC12CTL0 |= ADC12ENC; // Setup DMA0 DMACTL0 = DMA0TSEL_24; // ADC12IFGx triggered DMACTL4 = DMARMWDIS; // Read-modify-write disable DMA0CTL &= ~DMAIFG; DMA0CTL = DMADT_4+DMAEN+DMADSTINCR_3+DMAIE; // Rpt single tranfer, inc dst, Int DMA0SZ = 1; // DMA0 size = 1 __data16_write_addr((unsigned short) &DMA0SA,(unsigned long) &ADC12MEM0); // Source block address __data16_write_addr((unsigned short) &DMA0DA,(unsigned long) &DMA_DST); // Destination single address __bis_SR_register(LPM0_bits + GIE); // LPM0 w/ interrupts __no_operation(); // used for debugging } //------------------------------------------------------------------------------ // DMA Interrupt Service Routine //------------------------------------------------------------------------------ #pragma vector=DMA_VECTOR __interrupt void DMA_ISR(void) { switch(__even_in_range(DMAIV,16)) { case 0: break; case 2: // DMA0IFG = DMA Channel 0 P1OUT ^= BIT0; // Toggle P1.0 - PLACE BREAKPOINT HERE AND CHECK DMA_DST VARIABLE break; case 4: break; // DMA1IFG = DMA Channel 1 case 6: break; // DMA2IFG = DMA Channel 2 case 8: break; // DMA3IFG = DMA Channel 3 case 10: break; // DMA4IFG = DMA Channel 4 case 12: break; // DMA5IFG = DMA Channel 5 case 14: break; // DMA6IFG = DMA Channel 6 case 16: break; // DMA7IFG = DMA Channel 7 default: break; } }
你好!
1.需要存放数据的变量,他设置了unsigned int DMA_DST; 这个变量的位置是在flash还是RAM中的?再结合__data16_write_addr((unsigned short) &DMA0DA,(unsigned long) &DMA_DST); 最终是将ADC12MEM0的值存放到了哪里?是RAM?
unsigned int DMA_DST; 这个变量的位置是在RAM中的。
最终是将ADC12MEM0的值存放到了RAM中。
2.Timer_B选择了SMCLK和Up-mode,SMCLK是默认值1048576Hz,TBCCR1用来触发ADC12,那么TBCCR0和TBCCR1设置的是多长的时间?是(32768/65534)*1048576 = 524304Hz吗?
SMCLK是默认值大约1MHZ,例程中没有对UCS进行初始化,这个1MHZ是不准确的。在up mode 时TBCCR0设置timer的周期,TBCCR1为翻转的时间点,
如果SMCLK是1MHZ,则触发频率为1048576/65534=16HZ。
3.ADC12CTL1并没有设置SHP,就是用SHI来控制采样频率,那谁控制采样结束呢?
是的,SHI来自于TIMER-B,例程中是set/reset模式,即采保时间为32768/1048576s=31ms。
不好意思哦,问题有点多!
对于你说的触发频率和采保频率不是很明白,具体说:
1.这里的TBCCR1使ADC采样开始,TBCCR0使采样结束经过短暂同步之后开始转换,到下一个TBCCR1再开始新的ADC采样,是这样吗?
2.对于采保时间的求法,32768是TBCCR1的值吗?
不好意思没说清楚,是ADC12CTL1的ADC12SSELx~
还有两问题:
1.这里的TBCCR1使ADC采样开始,TBCCR0使采样结束经过短暂同步之后开始转换,到下一个TBCCR1再开始新的ADC采样,是这样吗?
2.对于采保时间的求法,32768是TBCCR1的值吗?
你好!
1.这里的TBCCR1使ADC采样开始,TBCCR0使采样结束经过短暂同步之后开始转换,到下一个TBCCR1再开始新的ADC采样,是这样吗?
set/reset模式下,是到TBCCR1后翻转为高,所以是到TBCCR1后开始采样保持,TBCCR0归零时启动转换。
2.对于采保时间的求法,32768是TBCCR1的值吗?
高电平的值,TBCCR0-TBCCR1=32766clk
我想问一下,这里的采保时间是用(CCR0-CCR1)/f求得的,那与ADC12CTL0中的SHT0的选择有什么关联?这里他选择了1024 ADC12CLK Cycles。速回,多谢!