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.

RTOS/MSP430F5529: MSP430F5529 TI-RTOS ADC

Part Number: MSP430F5529

Tool/software: TI-RTOS

HI

I'm using the msp430f5529, CCS  V7.4 and msp430Ware-v3.80.40.05 SDK.

Unfortunately i'm unable to find any ti-rtos ADC example (like on the other launchpads).

It's very crucial for me to find such an example since i'm planning on migreating my project (which was composed on ti-rtos) from my current lounchpad (msp432p401r) to the msp430f5529.

BEST REGARDS,

AVRAHAM

  • Void ADC_init(){
    	GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P6, GPIO_PIN1);
    
    	ADC12_A_init(
    			__MSP430_BASEADDRESS_ADC12_PLUS__,
    			ADC12_A_SAMPLEHOLDSOURCE_SC,
    			ADC12_A_CLOCKSOURCE_ADC12OSC,
    			ADC12_A_CLOCKDIVIDER_1);
    
    	ADC12_A_setupSamplingTimer(
    			__MSP430_BASEADDRESS_ADC12_PLUS__,
    			ADC12_A_CYCLEHOLD_64_CYCLES,
    			ADC12_A_CYCLEHOLD_64_CYCLES,
    			ADC12_A_MULTIPLESAMPLESDISABLE);
    
    	ADC12_A_configureMemoryParam config_param;
    	config_param.memoryBufferControlIndex = ADC12_A_MEMORY_0;
    	config_param.inputSourceSelect = ADC12_A_INPUT_A1;
    	config_param.positiveRefVoltageSourceSelect = ADC12_A_VREFPOS_AVCC;
    	config_param.negativeRefVoltageSourceSelect = ADC12_A_VREFNEG_AVSS;
    	config_param.endOfSequence = ADC12_A_ENDOFSEQUENCE;
    
    	ADC12_A_configureMemory(
    			__MSP430_BASEADDRESS_ADC12_PLUS__,
    			&config_param);
    
    	ADC12_A_setResolution(
    			__MSP430_BASEADDRESS_ADC12_PLUS__,
    			ADC12_A_RESOLUTION_12BIT);
    
    	ADC12_A_enable(__MSP430_BASEADDRESS_ADC12_PLUS__);
    }
    
    uint16_t get_one_ADC_reading(){
    	uint16_t result;
    
    	ADC12_A_startConversion(
    			__MSP430_BASEADDRESS_ADC12_PLUS__,
    			ADC12_A_MEMORY_0,
    			ADC12_A_SINGLECHANNEL);
    
    	while(ADC12_A_isBusy(__MSP430_BASEADDRESS_ADC12_PLUS__) == ADC12_A_BUSY);
    
    	result = ADC12_A_getResults(
    				__MSP430_BASEADDRESS_ADC12_PLUS__,
    				ADC12_A_MEMORY_0);
    
    	return result;
    }

    How you want to setup your ADC is based on your application, but this should be enough to get you going. It has all the calls to initialize and utilize the ADC. Good luck.

  • HI MIKE
    First of all thank you for the very quick replay.
    So you suggest to add all of those setting/operation api's "on top" of my rtos project like functions?
    I assum i need to import the adc library (which one?) as well?

    BR
    Avraham
  • The ADC initialization code should go with the other initialization code of your TI-RTOS project. I assume you have a task that needs to access the ADC, you can either call a function or include the code within the task.

    The libraries that you need for the code I supplied are:
    #include <adc12_a.h>
    #include <gpio.h>
    #include <xdc/std.h>
    #include <ti/drivers/GPIO.h>
  • HI MIKE
    On this thread, ToddMullanix, mentioned "We are working on a "How to move bare-metal code to TI-RTOS" but it is not completed yet."
    Is there any progress with that?
  • TY very much, i'll get into it right away and try it out.
  • I am not familiar with that thread. But moving any code to TI-RTOS should not be too complex if you do not run out of RAM :)
  • hopefully i won't : )
    I'm not conducting very copmlex operations.
    I'm just quite comfortable with the RTOS-OS thats why i'm insisting on it.
    again MIKE, ty very much,
    br
    Avraham

**Attention** This is a public forum