Other Parts Discussed in Thread: CC3235SF, SYSCONFIG
Hi,
I'm testing UART with CC3235SF LaunchPad and CC32xx SDK 4.40.00.07.
I use both UART0 and UART1 with 921600 baud rate, and I try to bypass the data from UART1 to UART0(Data packet -> UART1 Rx -> UART0 Tx -> PC, final goal is from UART1 to Wi-Fi).
and the size of data packet is variable, but it is about 800 bytes on average and it is transmitted at 100ms intervals.
I modify the uartecho example for using Read callback mode and my code is work well.
1.
But for using DMA, after enable the DMA in sysconfig tool, it occur the data loss on terminal program(tera term).
Source code isn't modified.
what am i doing wrong?
here is my code
/* * Copyright (c) 2015-2020, Texas Instruments Incorporated * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * * Neither the name of Texas Instruments Incorporated nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * ======== 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" /* Ringbuffer */ #include "rb.h" UART_Handle uart0, uart1; RingFifo_t UART0Rx_Rb, UART1Rx_Rb; uint8_t input; uint32_t cbCount; /* * ======== UART RX Callback (HWI) ======== */ void UART_RX_cb(UART_Handle handle, void *buf, size_t count) { if(handle == uart0) { RB_write(&UART0Rx_Rb, ((uint8_t*)buf)[0]); } else if(handle == uart1) { RB_write(&UART1Rx_Rb, ((uint8_t*)buf)[0]); } } /* * ======== mainThread ======== */ void *mainThread(void *arg0) { const char echoPrompt[] = "Echoing characters from UART0:\r\n"; const char echoPrompt2[] = "Echoing characters from UART1:\r\n"; UART_Params uartParams; uint8_t ch; /* 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); RB_init(&UART0Rx_Rb, 128); RB_init(&UART1Rx_Rb, 4096); /* 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.readMode = UART_MODE_CALLBACK; uartParams.readCallback = UART_RX_cb; uartParams.baudRate = 921600; uart0 = UART_open(CONFIG_UART_0, &uartParams); if (uart0 == NULL) { /* UART_open() failed */ while (1); } uart1 = UART_open(CONFIG_UART_1, &uartParams); if (uart1 == NULL) { /* UART_open() failed */ while (1); } /* remove uart receive from LPDS dependency */ // UART_control(uart, UART_CMD_RXDISABLE, NULL); /* Turn on user LED to indicate successful initialization */ GPIO_write(CONFIG_GPIO_LED_0, CONFIG_GPIO_LED_ON); UART_write(uart0, echoPrompt, sizeof(echoPrompt)); UART_write(uart1, echoPrompt2, sizeof(echoPrompt2)); UART_read(uart0, &input, 1); UART_read(uart1, &input, 1); /* Loop forever bypass */ while (1) { if(!RB_isempty(&UART0Rx_Rb)) { ch = RB_read(&UART0Rx_Rb); UART_write(uart1, &ch, 1); UART_read(uart0, &input, 1); } if(!RB_isempty(&UART1Rx_Rb)) { ch = RB_read(&UART1Rx_Rb); UART_write(uart0, &ch, 1); UART_read(uart1, &input, 1); } } }
2.
I tried to open both UART0 and UART1 by referring to the uart2callback example to try the UART2 driver too.
But it is not work.
As a result to run debug in CCS, when process the UART_open function, it is trapped loop. (more detail, UART_open -> HwiP_construct -> Hwi_construct2 -> Hwi_construct)
here is my code
/*
* Copyright (c) 2015-2020, Texas Instruments Incorporated
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
* ======== uartecho.c ========
*/
#include <stdint.h>
#include <stddef.h>
/* Driver Header files */
#include <ti/drivers/GPIO.h>
#include <ti/drivers/UART2.h>
/* Driver configuration */
#include "ti_drivers_config.h"
/* Ringbuffer */
#include "rb.h"
UART2_Handle uart0, uart1;
RingFifo_t UART0Rx_Rb, UART1Rx_Rb;
uint8_t input;
/*
* ======== UART2 RX Callback (HWI) ========
*/
void UART2_RX_cb(UART2_Handle handle, void *buf, size_t count, void *userArg, int_fast16_t status)
{
if (status != UART2_STATUS_SUCCESS) {
/* RX error occured in UART2_read() */
while (1);
}
if(handle == uart0)
{
RB_write(&UART0Rx_Rb, ((uint8_t*)buf)[0]);
UART2_read(uart0, &input, 1, NULL);
}
else if(handle == uart1)
{
RB_write(&UART1Rx_Rb, ((uint8_t*)buf)[0]);
UART2_read(uart1, &input, 1, NULL);
}
}
/*
* ======== mainThread ========
*/
void *mainThread(void *arg0)
{
const char echoPrompt[] = "Echoing characters from UART0:\r\n";
const char echoPrompt2[] = "Echoing characters from UART1:\r\n";
UART2_Params uartParams;
uint32_t status = UART2_STATUS_SUCCESS;
uint8_t ch;
/* 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);
RB_init(&UART0Rx_Rb, 256);
RB_init(&UART1Rx_Rb, 4096);
/* Create a UART with data processing off. */
UART2_Params_init(&uartParams);
uartParams.readMode = UART2_Mode_CALLBACK;
uartParams.readCallback = UART2_RX_cb;
uartParams.baudRate = 921600;
uart0 = UART2_open(CONFIG_UART2_0, &uartParams);
if (uart0 == NULL) {
/* UART_open() failed */
while (1);
}
uart1 = UART2_open(CONFIG_UART2_1, &uartParams);
if (uart1 == NULL) {
/* UART_open() failed */
while (1);
}
/* remove uart receive from LPDS dependency */
// UART_control(uart, UART_CMD_RXDISABLE, NULL);
/* Turn on user LED to indicate successful initialization */
GPIO_write(CONFIG_GPIO_LED_0, CONFIG_GPIO_LED_ON);
UART2_write(uart0, echoPrompt, sizeof(echoPrompt), NULL);
UART2_write(uart1, echoPrompt2, sizeof(echoPrompt2), NULL);
status = UART2_read(uart0, &input, 1, NULL);
if (status != UART2_STATUS_SUCCESS) {
/* UART2_read() failed */
while (1);
}
status = UART2_read(uart1, &input, 1, NULL);
if (status != UART2_STATUS_SUCCESS) {
/* UART2_read() failed */
while (1);
}
/* Loop forever echoing */
while (1) {
if(!RB_isempty(&UART0Rx_Rb))
{
ch = RB_read(&UART0Rx_Rb);
UART2_write(uart1, &ch, 1, NULL);
}
if(!RB_isempty(&UART1Rx_Rb))
{
ch = RB_read(&UART1Rx_Rb);
UART2_write(uart0, &ch, 1, NULL);
}
}
}
Please help me out where I'm making mistake.
Thanks.
그러나 DMA를 사용하는 경우 sysconfig 도구에서 DMA를 활성화 한 후 터미널 프로그램 (테라 용어)에서 데이터 손실이 발생합니다.