This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

GIO_read unexpected behavior....

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!!!!!!!!!!");

}

}

 

  • Hi Mike,

    Firstly, have you tried executing the default sample application that comes with the BIOSPSP in interrupt mode? If not, please try it.

    Mike Geppert said:
    if the Perl Script is not running, the GIO__read returns with a -1 after a few seconds.

    When does this error occur?. It occurs when you submit a packet or it throws an error from the interrupt context?.

    No doubt, the GIO_read has to wait forever until the requested number of bytes is not read(with timeout set as BIOS_WAIT_FOREVER) and no read line status errors occur. But in case if it is coming out with an error, try probing into the driver and check from where exactly it is returning -1. From the register dump, it does not seem to be like there are any read errors too!.

    By the way, what exactly is the perl script doing?. 

    I shall go through your configuration further and get back. Let me know the results.. 

    Best Regards,

    Raghavendra

  • I dont have the hardware that the PSP code was written for, so aside from the UART init function it is the PSP code and example.  Yes I started with Interrupt mode.

    It does work in TX mode great.  Just not in RX mode.

    As far as the error occures, it just sits at the consol for a second or two and then returns the -1 waiting for Characters to come in.  It does look like the ISR is NOT being executred which is what I would expect for the test case when the Perl script is not running.

    The perl script is just spinning on a loop that TX a bunch of characters then sleeps for 1 second and repeats.  I have changed the packet from everything from the 15 byte packet I need to 1 and it doesn't seem to effect the results.

    Since the last message I have played around with changing the BAUD rate on both the board and Perl Script.  I have gotten the 0x31 recieved value to change to 0x00 by making the BAUDS mismatch.  I have even gotten 3 0x00 per packet, expecting 5 chars.  Not very significant other then I can get the 0x31 to change.

     

    Thanks so much for the help,

  • UPDATE:

    Today I finally got a scope hooked up to the RS232 Driver and the TTL side is most definetly putting out  a 0x31 no matter what the input is.

    So it looks like the only real question left is why the GIO_read is returning a -1.  Once I solve why the Driver is doing what it is doing, I will see if I can find out why the read is returning a -1.

    Can you tell me what the mechanisim of the blocking is supposed to be?  It looks like it is something inside the GIO_read and not in the uartSubmit function?

    Thanks again!

  • UPDATE 2:

    Found out that the PERL Serial Port Class for writing a string seems to have a bug.  Interestingly the read works.  Chaned to "transmit_char" and now I get valid characters into the board. 

    Now i have to see what the software is doing...