Jump to content


  • Content Count

  • Joined

  • Last visited

  1. void main(void) { unsigned int i,j; WDTCTL = WDTPW+WDTHOLD; // Hold WDT REFCTL0 &= ~REFMSTR; P1OUT &= ~BIT0; // P1.0 clear P1DIR |= BIT0; // P1.0 output P5SEL |= BIT7; // P5.7/TB1 option select P5DIR |= BIT7; // Output direction P6SEL |= 0xFF; P7SEL |= 0x0F; P5SEL |= 0x03; // Setup ADC12 ADC12CTL0 &= ~ADC12ENC; ADC12CTL0 = ADC12SHT0_6+ADC12SHT1_6+ADC12MSC+ADC12ON+ADC12REF2_5V+ADC12REFON; ADC12CTL1 = ADC12SHP+AD
  2. Is it that I only need to declare just one line of ADC12MCTL15 or I need to declare ADC12MCTL 0 to ADC12MCTL15 to sample channel 0 - 15? Then if it is just one line, is it I have to put ADC12MCTL0 = ADC12SREF_1+ADC12INCH_15 or ADC12MCTL15 = ADC12SREF_1+ADC12INCH_15? Here is my code for the initialization. I collect one sample from each ADC channel in sequence. But seems like it won't run. The program stuck at 'while (ADC12CTL1 & BUSY)'. Do you know what's wrong? ADC12CTL0 &= ~ADC12ENC; ADC12CTL0 = ADC12SHT0_6+ADC12SHT1_6+ADC12MSC+ADC12ON+ADC12REF2_5V+ADC12REFON;// Sampling time,
  3. From my method, each DMA_DST[0] to DMA_DST[255] is equals to a channel. But from your method, DMA_DST[0] is for channel 0, DMA_DST[1] is for channel 1, DMA_DST[2] is for channel 2, DMA_DST[3] is for channel 3, ....., DMA_DST[15] is for channel 15. Then DMA_DST[16] is for channel 0 again, DMA_DST[17] is for channel 1 again... and then repeat again. Am I right? Then is it that my ADC12MCTL0 = ADC12SREF_1+ADC12INCH_15? right_cal = 0; for (r=ADCRIGHT; r < MAXADC; r+=6) { right_cal += ADCdata[r]; } right_cal /= SAMPLES; For your above for loop, what is ADCRIGHT? Is i
  4. for(i=0;i<256;i++) { RAWvalue += DMA_DST[i]; // Summing up 256 raw values } I found out that it is the above for loop which run 256 times to sum up the raw value for each channel that increase my time. Is there any other way that I can write to reduce the time?
  5. Yup. I had downloaded it. I think that you just have change to ADC10MCTL0 = ADC10INCH_15 and then DMA0SZ = 0x0F to scan all 15 channels right? But now I want to collect 256 conversion from each channel and I want to do all channels and it's roughly in total 256x14=3586 (14 channels for my F5325) conversion each time. Below is my code in main(): void main(void) { unsigned int i; WDTCTL = WDTPW+WDTHOLD; // Hold WDT REFCTL0 &= ~REFMSTR; P1OUT &= ~BIT0; // P1.0 clear P1DIR |= BIT0; // P1.0 output P5SEL |= BI
  6. I'm planning to ON all channels from channel 0 to 15 for my ADC12 for a user to use. Just that I thought of maybe a user won't know the sequence which one is channel 0 or which one is channel 15. Then if he put his device on channel 15, then he'll have to wait a long time only can get a result. I mean like, can't I get the ADC conversion from channel 0 to channel 15 all at the same time? Is there a configuration for this? Because of you add an extra step which is the DMA transfer in the code, I felt like the conversion time with using DMA is slower compare to without using DMA. Am I right
  7. So it is mean that using the coding you showed, doesn't matter I use multiple channels like for example from channel 0 to 2 or channel 0 to 15, the conversion will always store in ADC10MEM0? I notice the coding will still use the ADC10CTL1 = ADC10CONSEQ_2 for repeat single channel instead of ADC10CTL1 = ADC10CONSEQ_3 for repeat sequence of channel? Why? I thought we are using multiple channels? So, the ADC conversion is in sequence from channel 0, 1, 2, 3, .... to finally channel 15. Then if my device input is at the last channel, which is channel 15, doesn't we have to wait a long tim
  8. void adc_DMA_init(void) { DMACTL0 = DMA0TSEL__ADC10IFG; // select adc10 trigger __data16_write_addr( (unsigned short)&DMA0SA, (unsigned long)&ADC10MEM0 ); // dma single source address __data16_write_addr( (unsigned short)&DMA0DA, (unsigned long)&ADCdata[0] ); // destination array DMA0SZ = 64; // 64 conversions each channel, channels 12-14 selected in main routine after isr exit // repeat; increment dest address; enable dma; enable interrupt; high level DMA0CTL = DMADT_4 + DMADSTINCR_3 + DMAEN + DMAIE + DMALEVEL; } According t
  9. I've found the below circuit which can measure resistance using ADC12. But what I don't understand is what is the 1M resistor in the middle for? We must put it or can we omit it?
  10. My voltage is a stable one. I measured already, I don't experience voltage drop. Yup. You are right. I've change the upper resistor to 30k Ohm and it give me a correct voltage value. But do you know why we should use a larger value for the upper resistor?
  11. I see. I've also saw the word software control from the internet. What exactly it is? Could you explain to me how do we use software control to trigger the DMA? Is the time we set for CCR registers (long or short) effecting the ADC accuracy? I've read the MSP430x5xxx family datasheet on ADC12 and DMA already. But I still have a lot don't understand. That's why I posted my questions here hoping somebody to explain to me.
  12. Anybody willing to help me with the above question?
  13. Do you guys know why i face the above problem?
  14. I know but with 2.08V, the resistance I should get after my calculation is 4.95k ohm. But when i measure the thermistor using my multimeter, I still get 10k resistance. Besides, 4.95k ohm of temperature is around 40 degree C. That's impossible... I'm in a 25 degree C room.
  15. I still don't understand, why is it there is two TBCCR (TBCCR0 and TBCCR1) values from my code but from your sample code, there is only one TA0CCR0 value? The timer counts to TBCCR0 = 0xFFFE or counts to TBCCR1 = 0x8000? That's why I ask why is it there is two TBCCR. And by the way, how do you determine the values of TBCCR? Is it that we must use a timer to trigger ADC12? Can't we use the default ADC12SC bit? What is the difference of using a timer and the ADC12SC bit? Which is better? I see. Thanks for the explanation. But what I want to know is the block address. Back to my below c
  • Create New...