Other Parts Discussed in Thread: OMAPL138
I have taken the PSP 3.0.1.00 and am tring to get the UART code to run on a OMAPL138 experimenter board.
It seems to TX great to a perl script running on a PC, so I have a high confidence that I have the Pins setup correctly and BAUD and handshaking etc.
When I try to do a GIO_read I get some unexpected behavior.
1) if the Perl Script is not running, the GIO__read returns with a -1 after a few seconds. I was hoping it would be blocking and not return at all until it recieved a character.
2) if the Perl Script is running before I run the code (I do a few characters at a time then a 1 second delay when I do TX characters), I only RX 0x31 (not what I expect) and only 1 character for the entire packet, then I get another character after the 1 second delay.
I started in Interrupt mode and then went to polled mode and get the same results. I have tried 2 different cards with the same results. I have shut off the cache and FIFO stuff. Set everything to 1. I am running out of ideas on how to debug furthere.
Here is the run with out the PERL script running:
*******************************************************************************************************
[C674X_0] Uart is configured in polled mode
[C674X_0] Uart Sample Main
[C674X_0]
[C674X_0] EDMA driver initialization PASS.
[C674X_0]
[C674X_0] GIO_read failed. returned : -1
*******************************************************************************************************
Here is the run with the PERL script running (after every 16 characters I print a new line and then dumped the stats):
[C674X_0] Uart is configured in polled mode
[C674X_0] Uart Sample Main
[C674X_0]
[C674X_0] EDMA driver initialization PASS.
[C674X_0] 0x31 0x31 0x31 0x31 0x31 0x31 0x31 0x31 0x31 0x31 0x31 0x31 0x31 0x31 0x31 0x31
[C674X_0] rxBytes = 16
[C674X_0] txBytes = 0
[C674X_0] overrun = 0
[C674X_0] rxTimeout = 0
[C674X_0] rxFramingError = 0
[C674X_0] rxBreakError = 0
[C674X_0] rxParityError = 0
*******************************************************************************************************
Code snipets:
Void uartSampleTask(UArg arg1, UArg arg2)
{
Uart_ChanParams chanParams;
Error_Block eb;
GIO_Params ioParams;
int count = 0;
size_t len = 0;
Int status = IOM_COMPLETED;
#ifndef MIKIE
#else
char *string = NULL;
#endif
Error_init(&eb);
/*
* Initialize channel attributes.
*/
GIO_Params_init(&ioParams);
/* initialise the edma library and get the EDMA handle */
uartEdmaInit();
/* update the edma Handle */
chanParams.hEdma = hEdma;
ioParams.chanParams = (Ptr)&chanParams;
ioParams.model = GIO_Model_STANDARD;
ioParams.numPackets = 1;
ioParams.sync = NULL;
ioParams.timeout = BIOS_WAIT_FOREVER;
/* create the required streams for the UART demo */
#ifndef MIKIE
uartRxHandle = GIO_create("/uart2",GIO_INPUT, &ioParams, &eb);
#else
uartTxHandle = GIO_create("/uart2", GIO_OUTPUT, &ioParams, &eb);
#endif
if ((NULL == uartRxHandle) /* || (NULL == uartTxHandle) */ ){
System_printf("\nStream creation failed\n");
} else {
#ifndef MIKIE
GIO_flush(uartRxHandle);
memset(uartBuffer,0x00,sizeof(uartBuffer));
#else
GIO_flush(uartTxHandle);
string = "UART Demo Starts: INPUT a file of size 1000 bytes";
/* Copy to start string to Cache aligned buffer */
strcpy(uartBuffer,string);
#endif
/* Run the UART sample application */
// startUartSample();
do {
#ifndef MIKIE
len = 1;
status = GIO_read(uartRxHandle,&uartBuffer[0],&len);
if (IOM_COMPLETED != status) {
System_printf("\r\nGIO_read failed. returned : %d", status);
Task_sleep(1000);
System_exit(0);
} else {
count++;
System_printf("0x%02x ",uartBuffer[0]);
if ((count % 16) == 0) {
System_printf("\n");
uartPrintStats(uartRxHandle);
}
}
#else
len = strlen(uartTestStringStart);
status = GIO_write(uartTxHandle,&uartBuffer,&len);
if (IOM_COMPLETED != status) {
System_printf("\r\nGIO_write failed. returned : %d", status);
} else {
count++;
System_printf("0x%02x %s\n",count,uartBuffer);
}
Task_sleep(1000);
#endif
} while (count < 1000);
}
}
void user_uart_init()
{
Uart_init();
uartParams = Uart_PARAMS;
uartParams.baudRate = Uart_BaudRate_9_6K;
uartParams.hwiNumber = 9;
uartParams.rxThreshold = Uart_RxTrigLvl_1;
uartParams.softTxFifoThreshold = 1;
uartParams.fifoEnable = FALSE;
uartParams.enableCache = FALSE;
uartParams.opMode = Uart_OpMode_POLLED;
if(Uart_OpMode_POLLED == uartParams.opMode) {
System_printf(
"\r\nUart is configured in polled mode");
}
else if (Uart_OpMode_INTERRUPT == uartParams.opMode) {
System_printf(
"\r\nUart is configured in interrupt mode");
}
else if (Uart_OpMode_DMAINTERRUPT == uartParams.opMode) {
System_printf(
"\r\nUart is configured in dma mode");
}
else {
System_printf(
"\r\nError: Unknown mode of operation!!!!!!!!!!");
}
}