Tool/software: Code Composer Studio
Hello, everyone.
I am trying to communicate UART on ccs 8.3.1 with pdk 1.0.9 version, using the omap-l138 board.
- UART_BasicExample_lcdkOMAPL138_c674xExampleProject
- UART_BasicExample_lcdkOMAPL138_c674xTestProject
- UART_BasicExample_lcdkOMAPL138_c674xDMATestProject
Among these, I tested the Uart Polling method using No.1 and now I'm trying the Interrupt method using No.2.
For interrupt method, I added the source code by referring to ~pdk/packages/ti/csl/example/uart/intr/main.c in Example code 2 (UART_BasicExample_lcdkOMAPL138_c674xTestProject)
The codes added or modified are as follows:
void uartIsr()
{
static uint32_t txStrLength = sizeof(txArray);
static uint32_t count = 0;
uint32_t intId = 0;
rxByte = 0;
intId = UART_intIdentityGet_v0(CSL_UART_2_REGS);
switch(intId)
{
case UART_INTID_TX_THRES_REACH:
if( 0 != txStrLength)
{
UART_charPut_v0(CSL_UART_2_REGS, txArray[count]);
txStrLength--;
count++;
}
else
{
UART_intDisable_v0(CSL_UART_2_REGS, UART_INT_THR );
}
break;
case UART_INTID_RX_THRES_REACH:
buffer[++bufferIdx] = UART_charGetNonBlocking_v0(CSL_UART_2_REGS);
UART_charPut_v0(CSL_UART_2_REGS, buffer[bufferIdx]);
break;
case UART_INTID_RX_LINE_STAT_ERROR:
case UART_INTID_CHAR_TIMEOUT:
UART_charGetNonBlocking_v0(CSL_UART_2_REGS);
break;
default:
break;
}
}
void uart_test(UArg arg0, UArg arg1)
{
UART_Handle uart = NULL;
UART_Params uartParams;
int length = 0;
uintptr_t addrDataPrint, addrScanPrompt, addrEchoPrompt;
UART_Transaction transaction;
bool ret = false;
UART_HwAttrs uart_cfg;
printf("Starting Uart test \n");
UART_init();
UART_socGetInitCfg(uartTestInstance, &uart_cfg);
UART_osalSemParamsInit(&semParams);
semParams.mode = SemaphoreP_Mode_BINARY;
callbackSem = UART_osalCreateBlockingLock(0, &semParams);
/* UART SoC init configuration */
UART_initConfig(false);
UART_Params_init(&uartParams);
uartParams.baudRate =115200;
uart_cfg.edmaHandle = NULL;
uart_cfg.dmaMode = FALSE;
uart_cfg.enableInterrupt=1; /* Enabling interrupt forcefully */
/* Get the default UART init configurations */
UART_socSetInitCfg(uartTestInstance, &uart_cfg);
uart = UART_open(uartTestInstance, &uartParams);
if(uart == NULL)
{
if(uart)
{
UART_close(uart);
}
}
Intc_Init();
IntEventCombineInit(ECM0_UNUSED, ECM1_UNUSED, C674X_MASK_INT4, ECM3_UNUSED);
IntEventCombineRegister(69, (c674xISR)uartIsr);
IntEventCombineAdd(69);
Intc_SystemEnable();
UART_intEnable_v0(CSL_UART_2_REGS,(UART_INT_LINE_STAT | UART_INT_THR |
UART_INT_RHR_CTI) );
while(1)
{
}
}
I added the following code after seeing ~pdk/packages/ti/csl/example/uart/intr/main.c.
Intc_Init();
IntEventCombineInit(ECM0_UNUSED, ECM1_UNUSED, C674X_MASK_INT4, ECM3_UNUSED);
IntEventCombineRegister(69, (c674xISR)uartIsr);
IntEventCombineAdd(69);
Intc_SystemEnable();
UART_intEnable_v0(CSL_UART_2_REGS,(UART_INT_LINE_STAT | UART_INT_THR |
UART_INT_RHR_CTI) );
+ uartIsr code
I could check the UART Interrupt.
char txArray[] = "PDK UART Interrupt application\n\r";
case UART_INTID_RX_THRES_REACH:
buffer[++bufferIdx] = UART_charGetNonBlocking_v0(CSL_UART_2_REGS);
UART_charPut_v0(CSL_UART_2_REGS, buffer[bufferIdx]);
break;
Only the first one transmission interrupt occurs, and not thereafter.
It only prints one byte of received immediately through the interrupt.
What should I do to send it through tx interrupt?
Or
I would like you to tell me how to generate tx interrupts.
Sunny