cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Anonymous
Not applicable
10,737 Views

Problem in using Xuartlite functions

Jump to solution

Hi all,

 

I have  generated my own EDK project and used it. 

when I try to add some exdtra functions in the TastApp_Peripheral.c file -which is automatically generated - I don't see those bytes in my hyper terminal but other files are comming to the hyper terminal.

I think I don't know how to use those functions correctly. So, I would appreciate any help on this issue.

 below is my source code:

 

 

unsigned char arr[]={"message\n\r"}; unsigned char received; XUartLite UartLite; /* Instance of the UartLite device */ //#define C_BASEADDR 0x84000000 //from MHS file of project while(1){ print("This is a test.\n\r"); XUartLite_ResetFifos(&UartLite);/*just for test it didn't have any effect!....*/ XUartLite_Send(&UartLite,arr,9);//it didn't work it had not effect XUartLite_SendByte(C_BASEADDR,'C');//ok XUartLite_SendByte(C_BASEADDR,'D');//ok XUartLite_SendByte(C_BASEADDR,'\n');//ok XUartLite_SendByte(C_BASEADDR,'\r');//ok received = XUartLite_RecvByte(C_BASEADDR);//ok xil_printf("\n\rYou sent :%c\n\r",received);//ok }

 

As you can see in the comments, two functions have no effect I don't see why.

I also should tell that I used C_BASEADDR from mhs file and I could'nt find any where else which these parameters have been defined.

 

 thanks in advance.

 

 

 

0 Kudos
1 Solution

Accepted Solutions
xiaofeip_dup
Xilinx Employee
Xilinx Employee
10,690 Views
Registered: ‎08-07-2007

Hi Hossein,

 

Have you tried to debug your code?

 

"XUartLite_Send" actaully calls "XUartLite_SendByte" funciton to send out data. Please step into the funcion, and see if the correct base address is passed to "XUartLite_SendByte".

 

-Felix

View solution in original post

0 Kudos
16 Replies
Anonymous
Not applicable
10,728 Views

Hi,

 

If you want a simple way of writing to the terminal, you can just tell XPS that you want the stdin and stdout to point to the uart.  Do this in your software platform settings.  This way you can use printf, etc. to write to the terminal.

 

If you want to directly control the uart then you can just write to the transmit register.

 

 

//Assume TX_FIFO is at offset 0x04 //Send an X XIo_Out32(UART_BASE_ADDX + TX_FIFO, 'x');

 

Just remember not to write too much to the FIFO witout checking its empty status.

 

Cheers

Lachlan.

 

 

0 Kudos
Anonymous
Not applicable
10,723 Views

Hi Lachlan,

 

Thank you for your comment and post.

I think you misunderstood the issue. I can see messages in the hyperterminal but, I couldn't see

that message which I inserted into the code: "XUartLite_Send(&UartLite,arr,9);" I defined my array "arr"in the upper lines of the code as you can see it "unsigned char arr[]={"message\n\r"};"

 

and according to the definition of "XUartLite_send" function in the "XUartLite.h" we just need to pass a pointer of structure and a data buffer pointer and then number of bytes we want to send to this function in order to start sending those bytes but I didn't see my arr string in the hyperterminal while I see all other strings which are in the code.

besides I didn't see any effect by inserting "XUartLite_ResetFifos(&UartLite);" into my code!....

 

I appreciate any help.

 

Best Regards,

Hossein Moradi Sarvandi


0 Kudos
xiaofeip_dup
Xilinx Employee
Xilinx Employee
10,719 Views
Registered: ‎08-07-2007

Hi Hossein,

 

Did you initialize the uartlite instance "UartLite" before using it in your "XUartLite_Send" function?

 

Check out the example code from the uartlite driver.

 

-Felix

0 Kudos
Anonymous
Not applicable
10,685 Views

Hi,

 

Thank you for your answer.

This is one of my problems that I don't know  how to initialize that. for example, if you take a look at the code you can see that I predefined  "C_BASEADDR" for one of my function.

I couldn't find any help regarding on how to set those parameters for my functions so I decided to refer to teh MHS file and use those physical addresses. but, I want to know if there is any complete reference manual for these driver functions and their arguments.

Before  using a function I should be aware of its aguments and teh way I should initialize them in my application I would appreciate you if you can help me.

 

Best Ragards,

 

Hossein.

0 Kudos
xiaofeip_dup
Xilinx Employee
Xilinx Employee
10,661 Views
Registered: ‎08-07-2007

Hi Hossein,

 

All of the doc and source code for the BSP, libraries and drivers can be found in the EDK \sw directory.

 

-Felix 

0 Kudos
ballhog
Visitor
Visitor
10,627 Views
Registered: ‎02-08-2010

Check the MHS file.  Compare the RS232 to the uart you created.   I had a similar problem, hyper terminal was receiving data, just not the right data.  Took some time for me to realize the MHS file was missing a few things. 

 

BEGIN xps_uartlite
 PARAMETER INSTANCE = xps_uartlite_0
 PARAMETER HW_VER = 1.00.a
 PARAMETER C_BASEADDR = 0x84020000
 PARAMETER C_HIGHADDR = 0x8402ffff
 PARAMETER C_BAUDRATE = 9600
 PARAMETER C_DATA_BITS = 8
 PARAMETER C_USE_PARITY = 0
 PARAMETER C_ODD_PARITY = 0
 PARAMETER C_SPLB_CLK_FREQ_HZ = 50000000
 BUS_INTERFACE SPLB = mb_plb
 PORT Interrupt = xps_uartlite_0_Interrupt
 PORT TX = xps_uartlite_0_TX
 PORT RX = xps_uartlite_0_RX
END

 

BEGIN

xps_uartlite PARAMETER INSTANCE = xps_uartlite_0 

PARAMETER HW_VER = 1.00.a 

PARAMETER C_BASEADDR = 0x84020000 

PARAMETER C_HIGHADDR = 0x8402ffff 

PARAMETER C_BAUDRATE = 9600    <<<---- Mine was missing

PARAMETER C_DATA_BITS = 8     <<<---- Mine was missing

PARAMETER C_USE_PARITY = 0 

PARAMETER C_ODD_PARITY = 0 

PARAMETER C_SPLB_CLK_FREQ_HZ = 50000000      <<<---- Mine was missing

BUS_INTERFACE SPLB = mb_plb 

PORT Interrupt = xps_uartlite_0_Interrupt 

PORT TX = xps_uartlite_0_TX 

PORT RX = xps_uartlite_0_RXEND

0 Kudos
Anonymous
Not applicable
10,583 Views

Hi,

 

I read the return value of the "XUartLite_Send" function and printed it and saw that it can send the strings and returns the number of sent bytes I determined different lengths  for this function and I saw it can send actually the number of bytes which I determined but I can't see the string in the terminal !......

I can see other print messages but I can't see its bytes I think there there should be something wrong with the output stage!...

 

I checked my MHS file too and I think it is OK.

 

thanks,

Hossein

0 Kudos
Anonymous
Not applicable
10,581 Views

Hi,

 

I checked my MHS file and all teh thing swere OK for RS232.

I think you misunderstood the problem I try to explain it for you:

 

there are some print messages which I can see them through my terminal and also I I could send some other characters using "XUartLite_SendByte" in my code but I couldn't see teh string which I sent it with "XUartLite_Send" which it is a function of higher level compared to the "XUartLite_SendByte".

 

today, I tried to read the return value of function and I saw it is sending data but I can't see it.

0 Kudos
xiaofeip_dup
Xilinx Employee
Xilinx Employee
10,576 Views
Registered: ‎08-07-2007

Have you reviewed the documentation that I pointed you to?

 

Like I said, you need to initialize the instance before using it.

 

-Felix

0 Kudos
Anonymous
Not applicable
7,791 Views

Hi Felix,

Thank you for your comment and consideration,

If I understand you correctly you mean to initialize the UART instance module first, and I should tell that from the automatic source generated in EDK I see that it has used "UartLiteSelfTestExample(XPAR_MDM_0_DEVICE_ID);" and also I am receiving print messages in the Hyperterminal :

"

{
      XStatus status;
      
      print("\r\nRunning UartLiteSelfTestExample() for mdm_0...\r\n");
      status = UartLiteSelfTestExample(XPAR_MDM_0_DEVICE_ID);
      if (status == 0) {
         print("UartLiteSelfTestExample PASSED\r\n");
      }
      else {
         print("UartLiteSelfTestExample FAILED\r\n");
      }
   }

"

I see these messages in hyperterminal which are comming out of the board.

Besides, I defined a "XUartLite" structure and used both "XUartLite_Initialize" and "XUartLite_CfgInitialize" functions with appropriate arguments and I checked their return value and in both cases I saw that it is initilized successfully "XST_SUCCESS" I told you before that, when I check the returned value of "XUartLite_Send" function I see that it could send that number of bytes I wanted to and I don't understand why I can't see those messages.

I should also add that if I try to send bytes with "XUartLite_SendByte" function -which is a lowe-level driver function-I can see messages in hyperterminal.

 

now, what are differences between these two functions.

 

thanks,

 

Hossein.

 

 

0 Kudos
pumaju1808
Scholar
Scholar
7,759 Views
Registered: ‎08-14-2007

hi,

 

the differences you said it. "XUartLite_Send" is a high level function and "XUartLite_SendByte" is a low-level function, so in order to use XUartLite_Send function you have to use XUartLite structure and configure and initialize it. And in order to use XUartLite_SendByte you do not need anything just call the function with tha appropiate CBASE_ADDRESS. The disadvantage with XUartLite_SendByte is that you only can send one byte at time so if you want to sent 16 bytes you need to "call" this function 16 times!!

And with function XUartLite_Send you only have to fill a buffer and call this function once

 

For me these are the principal differences, it will be interesting other people opinion

 

Regards

0 Kudos
Anonymous
Not applicable
7,748 Views

Hi,

Thank you for your comment.

it seems that you didn't read my previous comments. I know differences between those two functions and I should inform you that I can see "print" messages in my hyper terminal I just can't see those bytes which I try to send with "XUartLite_Send" function, even I check its returned value and see it could send the number of bytes which I asked it.

I should add that I am sure that it is initialized because I can see what ever I send with "print" function.

Besides, I defiend a "XUartLite" structure and used two functions for initializing it, those functions are: "XUartLie_Initialize" and "XUartLite_CfgInitialize" which I checked their returned value and confirmed that it was OK.

So, I don't know why I can see "print" or "XUartLite_SendByte" messages but I am not able to see "XUartLite_Send" messages.

 

thanks,

Hossein

 

 

 

0 Kudos
xiaofeip_dup
Xilinx Employee
Xilinx Employee
10,691 Views
Registered: ‎08-07-2007

Hi Hossein,

 

Have you tried to debug your code?

 

"XUartLite_Send" actaully calls "XUartLite_SendByte" funciton to send out data. Please step into the funcion, and see if the correct base address is passed to "XUartLite_SendByte".

 

-Felix

View solution in original post

0 Kudos
Anonymous
Not applicable
7,710 Views

Hi felix,

 

I found the problem.

It was a wrong setting when I was calling "XUartLite_Initialize" function.

I gave its device_id incrorrectly "XPAR_MDM_0_DEVICE_ID" I just copied this device_ID from automatic source code generated in the EDK.

When I checked the UartLite structure I saw the base address field is set incorrectly then I doubted if the function works Correctly or not and when I checked the device_ID of RS232 in xparameters.h I found out that I entered it incorrectly and Changed it then it worked.

Thank you for your helps and comments.

 

Best Regards,

 

Hossein Moradi.

0 Kudos
fj773
Newbie
Newbie
4,144 Views
Registered: ‎09-22-2013

HI Hossein Moradi.

If the problem is the incorrect device ID, why you can use XUartLite_SendByte function ??? and you have said that 

XUartLite_SendByte(C_BASEADDR,'C');//ok XUartLite_SendByte(C_BASEADDR,'D');//ok XUartLite_SendByte(C_BASEADDR,'\n');//ok XUartLite_SendByte(C_BASEADDR,'\r');//ok

are work well????

 

how to explain it ????

 

and  how to use XUartLite_Send() function similar to printf() function ????

 

just make a function :  sendfunction("message"), then it will transfer the message via uart to the terminal?? and the "message" can be any string(random message ) such as "long message 100 words"  "10 words" "3.1415"???

 

how to make the sendfunction()  function ????

 

can you help me ???

 

 

thanks a lot ???

 

 

0 Kudos
embedded
Advisor
Advisor
4,109 Views
Registered: ‎06-09-2011

Hi @fj773

I think you have not read all the posts. So, I try to put it in a nutshell. I had some problems in sending a string through UART module. All simple send byte operations -XUartLite_SendByte()- were successful while that one -XUartLite_Send()- was not sending anything. The problem was that I hadn't initialized the instance -UartLite- before using that!..

 

Hope this would help.

Hossein

Thanks,
Hossein
0 Kudos