Jump to content


  • Content Count

  • Joined

  • Last visited

Everything posted by ahgan84

  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
  16. I have set up a NTC thermistor to interface with my ADC12 for measurement. I'm using a voltage divider settings. But I have encounter some problem. I've uploaded a picture for my settings. Sorry I just want to be quick so instead of using schematic software, I just use hand drawing. The top one is a voltage divider using a resistance box. As you can see, the voltage values that I measure using multimeter for 1k resistor and the 10k resistance box is the same with when I use calculation using voltage divider formula. So, the values are correct. But as for the bottom settings which I
  17. 4. May I know how does the coding flows? Is it from main() straightaway stay in the ADC12ISR in a forever loop? Or it occasionally got return to main() for a short while then back to ADC12ISR again?
  18. But I thought I got the ADC12SHT0_15 to control my sample and hold time and by default, it is from MODCLK right? Then why still use TimerB? I still don't understand why there's two value for TBCCR (TBCCR0 = 0xFFFE;TBCCR1 = 0x8000). Could you explain please? I thought of using DMA, the transferring of data will be faster because it doesn't involve the CPU. So, I want to study how to use DMA but I got a lot don't understand. Is it that when we want to transfer data using DMA, we have to use the two __data16_write_addr function? One is for source address and one is for destination addres
  19. Hi guys, The below coding is what I modified from the sample coding of MSP430F5325 on TI website. It put the ADC12 conversion in the ISR. #include #include #define MOVWIN 64 void initADC12(void); void initIO(void); unsigned long OVSresult0[MOVWIN]; unsigned long ActValue[100] = {0}; unsigned long ADCresult0 = 0; unsigned long OVSvalue0 = 0; unsigned long Dampvalue0 = 0; static unsigned long RAWvalue = 0; static unsigned int AVGpnt2 = 0; static unsigned int AVGpnt3 = 0; bool Flag = 0; void main(void) { WDTCTL = WDTPW+WDTHOLD; // Stop watchdog timer
  20. I see. So, can I say DMA0TSEL_24 is fixed for ADC12? Does that means other DMA0TSEL_xx is for other purposes / function? I got a few questions again regarding the above coding: 1. I thought it uses the DMA0IFG to trigger the ADC12 transfer? Why is it Timer_B is used and why is it there is two value for TBCCR (TBCCR0 = 0xFFFE;TBCCR1 = 0x8000)? Is it that we must always use a timer to trigger ADC12 transfer?2. How do we know what is the source address DMA0SA and destination address DMA0DA for this coding? Is it default address that start from 0? 3. Does __data16_write_addr function stan
  21. Hi guys, These days I've been studying some sample coding from TI on DMA for my ADC12. For your information I'm using MSP430F5325 and I have the below coding: //****************************************************************************** // MSP430F532x 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
  22. Hi guys, I'm using the MSP430F5325 and I'm just wondering how do you make the ADC reference voltage of 2.5V to be available at external pin? From the datasheet the pin is +Vref at A8. I've been studying the datasheet awhile and I've set the below configuration: REFCTL0 &= ~REFMSTR; ADC12CTL2 = ADC12REFOUT; Is this two setting enough to make the reference voltage available on external pin?
  23. Hi guys, I'm using the MSP430F5325 mcu and I am wondering whether I can simultaneously convert two channel from the ADC12? As far as I'm studying the data sheet, the ADC12 conversion is doing one channel at a time from A0 to A15. Because I'm trying to reduce the conversion time to half of it, so can it convert two channel in one time like for example convert A0 and A1 simultaneously at one time?
  24. Hi guys, Recently I begin to study on I2C communication for my MSP430F5325. I've found some I2C sample coding in the below link: http://www.ti.com/litv/zip/slac503 But all it got its one way only. Either its receive only or transmit only. I want to do transmit and receive. Is there any combine coding for transmit and receive?
  • Create New...