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.

MSP430F5438A: how trigger adc with timer to get 1k sample/sec

Part Number: MSP430F5438A

helo sir,

How can i trigger the msp430f5438a ADC with timer for CONSEQ=2 and MSC.

sampling frequency = ~1khz

the clock used is SMCLK = 12MHZ, here i changed clock frequency setting by using UCS module by referring the register level examples.

as well as i need to transfer the adc data through serial(UART) to PC.

can you please tell me i can i achieve 1k samples/sec.

Thankyou

  • Some time back I posted an example of this for the F5529:

    https://e2e.ti.com/support/microcontrollers/msp430/f/166/p/647533/2381069

    I don't have an F5438A, but glancing at data sheet (SLAS655F) Tables 6-8 and 6-10 your best bet is probably to use SHS=3 and TB0.1 (the example uses SHS=1 and TA0.1 on the F5529).

    It supposes that SMCLK=1MHz, which affects the value of ADC_TIMER_PERIOD.

    If you use CONSEQ=2 you should use MSC=0. In this case you can remove the toggling of ENC in the ISR.

  • Hi shiva,

    I haven’t heard from you for seven days, so I’m assuming you were able to resolve your issue. If this isn’t the case, please click the "This did NOT resolve my issue" button and reply to this thread with more information. If this thread locks, please click the "Ask a related question" button and in the new thread describe the current status of your issue and any additional details you may have to assist us in helping to solve your issues.

    Best Regards,

    Johnson

  • Hello sir,

    sorry for the delayed response.

    1) In MSP430F5438A register level examples

    a) msp430x54xA_adc_12_02.c example there is a delay of 75us for reference to settle @ ~1Mhz, I am using 12Mhz clock (using UCS module tested using oscilloscope) if I use REF module what could be the delay to settle reference is it 12*75 us?

    b) In msp430x54xA_adc_12_06.c  #define   Num_of_Results   8

    why num_of_samples is 8? is it 8 samples/sec, if I need 1000 samples/sec do I need to change it to 1000?

    2) I want to use the timer (ADC12SHS_3) to trigger ADC as you said use TB0.1 then how could I calculate timer values (TB0CCR1) to get 1k samples?

    please clarify these details

    regards

    shiva

  • Hi shiva,

    For the first question, in the code example of msp430x54xA_adc_12_02.c, the delay function is mainly used to stabilize the reference voltage, so it does not need to be very precise. It is ok to set it to 75*12 when you use a 12MHz clock. The delay time is also around 75us.

    In the code example of msp430x54xA_adc_12_06.c, the parameter of  Num_of_Results is only set the size of buff, its don't determine the sampling rate.

    For the second question, you can use the TB0.1 to set timing sampling, if you want to get 1K samples, you need to meet the CCR value from zero to the value you set in 1ms, those depend on TB0.1 clock source, you can refer to our code example about TB0.1, meanwhile, the ADC12SHSx register and TB0.1 have a corresponding relationship, as shown in the following figure:

    I think you can try this ways in order to In order to achieve 1000 times of AD sampling in 1 second:

    Set a 1ms timer interrupt and start AD sampling in the timer interrupt. Of course, this method may encounter other problems. This is only for your reference.

    Best Regards

    Johnson

  • 2) In the linked Example (derived from adc_06):

    > #define ADC_TIMER_PERIOD 20000      // 1MHz/20000 = 50Hz. Adjust to taste.

    Reversing the arithmetic, you could try:

    > #define ADC_TIMER_PERIOD (12000000UL/1000UL)      // SMCLK=12MHz/Rate=1kHz -> 12000 (fits in a uint16_t)

  • Hi shiva,

    I haven’t heard from you for seven days, so I’m assuming you were able to resolve your issue. If this isn’t the case, please click the "This did NOT resolve my issue" button and reply to this thread with more information. If this thread locks, please click the "Ask a related question" button and in the new thread describe the current status of your issue and any additional details you may have to assist us in helping to solve your issues.

    Best Regards,

    Johnson

**Attention** This is a public forum