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.

AM5708: PRU UART debug console

Part Number: AM5708


Hi,

We have AM5708 custom board and  need to use  PRU1 - UART0  for debugging and we ported the  firmware with reference to the project " ti-processor-sdk/example-applications/pru-icss-5.4.0/examples/am335x/PRU_Hardware_UART/",

and we are receiving junk in teraterm 

we are trying to send following line via Tx  "PrintMessageOut("Hello you are in the PRU UART demo test please enter 5 characters\r\n"); "  and received the Junk and Rx also getting Junk . can you Confirm the below DLL config is correct for AM5708 

CT_UART.DLL = 104;
CT_UART.DLH = 0;
CT_UART.MDR_bit.OSM_SEL = 0x0;

Attached our source file also ,

PRU_UART.zip

Don't know what went wrong.

What should I do now? 

  • Hello Vignesh,

    Are you able to get the firmware working properly by just porting to AM57xx? (without all the other additions you made, does the internal loopback test case work as expected?)

    Regards,

    Nick

  • Hi Nick ,

    Thanks for your reply , We are trying internal loop-back as suggested , meanwhile can you check the source code i have attached for PRU_Hardware_UART and confirm clock frequency we used for AM5708 as below ,

    /* Set up UART to function at 115200 baud - DLL divisor is 104 at 16x oversample

    109 * 192MHz / 104 / 16 = ~115200 */

    CT_UART.DLL = 104;

    CT_UART.DLH = 0;

    CT_UART.MDR_bit.OSM_SEL = 0x0;

    /*
     * Copyright (C) 2015 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.
     */
    
    
    #include <stdint.h>
    #include <pru_uart.h>
    #include "resource_table_empty.h"
    
    /* Commented out to prevent internal Loopback */
    //#define HWLOOPBACK
    
    /* If SWLOOPBACK is defined, this flag tells the main loop to copy rxBuf to txBuf */
    #ifdef SWLOOPBACK
    uint8_t lpbkFlag;
    #endif
    
    /* The FIFO size on the PRU UART is 16 bytes; however, we are (arbitrarily)
     * only going to send 8 at a time */
    #define FIFO_SIZE	16
    #define MAX_CHARS	8
    
    //******************************************************************************
    //    Print Message Out
    //      This function take in a string literal of any size and then fill the
    //      TX FIFO when it's empty and waits until there is info in the RX FIFO
    //      before returning.
    //******************************************************************************
    void PrintMessageOut(volatile char* Message)
    {
    	uint8_t cnt, index = 0;
    
    	while (1) {
    		cnt = 0;
    
    		/* Wait until the TX FIFO and the TX SR are completely empty */
    		while (!CT_UART.LSR_bit.TEMT);
    
    		while (Message[index] != NULL && cnt < MAX_CHARS) {
    			//CT_UART.THR = Message[index];
    			CT_UART.RBR_TBR_bit.TBR_DATA = Message[index];
    			index++;
    			cnt++;
    		}
    		if (Message[index] == NULL)
    			break;
    
    	}
    
    	/* Wait until the TX FIFO and the TX SR are completely empty */
    	while (!CT_UART.LSR_bit.TEMT);
    
    }
    
    
    //******************************************************************************
    //    IEP Timer Config
    //      This function waits until there is info in the RX FIFO and then returns
    //      the first character entered.
    //******************************************************************************
    char ReadMessageIn(void)
    {
    	while (!CT_UART.LSR_bit.DR);
    
    //	return CT_UART.RBR_bit.DATA;
    	return CT_UART.RBR_TBR_bit.RBR_DATA;
    }
    
    void main(void)
    {
    	uint32_t i;
    	volatile uint32_t not_done = 1;
    
    	char rxBuffer[6];
    	rxBuffer[5] = NULL; // null terminate the string
    
    	/*** INITIALIZATION ***/
    
    	/* Set up UART to function at 115200 baud - DLL divisor is 104 at 16x oversample
    	 * 192MHz / 104 / 16 = ~115200 */
    	CT_UART.DLL = 104;
    	CT_UART.DLH = 0;
    	CT_UART.MDR_bit.OSM_SEL = 0x0;
    
    	/* Enable Interrupts in UART module. This allows the main thread to poll for
    	 * Receive Data Available and Transmit Holding Register Empty */
    	CT_UART.IER = 0x7;
    
    	/* If FIFOs are to be used, select desired trigger level and enable
    	 * FIFOs by writing to FCR. FIFOEN bit in FCR must be set first before
    	 * other bits are configured */
    	/* Enable FIFOs for now at 1-byte, and flush them */
    	//CT_UART.FCR = (0x80) | (0x8) | (0x4) | (0x2) | (0x01); // 8-byte RX FIFO trigger
    
    //	CT_UART.IIR_FCR_bit = (0x80) | (0x8) | (0x4) | (0x2) | (0x01); // 8-byte RX FIFO trigger
    
    	CT_UART.IIR_FCR = (0x80) | (0x8) | (0x4) | (0x2) | (0x01); // 8-byte RX FIFO trigger
    
    //	CT_UART.IIR_FCR = (0x8000) | (0x800) | (0x400) | (0x200) | (0x0100); // 8-byte RX FIFO trigger
    
    	/* Choose desired protocol settings by writing to LCR */
    	/* 8-bit word, 1 stop bit, no parity, no break control and no divisor latch */
    	CT_UART.LCR = 3;
    
    	/* If flow control is desired write appropriate values to MCR. */
    	/* No flow control for now, but enable loopback for test */
    #ifdef HWLOOPBACK
    	CT_UART.MCR = 0x10;
    #elif SWLOOPBACK
    	CT_UART.MCR = 0x00;
    #endif
    
    	/* Choose desired response to emulation suspend events by configuring
    	 * FREE bit and enable UART by setting UTRST and URRST in PWREMU_MGMT */
    	/* Allow UART to run free, enable UART TX/RX */
    	CT_UART.PWREMU_MGMT_bit.FREE = 0x1;
    	CT_UART.PWREMU_MGMT_bit.URRST = 0x1;
    	CT_UART.PWREMU_MGMT_bit.UTRST = 0x1;
    
    	/* Turn off RTS and CTS functionality */
    	CT_UART.MCR_bit.AFE = 0x0;
    	CT_UART.MCR_bit.RTS = 0x0;
    
    	/*** END INITIALIZATION ***/
    
    	/* Print out greeting message */
    	PrintMessageOut("Hello you are in the PRU UART demo test please enter 5 characters\r\n");
    
    	/* Read in 5 characters from user, then echo them back out */
    	for (i = 0; i < 5 ; i++) {
    		rxBuffer[i] = ReadMessageIn();
    	}
    
    	PrintMessageOut("you typed:\r\n");
    
    	PrintMessageOut(rxBuffer);
    
    	PrintMessageOut("\r\n");
    
    	/*** DONE SENDING DATA ***/
    	/* Disable UART before halting */
    	CT_UART.PWREMU_MGMT = 0x0;
    
    	/* Halt PRU core */
    	__halt();
    }
    

    8171.pru_uart.h

    AM57xx_PRU_cmd.zip

    Thanks in advance.

  • Hi Nick,

    I am also working on this AM57x PRU_UART and not able to make it work either.

    I have seen multiple e2e posts on AM57x PRU_UART and issue was not resolved in any of the posts.

    Could you please look into this and see what could be the problem here ?

    I am suspecting the problem could be in PRU UART clock input & baudrate, is it make sense ?

    or PRU UART clock is not configurable through any PLL divider/multiplier values and fixed to 192MHz ?

    As per TI porting guide, AM335x & AM57x PRU_UART should be identical. So not sure what could be the change in AM57x ?

    No one is verified the PRU UART in AM57x series SOC ?

    And can you suggest to use correct "pru_uart.h" file for AM570x PRU UART ?

    Could you please help on this as we are blocked completely due to this issue, we planned to use this for debug port and unable to proceed further developments.

    It would be greatful if you could provide some pointers. Thanks. 

  • I am sorry for the delayed response. I am going to try to port the PRU_Hardware_UART example to AM57xx on my end to see if I can get it working.

    Regards,

    Nick

  • Update: Porting today. Will have more info soon.

  • Hi Nick,

    Porting am335x pru_uart.h file in which the

     /* PRU_UART_RBR_THR_REGISTERS register bit field */  and

    /* PRU_UART_INTERRUPT_IDENTIFICATION_REGISTER_FIFO_CONTROL_REGISTER register bit field */   were differing with am5708.

    That was the issue.

    So by making corresponding changes we can able to test PRU UART RX & TX functionality 

    Thanks,

    Vignesh

  • Hello Vignesh,

    Glad you got it working! Other things to make sure you do to align with the PRU-ICSS / PRU_ICSSG Migration Guide

    1) Update constant table references: Replace the linker command file AM335x_PRU.cmd with AM57xx_PRU.cmd from one of the other projects in examples/am572x/

    2) Updating PRU Peripheral Registers: In your Makefile, change the include line to INCLUDE=--include_path=../../../include --include_path=../../../include/am571x

    I don't think there are any differences between PRU-ICSS peripherals in AM571x and AM570x, but I will double check.

    After making those changes, I got errors from the compiler about RBR, THR, and FCR definitions. From there it should be easy to change your register names to match the register names in include/am571x/pru_uart.h

    Regards,

    Nick

  • Final follow-up: AM570x and AM571x use the same PRU-ICSS and share the same PRU registers, as per the AM571x and AM570x Technical Reference Manual. So you can use the am571x header file for am570x.

    Do note that there are differences in which PRU signals are pinned out on AM570x and AM571x - you can find more information on that in the PRU-ICSS Feature Comparison.

    Regards,

    Nick