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.

CCS/MSP432P401R: MSP432P401r timer32

Part Number: MSP432P401R

Tool/software: Code Composer Studio

I am using timer 32 to create delay( desired delay is of 50us),  the delay time decreases as i decrease the count in the timer register, but after a particular count the delay stays at some value say 128us, how to attain a delay of 20us or below using a  DCO freq of 48MHZ and timer32??

  • Gopalakrishnan,


    I'd like to help you, but can you share your code so I can better assist you? Are you using TI Drivers or Driverlib or Baremetal code?

  • hello Evan,

    I sorted out the issue i had before,

    1) i wrote a code using timer32 to do ADC on a sample with a programmed delay

    2) the count value in the program decides the delay

    3) the code works fine till a certain amount of delay

    4) i found that the extra delay  was due  to the conversion time of ADC and the time taken for the remaining part of the program to execute ( i removed the other part of the program like ADC and UART things, the program was fine  with desired value of delay )

    i now need some advice on how to reduce this delay caused by the other part of the code

    i have also attached the code i used

    thank you

    10marchFN.txt
    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    //* DriverLib Includes */
    #include "driverlib.h"
    /* Standard Includes */
    #include <stdint.h>
    #include <stdbool.h>
    /* variable intialization */
    static volatile uint16_t curADCResult,dval,i,j;
    static volatile uint32_t dec;
    static volatile float resultsBuffer[UINT8_MAX],d;
    static volatile uint8_t resPos;
    char itos[8]={0,};
    /* UART configuration with 9600 baud rate and 48MHZ clock*/
    const eUSCI_UART_Config uartConfig =
    {
    EUSCI_A_UART_CLOCKSOURCE_SMCLK, // SMCLK Clock Source
    312, // BRDIV = 78
    8, // UCxBRF = 2
    0, // UCxBRS = 0
    EUSCI_A_UART_NO_PARITY, // No Parity
    EUSCI_A_UART_LSB_FIRST, // MSB First
    EUSCI_A_UART_ONE_STOP_BIT, // One stop bit
    EUSCI_A_UART_MODE, // UART mode
    EUSCI_A_UART_OVERSAMPLING_BAUDRATE_GENERATION // Oversampling
    };
    int main(void)
    {
    /* Halting the Watchdog */
    WDT_A_holdTimer();
    /* temporary and count variable*/
    curADCResult = 0;
    resPos = 0;
    /* Setting DCO to 48MHz */
    CS_setDCOCenteredFrequency(CS_DCO_FREQUENCY_48);
    /* Setting MCLK to REFO at 48MHz for LF mode */
    CS_initClockSignal(CS_MCLK, CS_DCOCLK_SELECT, CS_CLOCK_DIVIDER_1);
    PCM_setPowerState(PCM_AM_LF_VCORE0);
    /* Enabling the FPU for floating point operation */
    FPU_enableModule();
    FPU_enableLazyStacking();
    /* Selecting P1.2 and P1.3 in UART mode */
    GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P1,
    GPIO_PIN1 | GPIO_PIN2 | GPIO_PIN3, GPIO_PRIMARY_MODULE_FUNCTION);
    /*setting P2.5 as output and initializing to 0*/
    GPIO_setAsOutputPin(GPIO_PORT_P2, GPIO_PIN5);
    GPIO_setOutputLowOnPin(GPIO_PORT_P2, GPIO_PIN5);
    /*setting LED Pin P1.0 as output and initializing to 0*/
    GPIO_setAsOutputPin(GPIO_PORT_P1, GPIO_PIN0);
    GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN0);
    /* Configuring GPIOs (5.5 A0) */
    GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P5, GPIO_PIN5,
    GPIO_TERTIARY_MODULE_FUNCTION);
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  • Hi Gopalakrishnan,

    With regards to your code, what are you trying to achieve with your ADC from a performance perspective? I would be concerned that the math and uart transmission you are trying to do in your interrupt is overrunning future interrupts. Because you are operating at 48MHz, and your interrupt is every 20us, you only have 960 clock cycles to complete the conversion and math. Have you measured how many clock cycles this part of your interrupt takes?
  • first of all thank you Evan for helping out...
    the main objective of my code is to do adc on a 1Khz sin signal( this is a part of my project work), and display the Adc result in a hyper terminal, since i am new to this field im learning it slowly so i am not sure about the clock cycle counts....and i am sure that the math and uart over runs the future interrupts...
    i tried doing atleast 20 samples per cycle but was unable to do as the math and uart took the time, so
    please help me out in doing ADC on 1Khz signal with atleast 20 samples per cycle...
    thank you
  • Gopalakrishnan,

    I would first look at increasing the baud rate of your UART. you are using 9600 baud which is significantly slower than 115200 baud. That may help, but with regards to timing I'm not sure if this will still get you inside the window that you are looking for.

    /* UART Configuration Parameter. These are the configuration parameters to
     * make the eUSCI A UART module to operate with a 115200 baud rate. These
     * values were calculated using the online calculator that TI provides
     * at:
     * software-dl.ti.com/.../index.html
     */
    const eUSCI_UART_Config uartConfig =
    {
            EUSCI_A_UART_CLOCKSOURCE_SMCLK,          // SMCLK Clock Source
            13,                                      // BRDIV = 13
            0,                                       // UCxBRF = 0
            37,                                      // UCxBRS = 37
            EUSCI_A_UART_NO_PARITY,                  // No Parity
            EUSCI_A_UART_MSB_FIRST,                  // MSB First
            EUSCI_A_UART_ONE_STOP_BIT,               // One stop bit
            EUSCI_A_UART_MODE,                       // UART mode
            EUSCI_A_UART_OVERSAMPLING_BAUDRATE_GENERATION  // Oversampling
    };

    If this doesn't work, I would adjust the code to continue to use the 115200 baud, but remove your floating point to string conversion math and see if this works within your window. Lastly, if this doesn't work, I would look towards removing your UART_TransmitData outside of your interrupt service routine and instead transmit before going back to LPMx mode in your while(1). Let me know if this helps.

  • Hi Evan,
    I already have tried with baud rates even greater than 115200 but the delay condition remains the same... but as you have mentioned above i will try removing the math part and will run the code again
    my question is that
    1)is there a problem with the ADC conversion time?? in this code how long does it take for a single conversion? and is there a way to minimize the conversion time if it is long..
    2) will there be any change if i use all the functions done in interrupt section to the main part??
    thanks and regards,
    Gopalakrishnan
  • Hi Evan ,
    i did the modifications as u said, and the delay has come down and its better now..
    i have an array of 500 float values and i need to send the float values stored to a hyper terminal using UART , how fast and simple this can be done??
    i am doing the math conversions because the hyperterminal displays the float values as desired only when this is done: is there any alternate way for this??
    thank you
  • Gopalakrishnan,

    With UART, the max on the MSP432 you can transfer is 3Mbaud. Keep in mind that a UART byte normally consists of 10 bits; 1 start bit, 8 data bits, 1 stop bit. This means that if you want to send data of an ADC with 14 bits, you have to send 2 bytes for each conversion. This means that you need to take the number of samples * 2 bytes * 10bits = x Mbaud. What is your desired number of samples/sample rate in this situation?
  • Evan,

    iam clear with the baud rate problem and i modified the code...i must have 30 samples per cycle ...or atleast a minimum of 20 samples per cycle..

    thank you

  • Gopalakrishnan,

    When you say 30 samples per cycle, are you saying 30 samples of the ADC per clock cycle of the MCU? This is not possible.

    Or are you referring to 20 samples per period of the 1khz signal you are trying to measure?
  • Evan,
    im refering to 20 samples per period of the 1khz signal, that is i want the analog values at 20 points in a sinusoidal period..
  • Gopalakrishnan,

    Would you maybe be interested in actually doing some of the processing of the float numbers on the computer/terminal side? Potentially using python?


    Can you send me your updated code?
  • Gopalakrishnan,

    have you looked into using something like DockLight terminal tool that can interpret raw hex values on your PC side? This might help. Otherwise, you might have to use python or log the info to a file and convert in a hex editor. Just more thoughts to this.
  • Hello Evan,

     i tried dock light and its working fine, i have another doubt... in the code that i have uploaded when i try to read data from the array as shown below,

    resultsBuffer[resPos] = (curADCResult * 3.3) / 16384;

    d=redultsBuffer[resPos];

    i often find the value at d to be 0 ratherbeing the value captured from adc at that moment, what might be the problem?

    is there any other way i cant get assistance during my work hours, im from india and i work from 0900 to 1700? 

    thank you,

  • Hi Gopalakrishnan,

    Can you please review the code attached to this thread. A colleague of mine and I sat down and created a simple example of what you are looking for running at 44khz. There are a number of changes that were made, please check the comments for the changes.

    We also would like to kindly ask that you update your driverlib and make sure you are using the Red MSP432 LaunchPad. There are a number of changes that have been made for the newer versions of driverlib and the Red LaunchPad contains Rev C silicon that has a number of bug fixes. 


    This code will send your ADC bytes in raw hex value, from here I would investigate if you can still do your math with this higher baud rate (1Mbaud currently). Instead of using the manual math on the CPU, you can leverage the ARM Floating-point Processing Unit (FPU) to do your math a little faster if you'd like. This can be done through the CMSIS DSP Library. See this app note for more details:

    Code is attached as "customer.c"

    customer.c
    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    /*
    * customer.c
    *
    */
    //* DriverLib Includes */
    #include <ti/devices/msp432p4xx/driverlib/driverlib.h>
    /* Standard Includes */
    #include <stdint.h>
    #include <stdbool.h>
    /* variable intialization */
    static volatile uint16_t curADCResult,dval,i,j;
    static volatile uint32_t dec;
    static volatile float resultsBuffer[UINT8_MAX],d;
    static volatile uint8_t resPos;
    char itos[8]={0,};
    /* UART configuration with 9600 baud rate and 48MHZ clock*/
    /*
    * 8bytes at 1M baud - 6.7ms, sampling rate is 12Khz, 83us
    */
    const eUSCI_UART_Config uartConfig =
    {
    EUSCI_A_UART_CLOCKSOURCE_SMCLK, // SMCLK Clock Source
    1, // BRDIV = 78
    8, // UCxBRF = 2
    0, // UCxBRS = 0
    EUSCI_A_UART_NO_PARITY, // No Parity
    EUSCI_A_UART_LSB_FIRST, // MSB First
    EUSCI_A_UART_ONE_STOP_BIT, // One stop bit
    EUSCI_A_UART_MODE, // UART mode
    EUSCI_A_UART_OVERSAMPLING_BAUDRATE_GENERATION // Oversampling
    };
    int main(void)
    {
    /* Halting the Watchdog */
    MAP_WDT_A_holdTimer();
    /* temporary and count variable*/
    curADCResult = 0;
    resPos = 0;
    /*
    * If going to run DCO at 48Mhz then you need to run at
    * Vcore1 and Flash wait state 1
    */
    MAP_PCM_setCoreVoltageLevel(PCM_VCORE1);
    /*
    * Revision C silicon supports wait states of 1 at 48Mhz
    * Revision B (black launchpad) requires 2
    */
    MAP_FlashCtl_setWaitState(FLASH_BANK0, 1);
    MAP_FlashCtl_setWaitState(FLASH_BANK1, 1);
    /* Setting DCO to 48MHz */
    MAP_CS_setDCOCenteredFrequency(CS_DCO_FREQUENCY_48);
    /* Setting MCLK to REFO at 48MHz for LF mode */
    MAP_CS_initClockSignal(CS_MCLK, CS_DCOCLK_SELECT, CS_CLOCK_DIVIDER_1);
    /*
    * USE SMCLK for ADC and not MCLK
    */
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  • Evan,

     what will be the major difference if i used a black MSP432?

    and is the baud rate 1M, and what does the sampling at 12Khz comment signify?

    thank you for ur time

  • Evan,
    i tried with the black board and it is working fine , with 44 samples per cycle and i was also able to transmit data to docklight as u said,
    but i have a doubt that
    /* transferring ADC result to a variable*/
    curADCResult = MAP_ADC14_getResult(ADC_MEM0);

    MAP_UART_transmitData(EUSCI_A0_BASE,(uint8_t)curADCResult);
    curADCResult = curADCResult >> 8;
    MAP_UART_transmitData(EUSCI_A0_BASE,(uint8_t)curADCResult);

    in the above codeu had transmitted the data twice, once before and after right shifting, why is it so?
    also what is the significance of right shifting to 8 bits???
    thanks and regards
    Gopalakrishnan P
  • Hi Gopalakrishnan,

    The 12kHz comment is actually a typo that we put there for something else but later adjusted the actual setting. It is actually sampling at roughly 44khz.

    With regards to the major different between the black and red launchpad, the black launchpad has Rev B devices, red LaunchPads has Rev C. You can check the errata to see a number of differences between the black and red launchpads. TI recommends that you use the red LaunchPad moving forward.
    Errata:
    www.ti.com/.../slaz610

    The right shift by 8 is to ensure the full ADC result is transmitted over uart. Your ADC result is 16bits, UART transmits 8 bits at a time, so to send the full 16 bits, you send the first 8 bits, left shift by 8 to prepare the next 8 bits and then send again thereby sending the full 16bits of information.
  • Evan,

    im now clear with the code. now i would like to know whether the following will work?

    d= ((curADCResult*3.3)/16384)*1000;

    MAP_UART_transmitData(EUSCI_A0_BASE,(uint8_t)d);

    what iam trying to do here is that to transmit the actual voltage values in millivolts , 

    what value will i obtain if i send this and visualise through docklight??

    what should be the actual value that is to be fed to docklight in order to get output in integer??

    regards

    Gopalakrishnan P

  • Gopalakrishnan,

    I'm not 100% sure on what question you're asking but this equation normalizes your ADC result. You would still need to left shift by 8 bits by the way and send the next 8 bits.

    If you send it to docklight and wish to view it in decimal or hex, you can do so by asking DockLight to display in hex or decimal. Please go ahead and try that and see if this gives you what you wish.

    If not, or if the timing doesn't work with normalizing the ADC result in time before the next interrupt, please try using the FPU through the CMSIS DSP library that i mentioned earlier.
  • Evan,
    thank you very much, i will give a try
    regards
  • Evan,

    i have another doubt. can you make me clear with the reference voltage value that i have used in the program?? what is the highest and lowest range of the ADC according to the code?? 

    thanks and regards

  • Gopalakrishnan,

    With regards to the reference voltage, since there is no code setting up the REF_A module, which controls the reference voltage, it will automatically default to 1.2V per section 19.3.1 of slau356, the TRM for the MSP432: www.ti.com/.../litabsmultiplefilelist.tsp

    highest and lowest range of the adc depends on your resolution. At 14 bit, With a 1.2V reference it results in a 14-bit ADC resolution of 73uV per code.
  • Evan,

    I asked the previous question because in an example program they have set the reference voltages to be default voltage (1.2 v) but they had used 3.3 to normalize the ADC value... why was it done??

    MAP_ADC14_configureConversionMemory(ADC_MEM0, ADC_VREFPOS_AVCC_VREFNEG_VSS,
    ADC_INPUT_A0, false);

    curADCResult = MAP_ADC14_getResult(ADC_MEM0);
    normalizedADCRes = (curADCResult * 3.3) / 16384;

    the above code is a part of example named ADC14_single_conversion_repeat

    thanks and regards

  • Gopalakrishnan,

    You're right, that is a bug in the code. Assuming that 1.2V is your Vref, you would divid by 1.2 to normalize the ADC value. Make sure if you change your reference voltage that you change this value accordingly. I will file for this to be fixed.
  • Gopalakrishnan,

    Thank you for clicking verify answer on every post and giving me a good laugh :)
  • Hi Evan,

    I tried modifying the code like I am doing certain number of samples and then transmitting them, so that i can avoid the delay that happened in the previous case.this works well... but i have two issues

    1) previously i was using UINT8_MAX  for the resultsBuffer array in which iam supposed to store the ADC results, by thi sthe array is defined to  a size of 256, the code i modified is now sending 200 values at a time, now i thought of increasing the array size and to increase the number of samples sent at an instance by making the array size as resultsBuffer[UINT16_MAX], when i used this it says im out of memory, how to overcome this issue?? the image below is the error

    2) in the code i am interrupting the timer once 200 samples have been saved , to send those data stored. i would like to start the timer again to do the same process again ,but the timer stops after one cycle, how do i rectify this?/ i have also attached my code..please help solving these issues.

    thanks

    code gopal.txt
    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    /*
    * customer.c
    *
    */
    //* DriverLib Includes */
    #include "driverlib.h"
    /* Standard Includes */
    #include <stdint.h>
    #include <stdbool.h>
    /* variable intialization */
    static volatile uint16_t curADCResult,dval,i,j;
    static volatile uint32_t dec;
    static volatile float resultsBuffer[UINT16_MAX],d;
    static volatile uint16_t resPos;
    char itos[9]={0,};
    /* UART configuration with 9600 baud rate and 48MHZ clock*/
    /*
    * 8bytes at 1M baud - 6.7ms, sampling rate is 12Khz, 83us
    */
    const eUSCI_UART_Config uartConfig =
    {
    EUSCI_A_UART_CLOCKSOURCE_SMCLK, // SMCLK Clock Source
    1, // BRDIV = 78
    8, // UCxBRF = 2
    0, // UCxBRS = 0
    EUSCI_A_UART_NO_PARITY, // No Parity
    EUSCI_A_UART_LSB_FIRST, // MSB First
    EUSCI_A_UART_ONE_STOP_BIT, // One stop bit
    EUSCI_A_UART_MODE, // UART mode
    EUSCI_A_UART_OVERSAMPLING_BAUDRATE_GENERATION // Oversampling
    };
    int main(void)
    {
    /* Halting the Watchdog */
    MAP_WDT_A_holdTimer();
    /* temporary and count variable*/
    curADCResult = 0;
    resPos = 0;
    /*
    * If going to run DCO at 48Mhz then you need to run at
    * Vcore1 and Flash wait state 1
    */
    MAP_PCM_setCoreVoltageLevel(PCM_VCORE1);
    /*
    * Revision C silicon supports wait states of 1 at 48Mhz
    * Revision B (black launchpad) requires 2
    */
    MAP_FlashCtl_setWaitState(FLASH_BANK0, 2);
    MAP_FlashCtl_setWaitState(FLASH_BANK1, 2);
    /* Setting DCO to 48MHz */
    MAP_CS_setDCOCenteredFrequency(CS_DCO_FREQUENCY_48);
    /* Setting MCLK to REFO at 48MHz for LF mode */
    MAP_CS_initClockSignal(CS_MCLK, CS_DCOCLK_SELECT, CS_CLOCK_DIVIDER_1);
    /*
    * USE SMCLK for ADC and not MCLK
    */
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    and regards 

    Gopalakrishnan 

    ( your answers will be verified ;-)  )

  • Gopalakrishnan,

    I haven't had a chance to look into this yet, my apologies. Have you resolved this yet by chance on your own?

    At a high level, I would say that you are overrunning your SRAM. I would be again concerned that your readyToTransmit function is not actually completing before the next interrupt fires potentially. Do you at least get a little data as expected from this code?

    Also, your resultsBuffer doesn't seem to ever reset to 0, if I'm not making a mistake (not been able to test the code, just running it in my head). This could be where you are overrunning your SRAM.
  • Hello Evan,

    Sorry for the long break, the previously sent code was just to visualize the data stored in form of a graph using excels sheet , and i somehow managed to do the same and the quality of the wave was could( replication was good). Now I'm trying to process this digital signals to analog signals through a DAC unit. does the MSP432P401R board have an internal DAC unit like ADC if it is there can u help me start with the DAC unit to convert the digital values that is have to frame an analog signal??

    thank you,

    Gopalakrishnan P

  • Gopalakrishnan,

    I'm sorry, but there is not a DAC on the MSP432 MCU. You can use an external DAC and communicate to it via SPI or other serial communication peripheral.
  • Evan,
    thank you, i have started working on it...
  • hello Evan,

    i tried finding some forums regarding setting up a DAC externally to msp432, i have mentioned the link below also the circuit diagram

    available: 

    these are the things i would like to do,

    i must be able to reconstruct the analog signal on which we did ADC before .

    that is feed the ADC data to the MSP and to use the DAC setup and regain the signal..

    is it possible through the above given ckt and the code mentioned in  the link???

    kindly provide a solution,

    thank you,

    Gopalakrishnan P

  • Gopalakrishnan,

    With regards to the link, yes this is entirely possible. If I were you, in order to have more control over the operation with a DAC though I would recommend that you write you own code using driver lib or TI-Drivers. We have examples that showcase how to use the MSP432 as a Master SPI.
    Driverlib: dev.ti.com/.../
    TI Drivers: dev.ti.com/.../

    And more examples on how to use the ADC. dev.ti.com/.../

    Energia is an IDE that was created for hobbiests and makers that is used for rapid prototyping and abstracts a lot of the underlying capability to API's that are similar to the Wiring API used in other areas of the market. For the most efficient programming and the most control of your application, it's recommended to use DriverLib or TI Drivers.

    You can definitely use that code though with the Energia IDE, downloadable at energia.nu and try it for yourself. I don't have that hardware so I can't verify my personal experience with it though, but I would definitely use that as a template for a program to start your project and build off of it from there.

    I do not have an example that does specifically what you are asking for, but the best suggestion right now is to take the code examples I linked above and piece them together to achieve what you are looking to do.
  • hello Evan,

    I tried with the sample codes, I tried attaching he UART receiving part with the SPI part to communicate with the DAC hardware that is made externally, now before that I will explain what I actually need,

    1)previously we had discussed about ADC sampling of the analog signal, that part being done now I have a ADC data in one MSP

    2) this data has to be sent to another MSP which has DAC attached to it externally

    3) the receiving MSP should send the data received to DAC unit through SPI

    this is my objective.

    now,

    I have attached the code that I have tried, the following are my doubts

    1)can I use the same clock source SMCLK for both UART and SPI in the same board

    2) we had shifted the ADC value and sent it 8 bit at a time, now if I receive the data as such and send it to DAC will it affect the system?? ( in code customer.c )

    3) how do I send the 14 bit ADC values in binary as such  from MSP 1 to MSP 2??

    dac.txt
    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    //*****************************************************************************
    //
    // MSP432 main.c template - Empty main
    //
    //****************************************************************************
    /* DriverLib Includes */
    #include "driverlib.h"
    /* Standard Includes */
    #include <stdint.h>
    #include <stdbool.h>
    /* Statics */
    static volatile uint8_t RXData = 0;
    /* SPI Master Configuration Parameter */
    const eUSCI_SPI_MasterConfig spiMasterConfig =
    {
    EUSCI_B_SPI_CLOCKSOURCE_SMCLK, // SMCLK Clock Source
    3000000, // SMCLK = DCO = 3MHZ
    500000, // SPICLK = 500khz
    EUSCI_B_SPI_MSB_FIRST, // MSB First
    EUSCI_B_SPI_PHASE_DATA_CHANGED_ONFIRST_CAPTURED_ON_NEXT, // Phase
    EUSCI_B_SPI_CLOCKPOLARITY_INACTIVITY_HIGH, // High polarity
    EUSCI_B_SPI_3PIN // 3Wire SPI Mode
    };
    const eUSCI_UART_Config uartConfig =
    {
    EUSCI_A_UART_CLOCKSOURCE_SMCLK, // SMCLK Clock Source
    1, // BRDIV = 78
    8, // UCxBRF = 2
    0, // UCxBRS = 0
    EUSCI_A_UART_NO_PARITY, // No Parity
    EUSCI_A_UART_LSB_FIRST, // MSB First
    EUSCI_A_UART_ONE_STOP_BIT, // One stop bit
    EUSCI_A_UART_MODE, // UART mode
    EUSCI_A_UART_OVERSAMPLING_BAUDRATE_GENERATION // Oversampling
    };
    int main(void)
    {
    /* Halting the Watchdog */
    MAP_WDT_A_holdTimer();
    /*
    * If going to run DCO at 48Mhz then you need to run at
    * Vcore1 and Flash wait state 1
    */
    MAP_PCM_setCoreVoltageLevel(PCM_VCORE1);
    /*
    * Revision C silicon supports wait states of 1 at 48Mhz
    * Revision B (black launchpad) requires 2
    */
    MAP_FlashCtl_setWaitState(FLASH_BANK0, 2);
    MAP_FlashCtl_setWaitState(FLASH_BANK1, 2);
    /* Setting DCO to 48MHz */
    MAP_CS_setDCOCenteredFrequency(CS_DCO_FREQUENCY_48);
    MAP_CS_initClockSignal(CS_SMCLK, CS_DCOCLK_SELECT, CS_CLOCK_DIVIDER_2);
    /* Enabling the FPU for floating point operation */
    MAP_FPU_enableModule();
    MAP_FPU_enableLazyStacking();
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    kindly assist me with your corrections in the above attached code..

    thanks and regards,

    Gopalakrishnan P

  • hello EVAN ,
    can u also provide me some links where I can find connecting msp432 with Bluetooth modules
    thank you
  • Gopalakrishnan,

    For MSP432 + BLE please check: dev.ti.com/.../

    1) you can use SMCLK for both UART and SPI if you wish.

    2) I believe you would have to read up on how the DAC expects to receive data. This is dependent on the DAC you are using likely. I would look for example code that is previously used with the DAC you picked.

    A quick note, the DAC you picked, is 12 bits and won't showcase all 14-bits from your ADC measurement. You are essentially clipping 2 bits off of your measurement. If you are only sampling at 12 bits with the MSp432 this should be fine, but thought you should be aware. There are three wire spi examples that are in the link below that could be a good starting point. The TLV5618A has example code here: www.ti.com/.../slac087

    3) You can send the ADC values through SPI, I2C or UART. Any will work, its up to you to decide. There are a number of examples that show how I2C Master/Slave or SPI master/slave combo is done. Check here:
    dev.ti.com/.../
  • Gopalakrishnan,

    I'm going to close this thread now as the original question has been answered. For questions that you have with regards to other parts of your project in relation to the MSP432, please continue to post a new forum thread in the MSP MCU E2E forum and we will work at answering it. We try to keep from having multiple subjects covered in one thread so the community can also jump in when necessary. Thanks for understand!

**Attention** This is a public forum