I have a task:
1. Sample 4 channels (a0-a3) by adc using DMA.
2. Go In sleep mode until it sample all four. (how to know dma has completed sampling channles & put results in RAM variables for accessing)
3. Do some task by accessing those variables, do other task also.
4. Go to sleep mode again.
5. Go to step 1.
Now I have questions 4 it:
1. best is to use repeat sequence of channels or sequence of channel.
2. when does dma completes its task, how does we can know it -> ADC interrupt flag?
3. it says DMA should be synchronized with mclk. So how to do it.
4. any example showing the above task.
any help regarding this................
The 2253 does not have (general purpose) DMA. It does have, however, the DTC for the ADC10, which serves as a purpose-limited DMA.When using DTC, keep in mind that a data transfer to ram requires MCLK active. So entering LPM1 or below, which will deactivate the DCO, requires some startup time before MCLK can be activated for the transfer. You shouldn't go below LMP0 except if the distance between two samples is significantly longer than the MCLK startup time.
Now about your questions:
1. it depends. You want to wakeup from LPM once a sequence is done. Normally, the ADC10 sets ADC10IFG once a conversion is done. If ADC10IE is also set, your ADC10 ISR will be called, waking teh CPU from LPM if required.
If the DTC is used, an interrupt is generated after a block transfer is competed. So your ISR is called after the four values are written to ram. If you are sure that wakeup and also handlign the four values can be done faster than the completion of th enext conversion, you canuse repeat sequence of channels. If you're not fast enough, the DTC will overwrite the last sequence in ram while you're still workign on it. Then you should use single sequence of channels mode and restart the ADC when you're done. However, this will increase the time between the last sample of one sequence and the first sample of the next sequence. Probably not an issue.
2. see 1. Once DTC is done, ADC10IFG is set. If DTC is used, the ADC10 will not generate ADC10IFG for every individual conversion. (well, the ADC10 will generate the signal, but it is forwarded to the DTC internally then)
3. not 'should', but 'is'. For a DMA transfer, MCLK is used. The clock cycle is used for DMA and not for the CPU. However, in LPM, MCLK is off, so it needs to be reactivated first (done automatically), and in LPM1 and deeper, this might mean reactivating the DCO, with some delay. Worst case, the ADC10 will have the next result before the transfer is done. Which dumps the unwritten last value then.
_____________________________________Before posting bug reports or ask for help, do at least quick scan over this article. It applies to any kind of problem reporting. On any forum. And/or look here.If you cannot discuss your problem in the public, feel free to start a private conversation: click on my name and then 'start conversation'. But please do so only if you really cannot do it in a public thread, as I usually read all threads. And I prefer to answer where others can profit from it (or contribute to it) too.
I HAVE WRITE CODE FOR FOLLOWING TASK. iS IT RIGHT METHOD.
1. SAMPLE A3 TO A0 WITH dma & dtc. PUT VALUES TO RAM ADDRESS 200H-207H.
2. gO TO SLEEP UNTIL CONVERSION COMPLETE
3. WORK WITH THESE VALUES.
4. GO TO SLEEP MODE.
5. WAKE UP & GO TO STEP 1.
(ABOVE STEPS WILL OCCUR IN 2 SEC EACH INCLUDING SLEEP. & WILL BE IN FIELD FOR 3 MONTH CONTINUOUSLY. IS IT RIGHT WAY)
void main(void){ ADC10CTL0 = SREF_1 + ADC10SHT_3 + ADC10SR + MSC + ADC10IE; // ADC10CTL SETTINGS ADC10CTL1 = INCH_3 + ADC10SSEL_3 + CONSEQ_3; // Repeat CHANNEL FROM A3 TO A0 ADC10AE0 |= 0x0F; ADC10DTC1 = 0x04; // 4 CONVERSION conversions SO THAT RESULT INTO 0X200-0X207h for(;;) { ADC10CTL0 |= (ADC10ON + REFON); //turn on ADC __delay_cycles(40); //settling time 30us for reference buffer // extra time 10us in case of variations get_adc_value();
__bis_SR_register(CPUOFF + GIE); // LPM0, ADC10_ISR will force exit _NOP(); ADC10CTL0 &= ~(ADC10ON + REFON); //turn off adc module
do_some_other_task(); }}void get_adc_value(void){ ADC10CTL0 &= ~ENC; while (ADC10CTL1 & BUSY); // Wait if ADC10 core is active ADC10SA = 0x0200; // Data buffer start
ADC10CTL0 |= ENC + ADC10SC; // Sampling and conversion start }#pragma vector=ADC10_VECTOR__interrupt void ADC10_ISR(void){ __bic_SR_register_on_exit(CPUOFF); // Clear CPUOFF bit from 0(SR)}
any help abt dis
I want 2 reduce power consumption to minimum with Vcc=2.5V min. Is this best method with MSP430G2553 or other methods can be done to reduce power.
any help abt dis.............
Aamir Ali ADC10CTL0 &= ~(ADC10ON + REFON); //turn off adc module
Besides this, well, the code look sgood, so why do yoou ask? Compile it and try it. And check the results. And if something is not as you expect, tell us what you expected and what you unexpectedly observed instead. The we might be able to see what's going wrong. Please don't abuse this forum as a preventative code validator. :)