File size: 10,620 Bytes
5aefcf4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
Ticket Name: RTOS/TDA2EXEVM: uart2 no work

Query Text:
Part Number: TDA2EXEVM Other Parts Discussed in Thread: TDA2 Tool/software: TI-RTOS Hi Expert, I'm running PROCESSOR SDK VISION v03.04.00 rtos on tda2eg. TDA2 EVM and custom board both have. I modify and run CSL uart test present here: PROCESSOR_SDK_VISION_03_04_00_00\ti_components\drivers\pdk_01_10_00_08\packages\ti\csl\example\uart\uart_test I call UARTConfigInit() to initial UART2 engine after pin mux setting finish. but system get stuck problem when I call UARTConfigInit() API. Could you please give me some advise? Thanks in advance. attach is source file. 1832.main.c /*
 *  Copyright (C) 2013-2017 Texas Instruments Incorporated - http://www.ti.com/
 *
 *  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.
 *
 */

 /**
 *  \file   main.c
 *
 *  \brief This file demonstrates UART console input and output.
 *         Expects user to enter an input string and outputs the same
 *         on console.
 *
 **/

/* ========================================================================== */
/*                             Include Files                                  */
/* ========================================================================== */
#include <stdint.h>
#include <stdio.h>
#include <ti/csl/hw_types.h>
#include <ti/csl/soc.h>
#include <ti/csl/example/utils/uart_console/inc/uartConfig.h>
#if defined (SOC_AM574x) || defined (SOC_AM572x) || defined (SOC_AM571x)
#include <ti/board/board.h>
#endif

/* ========================================================================== */
/*                                 Macros                                     */
/* ========================================================================== */

/* Commented define TESTCASE_ID to test with default settings of
 * BAUD_RATE    = 115200,
 * WORD_LENGTH  = 8Bits,
 * STOP_BIT     = 1,
 * PARITY       = None.
 * Uncomment below define and set to appropriate test case number to test
 * specific configuration.
 */

/*
#define TESTCASE_ID     UART_19
*/

#if (TESTCASE_ID == UART_1)
#define BAUD_RATE       BAUD_RATE_9600
#endif

#if (TESTCASE_ID == UART_2)
#define BAUD_RATE       BAUD_RATE_14400
#endif

#if (TESTCASE_ID == UART_3)
#define BAUD_RATE       BAUD_RATE_19200
#endif

#if (TESTCASE_ID == UART_4)
#define BAUD_RATE       BAUD_RATE_38400
#endif

#if (TESTCASE_ID == UART_5)
#define BAUD_RATE       BAUD_RATE_57600
#endif

#if (TESTCASE_ID == UART_6)
#define BAUD_RATE       BAUD_RATE_115200
#endif

#if (TESTCASE_ID == UART_7)
#define BAUD_RATE       BAUD_RATE_230400
#endif

#if (TESTCASE_ID == UART_8)
#define BAUD_RATE       BAUD_RATE_460800
#define UART_MODE       UART_13x_MODE
#endif

#if (TESTCASE_ID == UART_9)
#define BAUD_RATE       BAUD_RATE_921600
#define UART_MODE       UART_13x_MODE
#endif

#if (TESTCASE_ID == UART_10)
#define WORD_LENGTH     UART_WORD_LENGTH_5
#endif

#if (TESTCASE_ID == UART_11)
#define WORD_LENGTH     UART_WORD_LENGTH_6
#endif

#if (TESTCASE_ID == UART_12)
#define WORD_LENGTH     UART_WORD_LENGTH_7
#endif

#if (TESTCASE_ID == UART_13)
#define WORD_LENGTH     UART_WORD_LENGTH_8
#endif

#if (TESTCASE_ID == UART_14)
#define STOP_BIT        UART_STOP_BIT_1
#endif

#if (TESTCASE_ID == UART_15)
#define STOP_BIT        UART_STOP_BIT_1_5_2
#define WORD_LENGTH     UART_WORD_LENGTH_5
#endif

#if (TESTCASE_ID == UART_16)
#define STOP_BIT        UART_STOP_BIT_1_5_2
#endif

#if (TESTCASE_ID == UART_17)
#define PARITY      UART_NO_PARITY
#endif

#if (TESTCASE_ID == UART_18)
#define PARITY      UART_PARITY_ODD
#endif

#if (TESTCASE_ID == UART_19)
#define PARITY      UART_PARTY_EVEN
#endif

#ifndef BAUD_RATE
#define BAUD_RATE       BAUD_RATE_115200
#endif

#ifndef WORD_LENGTH
#define WORD_LENGTH     UART_WORD_LENGTH_8
#endif

#ifndef STOP_BIT
#define STOP_BIT        UART_STOP_BIT_1
#endif

#ifndef PARITY
#define PARITY          UART_NO_PARITY
#endif

#ifndef UART_MODE
#define UART_MODE       UART_16x_MODE
#endif

#define UART_INST_NUM                    (1U)
uint32_t uartBaseAddr;
uint32_t uart2Addr;

#define df_uart1	1
#define df_uart2	1
/* ========================================================================== */
/*                            Global Variables                                */
/* ========================================================================== */
/* None */

/* ========================================================================== */
/*                          Function Definitions                              */
/* ========================================================================== */
#if 1
void delay(void)
{
    volatile uint32_t i;
    for (i = 0; i < 1000000; i++)
    {}
}
#endif
//'----------------------------------------------------------



void padConfig_prcmEnable()
{
#if defined (SOC_AM574x) || defined (SOC_AM572x) || defined (SOC_AM571x)
/*'
    // Pad configurations
    Board_initCfg boardCfg;
    boardCfg = BOARD_INIT_UNLOCK_MMR | BOARD_INIT_UART_STDIO | 
               BOARD_INIT_MODULE_CLOCK | BOARD_INIT_PINMUX_CONFIG;
    Board_init(boardCfg);  
*/	
#endif
#if defined (SOC_TDA2XX) || defined (SOC_TDA2PX) || defined (SOC_TDA2EX) || defined (SOC_DRA72x) || defined (SOC_DRA75x)

#if df_uart1	//'	uart1
    /*Pad configurations */
    HW_WR_REG32(SOC_CORE_PAD_IO_REGISTERS_BASE+CTRL_CORE_PAD_UART1_RXD,0x00040000);
    HW_WR_REG32(SOC_CORE_PAD_IO_REGISTERS_BASE+CTRL_CORE_PAD_UART1_TXD,0x00000000);
    /* Set the UART Parameters */
    UARTConfigInit(uartBaseAddr, BAUD_RATE, WORD_LENGTH, STOP_BIT, PARITY, UART_MODE);
#endif					

#if df_uart2	//'	uart2
    HW_WR_REG32(SOC_CORE_PAD_IO_REGISTERS_BASE+CTRL_CORE_PAD_UART2_RXD,0x00040000);
    HW_WR_REG32(SOC_CORE_PAD_IO_REGISTERS_BASE+CTRL_CORE_PAD_UART2_TXD,0x00000000);
    UARTConfigInit(uart2Addr, BAUD_RATE, WORD_LENGTH, STOP_BIT, PARITY, UART_MODE);	
#endif					
					
#endif
#if defined (SOC_TDA3XX) || defined (SOC_DRA78x)
/*'
    // Pad configurations
    HW_WR_REG32(SOC_CORE_PAD_IO_REGISTERS_BASE+CTRL_CORE_PAD_IO_SPI1_SCLK,0x00040001);
    HW_WR_REG32(SOC_CORE_PAD_IO_REGISTERS_BASE+CTRL_CORE_PAD_IO_SPI1_CS0,0x00000001);
    // Set the UART Parameters 
    UARTConfigInit(uartBaseAddr, BAUD_RATE, WORD_LENGTH, STOP_BIT, PARITY,
                    UART_MODE);
*/
#endif
}

int main(void)
{
    char     dataBuffer[100];
    uartBaseAddr = SOC_UART1_BASE;
	uart2Addr = SOC_UART2_BASE;

/*'
#if defined (SOC_TDA3XX) || defined (SOC_DRA78x)
    uartBaseAddr = SOC_UART3_BASE;
#endif
#if (defined (SOC_AM574x) || defined (SOC_AM572x)) || (defined (SOC_AM571x))
    uartBaseAddr = SOC_UART3_BASE;
#endif
*/

    /*Pad configuration and PRCM enable*/
    padConfig_prcmEnable();

	//'------------------------------------------------
	while(1){
		
#if df_uart1		
		UARTConfigPuts(uartBaseAddr, "--tnzaku02------ uart1\n", -1);
#endif

#if df_uart2
		UARTConfigPuts(uart2Addr, "--tnzaku02------ uart2\n", -1);
#endif		
		delay();

		
	}	
	
	
    /* UART receive and transmit operation */
    UARTConfigPuts(uartBaseAddr, "\nUART Test", -1);

    UARTConfigPuts(uartBaseAddr, "\nEnter some data to transmit:", -1);

    UARTConfigGets(uartBaseAddr, &dataBuffer[0], -1);

    UARTConfigPuts(uartBaseAddr, "\nData Received:", -1);

    UARTConfigPuts(uartBaseAddr, &dataBuffer[0], -1);

    UARTConfigPuts(uartBaseAddr, "\nUART Test Completed", -1);

	
    return 0;
}
/********************************* End of file ******************************/

Responses:
Hi, How are you running this binary? This is a standalone example that should be run using CCS. You should make sure that you are not booting Vision SDK when you try to run this binary. Also you can't run UART test for UART2 on the EVM as there is no connection for UART2. Regards, Rishabh

Hi, command window > gmake csl_uart_test_app BOARD=tda2ex-evm CORE=ipu1_0 Refer "Load using CCS" in VisionSDK_UserGuide_TDA2Ex.pdf to load and run csl_uart_test_app_ipu1_0_release.xem4 Tested in TDA2 EVM and custom board. It is normal to only test uart1 printing, but after adding UARTConfigInit() to initial UART2, uart1 is nothing print out. So guess the initial UART2 has a problem. Thanks in advance.

Hi, As I specified previously you cannot use UART2 for communication as there is no connection between UART2 pins and FTDI chip. On custom board you have to check the schematics and find out if there is a route available for UART2. You also need to set the pin mux, IO expanders, etc depending on board schematics. Regards, Rishabh

Hi, On custom board previously used linux to confirm that uart2 is working. There is a route available for UART2. --------------------------------------------------------------------------------------------- As I specified previously: It is normal to only test uart1 printing, but after adding UARTConfigInit() to initial UART2, uart1 is nothing print out. Tracking with CCS will stop at UARTConfigInit() to UART2. Why does UARTConfigInit() to UART2 the operation to stop? Thanks in advance.

Hi, UARTConfigInit() API modifies UART2 registers. Have you enabled UART2 in PRCM? If UART2 is not enable and you try to access the registers you will see a crash. Regards, Rishabh