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: 8 MHz UART

Tool/software: TI-RTOS

Hello,

for my project i have to run UART ant high frequency, say 8 MHz.. if not possible at least 8 MHz,

I did modify a NORTOS UART echo example, it runs at 8 MHz with following modifications 

const eUSCI_UART_Config uartConfig =
{
        EUSCI_A_UART_CLOCKSOURCE_SMCLK,          // SMCLK Clock Source
        3,                                     // BRDIV 
        0,                                       // UCxBRF 
        0,                                       // UCxBRS 
        EUSCI_A_UART_NO_PARITY,                  // No Parity
        EUSCI_A_UART_LSB_FIRST,                  // LSB First
        EUSCI_A_UART_ONE_STOP_BIT,               // One stop bit
        EUSCI_A_UART_MODE,                       // UART mode
        0//EUSCI_A_UART_OVERSAMPLING_BAUDRATE_GENERATION  // Oversampling
};

int main ()

{

...

 CS_setDCOCenteredFrequency(CS_DCO_FREQUENCY_24);

...

}

So, far. all is ok. ... SMLK 24MHZ divider is 3. I see on osciloscope propr frequency.

The problem is that I cannot run UART with 8 mhz in TIRTOS.

What I did..

1. I changed and recompiled TIRTOS with changes in PowerMSP432.c

PowerMSP432_PerfLevel PowerMSP432_perfLevels[NUMPERFLEVELS] = {

...

{ .activeState = AM_DCDC_VCORE1,
.VCORE = 1,
.clockSource = CS_DCOCLK_SELECT,
.DCORESEL = CS_DCO_FREQUENCY_48,
.DIVM = CS_CLOCK_DIVIDER_1,
.DIVHS = CS_CLOCK_DIVIDER_2,
.DIVS = CS_CLOCK_DIVIDER_2,
.flashWaitStates = 2,
.enableFlashBuffer = true,
.MCLK = 48000000,
.HSMCLK = 24000000,
.SMCLK = 24000000,
.ACLK = 32768
},

 

I changed related array const UARTMSP432_BaudrateConfig uartMSP432Baudrates[] properly..

{8000000, 24000000,   3,  0,   0, 0},

 


I can init, but cannot run UART.

on second UART_write the UCTXIFG = 0, (UCAxIFG register)

then exit().

Questions

1 Why this register field is 0? I see on osciloscope that the sending was on the uart line. all is ok.?

2 Can I simply write 1 to the UCTXIFG? if yes how I can in TIRTOS do that?

Thanks

  • Hello Yuliy,

    There is no need to re-build PowerMSP432.c, please take a look at this post e2e.ti.com/.../2222805

    Also, could you please share your MSP_EXP432P401R.c file.

    Thanks,

    David
  • >There is no need to re-build PowerMSP432.c, please take a look at this post e2e.ti.com/.../2222805

    Sorry, following your link I see that TI do advise to rebuildthe TIRTOS.. 

    or how must I understand  our "new" performance level?

    By the way I used exactly the same new element, otherwise I cannot reach UART frequency 8 mHz...

    So I rebuild the TIRTOS.

    Now my code completely..

    /*
     *  ======== uartecho.c ========
     */
    
    #include <ti/devices/msp432p4xx/driverlib/driverlib.h>
    #include <msp.h>
    /* XDCtools Header files */
    #include <xdc/std.h>
    #include <xdc/runtime/System.h>
    
    /* BIOS Header files */
    #include <ti/sysbios/BIOS.h>
    #include <ti/sysbios/knl/Task.h>
    #include <ti/sysbios/knl/Semaphore.h>
    
    /* TI-RTOS Header files */
    #include <ti/drivers/GPIO.h>
    #include <ti/drivers/UART.h>
    
    /* Example/Board Header files */
    #include "Board.h"
    
    #include <stdint.h>
    #include <string.h>
    
    #define TASKSTACKSIZE     768
    
    Task_Struct task0Struct;
    Char task0Stack[TASKSTACKSIZE];
    Semaphore_Handle writeSem;
    uint32_t cnt;
    
    void writeCallBack (UART_Handle h, void *buf, size_t count)
    {
        cnt = count;
        Semaphore_post(writeSem);
    }
    
    #define EUSCI_A_CMSIS(x) ((EUSCI_A_Type *) x)
    /*
     *  ======== echoFxn ========
     *  Task for this function is created statically. See the project's .cfg file.
     */
    Void echoFxn(UArg arg0, UArg arg1)
    {
        char buff[256];
        memset(buff,0x55,256);
        UART_Handle uart;
        UART_Params uartParams;
    
        /* Create a UART with data processing off. */
        UART_Params_init(&uartParams);
        uartParams.writeDataMode = UART_DATA_BINARY;
        uartParams.readDataMode = UART_DATA_BINARY;
        uartParams.readReturnMode = UART_RETURN_FULL;
        uartParams.readEcho = UART_ECHO_OFF;
        uartParams.baudRate = 8000000;
        uartParams.writeMode         = UART_MODE_CALLBACK;
        uartParams.writeCallback     = writeCallBack;
    
    
        uart = UART_open(Board_UART0, &uartParams);
    
        if (uart == NULL) {
            System_abort("Error opening the UART");
        }
    
        /* Loop forever echoing */
        cnt = 0;
        while (1)
        {
            uint32_t n = UART_write(uart, buff, 256);
            Semaphore_pend(writeSem, BIOS_WAIT_FOREVER);
            BITBAND_PERI(EUSCI_A_CMSIS(EUSCI_A0_BASE)->IFG, UCTXIFG_OFS) = 1;
            Task_sleep(2);
        }
    }
    /*
     *  ======== main ========
     */
    int main(void)
    {
        /* Call board init functions */
        Board_initGeneral();
        Board_initGPIO();
        Board_initUART();
    
        writeSem = Semaphore_create(0, NULL, NULL);
    
        /* Construct BIOS objects */
        Task_Params taskParams;
    
        Task_Params_init(&taskParams);
        taskParams.stackSize = TASKSTACKSIZE;
        taskParams.stack = &task0Stack;
        taskParams.instance->name = "echo";
        taskParams.priority = 12;
        Task_construct(&task0Struct, (Task_FuncPtr) echoFxn, &taskParams, NULL);
    
        /* Turn on user LED */
        GPIO_write(Board_LED0, Board_LED_ON);
    
        /* Start BIOS */
        BIOS_start();
    
        return (0);
    }
    

    the question is

    Why I do have to set the UCTXIFG bit back to 1?

    Why it not happen with UART freq. 9600 ... 256000?

    Thanks

  • Hello,

    I just created this example code (7MBaud) and I do not see this behavior, could you please give it a try and let me know your results.

    In regards to "re-build PowerMSP432.c", you will only need to create a custom perf level in your MSP_EXP432P401R.c as it is explained in this post https://e2e.ti.com/support/microcontrollers/msp430/f/166/p/603334/2220428#2220428.

    Anyway, 8MBaud is out of specification, so we do not recommend it, please also take a look this post: https://e2e.ti.com/support/microcontrollers/msp430/f/166/p/609301/2242742#2242742 and let us know if you have further questions.

     Best regards,

        David

  • Thank you for the detailed answer.

    Yes, I agree I do not have to rebuild the TIRTOS, thank you for the advice...

    regarding your project, I cannot build it, got following error.


    **** Clean-only build of configuration Debug for project uartecho_EUSCI_A3_MSP_EXP432P401R_tirtos_ccs ****

    "C:\\ti\\ccsv7\\utils\\bin\\gmake" -k -j 8 clean -O
    DEL /F "uartecho_EUSCI_A3_MSP_EXP432P401R_tirtos_ccs.hex" "uartecho_EUSCI_A3_MSP_EXP432P401R_tirtos_ccs.out"
    DEL /F "MSP_EXP432P401R.obj" "main_tirtos.obj" "uartecho.obj"
    DEL /F "MSP_EXP432P401R.d" "main_tirtos.d" "uartecho.d"
    Could Not Find C:\Users\oxford\temp\uartecho_EUSCI_A3_MSP_EXP432P401R_tirtos_ccs\Debug\uartecho_EUSCI_A3_MSP_EXP432P401R_tirtos_ccs.hex
    Could Not Find C:\Users\oxford\temp\uartecho_EUSCI_A3_MSP_EXP432P401R_tirtos_ccs\Debug\MSP_EXP432P401R.obj
    Could Not Find C:\Users\oxford\temp\uartecho_EUSCI_A3_MSP_EXP432P401R_tirtos_ccs\Debug\MSP_EXP432P401R.d
    'Finished clean'
    ' '

    **** Build Finished ****
    Buildfile generation error occurred..
    Referenced project 'tirtos_builds_MSP_EXP432P401R_release_ccs' does not exist in the workspace. Project 'uartecho_EUSCI_A3_MSP_EXP432P401R_tirtos_ccs' may not build as expected.
    Build stopped..

  • Hello,

      Maybe you can try importing the project into a brand new CCS workspace. If that does not work, I used the uart echo example as reference, so you may want to import this project and then copy the files (overwrite) from my project into this project.

      Hopefully this helps.

        David

  • okay, now it works...

    thank you

**Attention** This is a public forum