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.

LAUNCHCC3220MODASF: About UART multiprocessor format communication

Part Number: LAUNCHCC3220MODASF
Other Parts Discussed in Thread: CC3220S, TEST2

Hi Team,

I want to use the UART in a "multiprocessor format".
(The first byte of data is transmitted with parity bit 1.
Subsequent data is transmitted with the parity bit set to 0. )

Code Composer Studio Version: 10.2.0.00009
SimpleLink CC32xx SDK (4.40.00.07)

So, I changed the program from "C: \ ti \ simplelink_cc32xx_sdk_4_40_00_07 \ examples \ rtos \ CC3220S_LAUNCHXL \ drivers \ uartecho" and tested it.

 *  ======== uartecho.c ========
 */
#include <stdint.h>
#include <stddef.h>

/* Driver Header files */
#include <ti/drivers/GPIO.h>
#include <ti/drivers/UART.h>

/* Driver configuration */
#include "ti_drivers_config.h"

#include <ti/devices/cc32xx/inc/hw_memmap.h>
#include <ti/drivers/uart/UARTCC32XXDMA.h>
#include <ti\devices\cc32xx\inc\hw_uart.h>

/*
 *  ======== mainThread ========
 */
void *mainThread(void *arg0)
{
    char        input;
    const char  echoPrompt[] = "Echoing characters:\r\n";
    UART_Handle uart;
    UART_Params uartParams;

    /* Call driver init functions */
    GPIO_init();
    UART_init();

    /* Configure the LED pin */
    GPIO_setConfig(CONFIG_GPIO_LED_0, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_LOW);

    /* 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.baudRate = 115200;

    uart = UART_open(CONFIG_UART_0, &uartParams);

    if (uart == NULL) {
        /* UART_open() failed */
        while (1);
    }

    /* Turn on user LED to indicate successful initialization */
    GPIO_write(CONFIG_GPIO_LED_0, CONFIG_GPIO_LED_ON);

    UART_write(uart, echoPrompt, sizeof(echoPrompt));

	input = '5';

    /* Loop forever echoing */
    while (1) {
//        UART_read(uart, &input, 1);
		UARTParityModeSet( UARTA0_BASE, UART_PAR_ONE );				//Step1
        UART_write(uart, &input, 1);								//Step2
		UARTParityModeSet( UARTA0_BASE, UART_PAR_ZERO );			//Step3
        UART_write(uart, &input, 1);								//Step4
		usleep(20000);
    }
}

When I Step Over the line of "Step 2", 1 byte was sent. This is the TX line of UART.

Next, when I Step Over the line of "Step 3", the TX line became Low.
I don't know the cause.

Then the "step 4" line doesn't work.
When I stepped in, I got an error in UART Busy.

Please tell me how to communicate in the multiprocessor format.

Thank you
Seitaro

  • Hi Seitaro-san,

    If you start the UART peripheral into UART_PAR_ZERO first, are you able to perform step 1 and step 2 correctly?

    The most likely cause for your issue is that the UART peripheral should not be reconfigured while it is enabled. Please take a look at section 6.3.6 and 6.3.7 of the TRM for documentation on the UART control and line control registers for more info: www.ti.com/lit/swru465

    If you disable the UART peripheral before switching parity, are you able to perform steps 3-4?

    Regards,

    Michael

  • Hi Michael,
    Thanks for replying.


    I set the parityType to UART_PAR_ZERO with the "UART_open" function.
    Added 1-character transmission as "Step0".

        /* 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.baudRate = 115200;
        uartParams.parityType = UART_PAR_ZERO;                          //Initialize
    
        uart = UART_open(CONFIG_UART_0, &uartParams);
    
        if (uart == NULL) {
            /* UART_open() failed */
            while (1);
        }
    
        /* Turn on user LED to indicate successful initialization */
        GPIO_write(CONFIG_GPIO_LED_0, CONFIG_GPIO_LED_ON);
    
        UART_write(uart, echoPrompt, sizeof(echoPrompt));
    
    	input = '5';
    
        /* Loop forever echoing */
        while (1) {
    //        UART_read(uart, &input, 1);
            UART_write(uart, &input, 1);                                //Step0
    		UARTParityModeSet( UARTA0_BASE, UART_PAR_ONE );				//Step1
            UART_write(uart, &input, 1);								//Step2
    		UARTParityModeSet( UARTA0_BASE, UART_PAR_ZERO );			//Step3
            UART_write(uart, &input, 1);								//Step4
    		usleep(20000);
        }
    

    After doing this, the TX line looks like this:
    The first character was sent with parity = 0 and the second character was sent with parity = 1.
    After that, the TX line became Low.

    (I want to paste the oscilloscope screen, but the "upload" button does not appear.

    This time I will explain without images.)


    Then I tried the following:

    I called the "UARTDisable" function before the "UARTParityModeSet" function and later called the "UARTEnable" function.
    The result was the same as before.

        /* Loop forever echoing */
        while (1) {
    //        UART_read(uart, &input, 1);
            UART_write(uart, &input, 1);                                //Step0
            UARTDisable(UARTA0_BASE);
    		UARTParityModeSet( UARTA0_BASE, UART_PAR_ONE );				//Step1
    		UARTEnable(UARTA0_BASE);
            UART_write(uart, &input, 1);								//Step2
            UARTDisable(UARTA0_BASE);
    		UARTParityModeSet( UARTA0_BASE, UART_PAR_ZERO );			//Step3
            UARTEnable(UARTA0_BASE);
            UART_write(uart, &input, 1);								//Step4
    		usleep(20000);
        }
    

    As I stepped through, the TX line went low when I executed the "UARTEnabl" function next to "STEP3".

    I stepped in the "UART Enable" function. When I enabled the UART on line 469 of "driverlib \ uart.c", the TX line went low.

    Is there anything else I can check?
    best regards,

    Seitaro

  • Hi Seitaro-san,

    Looking at your testing, it seems like switching to UART_PAR_ZERO causes the issue. If I understand your results correctly, in test 1 you were able to send 1 byte with parity zero, one byte with parity 1, but afterwards when you try to set the parity into parity zero it caused the TX line to go low.

    In test 2, you repeated the same test but this time disabling the UART before performing the parity change, but still encountered the same result, is that correct?

    Is the multiprocessor format UART a strict requirement for your project? If this behavior turns out to be a bug, it will be potentially difficult to fix given the low-level nature of the issue, and so investigating workarounds or other methods of performing your goal might be a good idea.

    Regards,

    Michael

  • Hi Michael,
    Thanks for replying.

    Both the result of TEST1 and the result of TEST2 are as you understand.
    The waveforms obtained for both TEST1 and TEST2 are the same.
    (I was able to upload it today.)

    A year ago, I delivered an RS-485 communication system using "multiprocessor format UART" to a customer.

    I need to connect CC3220 there with RS-485.
    (The CC3220 original board equipped with RS-485 has already been developed and manufactured.)

    Can you tell me a workaround for this issue?
    (If this behavior is a bug, I'll consider another way, as advised.) 

    best regards,

    Seitaro

  • Hi Seitaro-san,

    One further thing you can try is changing the UART driver in use. Distributed with the CC3220 SDK are actually three UART drivers - the regular UART driver, the UART driver with DMA enabled, as well the UART2 driver. If you try enabling DMA using the "Use DMA" option to switch drivers do you see any change in behavior.

    Finally, you can use the debugger to check the UART control registers to ensure that the UARTParityModeSet() function is actually functioning as expected. When you call that function, it will modify the UART_O_LCRH register. If you check that register in debug mode, is it set correctly after step3? Also, do the rest of the UART registers look correct?

    Regards,

    Michael

  • Hi Michael,
    Thanks for replying.

    I tried a UART driver with DMA enabled.
    The spacing between each character has increased, but the waveform is the same.


    Then I used a debugger to check the UART control registers.
    After calling "UARTParityModeSet (UARTA0_BASE, UART_PAR_ZERO);", the value of "UARTLCRH Register" was incorrect.
    The "UART Send Break" bit was 1.
    The mystery that the TX line goes low has been solved.

    I made a mistake in the argument of the "UARTParityModeSet" function.

    Wrong argument
    UARTParityModeSet (UARTA0_BASE, UART_PAR_ONE);
    UARTParityModeSet (UARTA0_BASE, UART_PAR_ZERO);

    Correct argument
    UARTParityModeSet (UARTA0_BASE, UART_CONFIG_PAR_ONE);
    UARTParityModeSet (UARTA0_BASE, UART_CONFIG_PAR_ZERO);

    I had to use the definitions in this file.
    ”C: \ ti \ simplelink_cc32xx_sdk_4_40_00_07 \ source \ ti \ devices \ cc32xx \ driverlib \ uart.h

    It is now possible to set the parity bit from 0 to 1 and from 1 to 0 for transmission.

    Thanks for your advice.
    Thanks to you, I was able to solve it.

    Seitaro