News:

Attention: For security reasons,please choose a user name *different* from your login name.
Also make sure to choose a secure password and change it regularly.

Main Menu

TE0320 board USB communication sample

Started by umitcelik, June 16, 2011, 03:48:56 PM

Previous topic - Next topic

umitcelik

Hello,

I bought TE0320 board for data capture and send them to PC via USB interface. I tested the board TE0320_API_Example\Release program and I et the same results as in TE0320 User manual. I would like to ask when we use TE0320_API_Example\Release program which FPGA source code is executed?

There is a reference design code named "reference-TE0320-00-EDK-12-2". When  open it in XPS there are 2 projects one of them is bootloader and the other one is demo. Is bootleoder code stores the fpga firmare in SPI flash to FPGA? When I load this code to FPGA and run TE0320_API_Example\Release everthing works as in user maneul. When I store demo code to fpga, nothing happens..

Could you help me How can I simply make bulk trasnfer to pc from microblaze and get data from PC? I could not  udnerstand reference design code and there is no any explanation.

best regards,

-umit

Ales Gorkic

Dear Umit,

The bootloader project only reads the header and program from the FLASH and executes the program when copied to DDR and verified. The design works OK when the data is stored in the FLASH.
However when you want to execute the program directly from the DDR memory (development of a new program) you need to download the bistream first with Bootlop and then press xmd button. The xmd will connect to cpu and download the program according to xmd.ini script (project root) and execute it.
If the program does not exceed processor BRAM (32kB in demo project) then you can mark the program to be stored in the bitstream (mark for BRAM). But before doing this the program MUST be properly compiled. The linker script tells the compiler from where the program is to be executed. To execute the program from the BRAM simply remove the linker script from the demo project settings (double click on the project) and check if the program start address is set to 0x0000000 instead of DDR start address.

Hope this helps

Ales

umitcelik

Hello,

thank you very much for your reply. I am try to understand the reference design for TE0320 but I could not understand how we can transfer data between PC and TE0320 . Also I could not understand how we can write and read data from DDR Ram. Is there any simple example whic I can easly understand.
regards,

-umit

Thorsten Trenz

Dear Umit,
there is no easier example than the reference design, because the task is not easy  ;)
Please be so kind to review it in detail, and then ask specific questions.

best regards
Thorsten Trenz


umitcelik

Dear Thorsten,

thank you very much for your quick reply :)  Let me ask the first question :
I am using TE0320 API to test the board. When  transfer  the data to FPGA, which part of the code in microblaze captures the data and stores it to DDR ram. When I find this, I hope I will solve all of them :) I could not find a code block which makes it...


regards,

-umit

Thorsten Trenz

Dear Umit,

Quote from: umitcelik on June 21, 2011, 12:19:08 PM
I am using TE0320 API to test the board. When  transfer  the data to FPGA, which part of the code in microblaze captures the data and stores it to DDR ram. When I find this, I hope I will solve all of them :) I could not find a code block which makes it...
This is done with DMA in Hardware. Microblaze would not be able to handle the datarate.
Please take a look at this document:
http://docs.trenz-electronic.de/Trenz_Electronic/TE03xx/AN-TE03xx.pdf
On the first page is a diagramm, which shows the reference design architecture.

best regards
Thorsten Trenz


umitcelik

Dear Thorsten,

Thak you very much for your all quick responses. I am working too much but there is no clear document to understand what you are doing. I read alldatasheet documents but they are not too clear for a new bee.  I have a project and I have no too much time. Could you please tell me how can I send a 1KB data PC to microblaze or microblaze to PC? How can I simply read or write DDR RAM in microblaze. I dont need DMA transfer. I need to read some data from ADC and store them to DDR RAM(for example 1KB data). When I capture 1 KB data in microblaze I would like to send them to PC.  I would like to make of the control in microblaze. I can use DMA transfer in future time. Now I need to make simple things.. Please help me. We are trying to develope a scanning probe microscope controller., If we achieve, we will buy to much TE0320 boards..

regards..

-umit

Ales Gorkic

Dear Umit,

If this is the case there is a simpler way to do transfer data word by word (4bytes at the time) with a microblaze. This is a direct FIFO interface through registers. You can achieve up to 4MB/s data rate.
Take a look at the end of the file for USB communication functions in:
TE03xx-development-suite\MyProcessorIPLib\drivers\xps_fx2_v1_00_a\src\xps_fx2.h

First set the Endpoint number through which you will transfer data:
XPS_FX2_SetUSB_FIFOadr(Xuint32 BaseAddress, enum PI_PipeNumber PipeNo);

BaseAddress is the base adddres of the xps_fx2 peripheral (use the define from the xparameters.h)
and
enum PI_PipeNumber
{
   PI_EP2   = 0,   
   PI_EP4   = 1,   
   PI_EP6   = 2,
   PI_EP8   = 3
};

Then set the timeout which commences the packets shorter than 512B:
XPS_FX2_PktendTimeout(Xuint32 BaseAddress, Xuint16 Timeout);
Timeout is counted in 20ns ticks.

for (i=0; i<256; i++) {
To read the data from the DDR use this:
Xuint32 XIo_In32(Xuint32 Address);
where the Address is the location in the memory (DDR base address+something). Use 32bit aligned addresses!

To transfer one word to host PC then call this function:
XPS_FX2_WriteTXFifo(Xuint32 BaseAddress, Xuint32 Data);
}

Use the TE0320_API_Example to receive data on the PC side. To dump the data to display the data on the display change  the line 217 to:
bool printout=true;


To receive the data from the PC send the data with the TE0320_API_Example.

On the microblaze check the FIFO occupancy with
Xuint16 XPS_FX2_GetRXFIFOcount(Xuint32 BaseAddress);

Then read only the words given by the Count with:
for (i=0; i<count; i++) {
Xuint32 XPS_FX2_ReadRXFifo(Xuint32 BaseAddress);

and store to DDR:
XIo_Out32(Xuint32 Address, Xuint32 data);

This is more or less it.
I hope you will manage it from this point.

Best regards,

Ales


umitcelik

Dear Ales,

Thank you very much for your detailed documents. I could achieve sen data from microblaze to PC 512Byte by filliing EP 6. Then I try to send data from PC to microblaze and store them to DDRAM after that I try to read all of them again from PC. Bu tI could not achieve it. COuld you tell me what am I doing wrong. 

with best regards.

Interrupt in microblaze  which reads data from DDR and write them into FIFO for reading them in PC.
case READFROMPC :
      {
         XPS_FX2_SetUSB_FIFOadr(XPAR_XPS_FX2_0_BASEADDR, PI_EP6);
         ddroffset = 0;
          for (i=0; i<16; i++)
          {
            data=XIo_In32(Start_addr + ddroffset);
            ddroffset = +4;
            XPS_FX2_WriteTXFifo(XPAR_XPS_FX2_0_BASEADDR, data);
          }    
   
         break;
      }
      
Interrupt in microblaze  which reads data from FIFO and write them into DDRRAM.
      case WRITETOUB :
      {         
         //XPS_FX2_SetUSB_FIFOadr(XPAR_XPS_FX2_0_BASEADDR, PI_EP8);  // Do I need to again set FIFO adres with EP8?
         ddroffset = 0;
         count = XPS_FX2_GetRXFIFOcount(XPAR_XPS_FX2_0_BASEADDR);
         
         for (i=0; i<count; i++)
         {
            data = XPS_FX2_ReadRXFifo(XPAR_XPS_FX2_0_BASEADDR);
            XIo_Out32(Start_addr+ddroffset,data);
            ddroffset = +4;
         }
                  
         break;
      }


PC Side data write to microblaze

void WriteDataUmit(unsigned int handle)
{
   int packetlen = RX_PACKET_LEN;
   unsigned int packets = 1200;
   byte * data;
   unsigned int total_cnt = 0;
   unsigned int errors = 0;
   double TheElapsedTime;

   data = new byte [RX_PACKET_LEN*packets]; //allocate memory

   for (unsigned int j = 0; j < 16; j++)
   {
      data[j] = j;
   
   }

   ResetFX2FifoStatus(handle);

   SendFPGAcommand(handle,WRITETOUB); //starts test

   ElapsedTime.Start(); //StopWatch start
   total_cnt = 0;

   //for (unsigned int i = 0; i < packets; i++)
   {
      packetlen = RX_PACKET_LEN;
      if (TE0300_SetData(handle, data, sizeof(data), PI_EP8))
      {
         cout << "ERROR" << endl;
      }
      total_cnt += packetlen;
   }

   TheElapsedTime = ElapsedTime.Stop(false); //DEBUG StopWatch timer
   //SendFPGAcommand(handle,FX22MB_REG0_STOP); //stops test

   delete data;
}

Ales Gorkic

Hi Umit,

Seems like you send one packet from the PC. Packet size should not exceed RX_FIFO size.
What is the problem? Please attach DDR memory dump if you recived anything to FX2.
Check also the FX2 status.
EP8 is always used to receive data.

Best regards,


Ales

umitcelik

Dear Ales,

As I see in the FX2LP the EP8 Buffer size 512 Byte. I am just trying to send 16 * 4 = 64 Byte data. So it must not be a problem, isnt it? I try to send data in EP8 in the PC. Do I need to set fifo number to read them in EP8.( XPS_FX2_SetUSB_FIFOadr(XPAR_XPS_FX2_0_BASEADDR, PI_EP8) is it needed
?) I am still too new to understand what you are saying. How  can I  attach DDR memory dump if you recived anything to FX2 and check also the FX2 status. Could you give me a bit more detail?

Is it true to use DDRAM read and writing as:

for (i=0; i<count; i++)
         {
             data = 123456789; //(integer value)
            XIo_Out32(Start_addr+ddroffset,data);
            ddroffset = +4;  // Does the memoy adress must chang whith 4 by 4 or juest one by one?

gedards...

-umit\

         }

Ales Gorkic

Dear Umit,

It is wise to send 512bytes for a start, but smaller packets should not be a problem.
You do not need to set the EP addres to EP8.
The code for writing the data to DDR is OK. When using 32 bit (word) transfer address must increment by 4.
Did Get_RX_FIFO_Count return any value?
Memory dump is printf of data read from the memory.
You can check the FX2 status using the API demo on the PC.

Regards

Ales

umitcelik

Dear Ales,

Thank you very much for your kind interest. I still have DDR ram read and write problem. There is an interesting problem.

When I try to write and read DDR ram as following, I can get what I write:

for (i=0; i<16; i++)
          {
            XIo_Out32(Start_addr+ddroffset,i);
            data=XIo_In32(Start_addr + ddroffset);            
            ddroffset = +4;
            XPS_FX2_WriteTXFifo(XPAR_XPS_FX2_0_BASEADDR, data);
          }    

But when I try as following I could not get the DATAS from RAM what I write.


         for (i=0; i<16; i++)   
         {
            data = i+16;
            XIo_Out32(Start_addr+ddroffset,data);
            ddroffset = +4;
         }


         ddroffset = 0;   
                        
          for (i=0; i<16; i++)
          {            
                 data=XIo_In32(Start_addr + ddroffset);
                 ddroffset = +4;
            XPS_FX2_WriteTXFifo(XPAR_XPS_FX2_0_BASEADDR, data);
          }    

Do you have any idea?

Please help me to solve those problems. When I achieve to read and write DDR RAM and USB communication, I wont disturb you again :)
As you know it is too difficult to understand and develope someone else code..
Best ragards,

-umit

Ales Gorkic

#13
Dear Umit,

I would check the Start_addr if it points to DDR or not.

Do you have UART (RS232) cable connected to the board? If not use the XMD UART as STDIO (read the TE0300 or TE0320 documentation how to achieve this).
Then put in the code memory dump to verify the DDR contents first:
xil_printf("%08X", data);
This will print the data to the UART terminal (hyper terminal or realterm for example).

Then verify the data when they are written to TX_FIFO using this memory dump.

If there is no way to that you manage the UART then you can still use the GDB debugger, but to my experience this works pretty lowsy.

Ales

Hengist

The release of the third generation Trenz Electronic USB FX2 Suite made this post obsolete. Please access current documentation and resources here: TE USB FX2 Suite.