Other Parts Discussed in Thread: SYSBIOS
Tool/software: TI-RTOS
Hi,
I created a SYSBIOS sample code and trying to integrate UART CSL. Added CSL code from CSL example uart_test.
My code is given below
/*
* ======== main.c ========
*/
#include <xdc/std.h>
#include <xdc/runtime/Error.h>
#include <xdc/runtime/System.h>
#include <ti/sysbios/BIOS.h>
#include <ti/sysbios/knl/Task.h>
#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>
/* ========================================================================== */
/* 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;
/* ========================================================================== */
/* Global Variables */
/* ========================================================================== */
/* None */
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)
/*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 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
}
/*
* ======== taskFxn ========
*/
Void taskFxn(UArg a0, UArg a1)
{
System_printf("enter taskFxn()\n");
Task_sleep(10);
System_printf("exit taskFxn()\n");
System_flush(); /* force SysMin output to console */
}
/*
* ======== main ========
*/
Int main()
{
Task_Handle task;
Error_Block eb;
System_printf("enter main()\n");
char dataBuffer[100];
uartBaseAddr = SOC_UART1_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();
/* UART receive and transmit operation */
UARTConfigPuts(uartBaseAddr, "\nUART Test", -1);
Error_init(&eb);
task = Task_create(taskFxn, NULL, &eb);
if (task == NULL) {
System_printf("Task_create() failed!\n");
BIOS_exit(0);
}
BIOS_start(); /* does not return */
return(0);
}
My project configuration is given below
var Defaults = xdc.useModule('xdc.runtime.Defaults');
var Diags = xdc.useModule('xdc.runtime.Diags');
var Error = xdc.useModule('xdc.runtime.Error');
var Log = xdc.useModule('xdc.runtime.Log');
var LoggerBuf = xdc.useModule('xdc.runtime.LoggerBuf');
var Main = xdc.useModule('xdc.runtime.Main');
var Memory = xdc.useModule('xdc.runtime.Memory')
var SysMin = xdc.useModule('xdc.runtime.SysMin');
var System = xdc.useModule('xdc.runtime.System');
var Text = xdc.useModule('xdc.runtime.Text');
var BIOS = xdc.useModule('ti.sysbios.BIOS');
var Clock = xdc.useModule('ti.sysbios.knl.Clock');
var Swi = xdc.useModule('ti.sysbios.knl.Swi');
var Task = xdc.useModule('ti.sysbios.knl.Task');
var Semaphore = xdc.useModule('ti.sysbios.knl.Semaphore');
var Hwi = xdc.useModule('ti.sysbios.hal.Hwi');
/*
* Uncomment this line to globally disable Asserts.
* All modules inherit the default from the 'Defaults' module. You
* can override these defaults on a per-module basis using Module.common$.
* Disabling Asserts will save code space and improve runtime performance.
Defaults.common$.diags_ASSERT = Diags.ALWAYS_OFF;
*/
/*
* Uncomment this line to keep module names from being loaded on the target.
* The module name strings are placed in the .const section. Setting this
* parameter to false will save space in the .const section. Error and
* Assert messages will contain an "unknown module" prefix instead
* of the actual module name.
Defaults.common$.namedModule = false;
*/
/*
* Minimize exit handler array in System. The System module includes
* an array of functions that are registered with System_atexit() to be
* called by System_exit().
*/
System.maxAtexitHandlers = 4;
/*
* Uncomment this line to disable the Error print function.
* We lose error information when this is disabled since the errors are
* not printed. Disabling the raiseHook will save some code space if
* your app is not using System_printf() since the Error_print() function
* calls System_printf().
Error.raiseHook = null;
*/
/*
* Uncomment this line to keep Error, Assert, and Log strings from being
* loaded on the target. These strings are placed in the .const section.
* Setting this parameter to false will save space in the .const section.
* Error, Assert and Log message will print raw ids and args instead of
* a formatted message.
Text.isLoaded = false;
*/
/*
* Uncomment this line to disable the output of characters by SysMin
* when the program exits. SysMin writes characters to a circular buffer.
* This buffer can be viewed using the SysMin Output view in ROV.
SysMin.flushAtExit = false;
*/
/*
* The BIOS module will create the default heap for the system.
* Specify the size of this default heap.
*/
BIOS.heapSize = 0x1000;
/*
* Build a custom SYS/BIOS library from sources.
*/
BIOS.libType = BIOS.LibType_Custom;
/* System stack size (used by ISRs and Swis) */
Program.stack = 0x2000;
/* Circular buffer size for System_printf() */
SysMin.bufSize = 0x200;
/*
* Create and install logger for the whole system
*/
var loggerBufParams = new LoggerBuf.Params();
loggerBufParams.numEntries = 16;
var logger0 = LoggerBuf.create(loggerBufParams);
Defaults.common$.logger = logger0;
Main.common$.diags_INFO = Diags.ALWAYS_ON;
System.SupportProxy = SysMin;
While trying to build i am getting identifier "SOC_UART1_BASE" is undefined error. The soc.h is already included do i need to add anything specifically?
For Jacinto J6 EVM does SOC_UART1_BASE prints messages to EVM's debug UART Terminal