cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
chriscorp
Visitor
Visitor
8,362 Views
Registered: ‎08-24-2010

UART RECEIVE DATA AND SAVE INTO DDR

Jump to solution

Hi,

 

Newbie to microblaze, I am currently doing a project that needs to receive data from uartlie and save into DDR ram to processed later can anyone give me an example c code of doing that? I am using spartan board, the memory controller used is MPMC and uartlite is my stdio.

 

I have tried searching for it but most of them just teach how to process the data but not how to receive and save data into DDR, any simple example will do just wanna get started only.

 

Thanks in advance.

0 Kudos
1 Solution

Accepted Solutions
saranshmeh
Adventurer
Adventurer
10,894 Views
Registered: ‎04-09-2010

// Here is code for writing only. parallel will be for reading.

// Initially what you can do is, you can pass a command byte sequence from UART, before passing data. Command sequence should include - reading or writing, and how much filesize to read ot write.

// here i am assuming to write to DDR2 only.

 

/ /ptr is base address of MPMC

// this is for writing to DDR2, where i am assuming the data width to be 32, and since uart works in 1 byte, so we will have //to concatenate while writing to it.

// real_file_size; is the file size you want to write to DDR2. If you want to write whole DDR2, then you need not pass it.

 

ptr=0x88000000;
            //xil_printf("\n\rWriting in Progress");
            for(i=1;i<=real_file_size;i++)
            {
                j=(i-1)%4;
                data[j]=XUartLite_RecvByte(0x84000000);
                if (j==3)
                {
                    data32=(data[0] | (data[1]<<8) | (data[2]<<16) | (data[3]<<24));
                    XIo_Out32(ptr,data32);
                    ptr=ptr+4;
                }
                else if (i == real_file_size)
                {
                    for (;j<=2;j++)
                    {
                        data[j+1] = 0;
                    }
                    data32=(data[0] | (data[1]<<8) | (data[2]<<16) | (data[3]<<24));
                    XIo_Out32(ptr,data32);
                    ptr=ptr+4;
                    xil_printf("\n\rWriting in Progress %d",i);
                }
            }
            
            xil_printf("\n\rWriting Completed %d   %d ", i, real_file_size);

 

I think, this will provide you with sufficient idea as to how to proceed. Further you can proceed as to your application. Do let me know if this helps.

 

Regards

Saransh

View solution in original post

6 Replies
saranshmeh
Adventurer
Adventurer
10,895 Views
Registered: ‎04-09-2010

// Here is code for writing only. parallel will be for reading.

// Initially what you can do is, you can pass a command byte sequence from UART, before passing data. Command sequence should include - reading or writing, and how much filesize to read ot write.

// here i am assuming to write to DDR2 only.

 

/ /ptr is base address of MPMC

// this is for writing to DDR2, where i am assuming the data width to be 32, and since uart works in 1 byte, so we will have //to concatenate while writing to it.

// real_file_size; is the file size you want to write to DDR2. If you want to write whole DDR2, then you need not pass it.

 

ptr=0x88000000;
            //xil_printf("\n\rWriting in Progress");
            for(i=1;i<=real_file_size;i++)
            {
                j=(i-1)%4;
                data[j]=XUartLite_RecvByte(0x84000000);
                if (j==3)
                {
                    data32=(data[0] | (data[1]<<8) | (data[2]<<16) | (data[3]<<24));
                    XIo_Out32(ptr,data32);
                    ptr=ptr+4;
                }
                else if (i == real_file_size)
                {
                    for (;j<=2;j++)
                    {
                        data[j+1] = 0;
                    }
                    data32=(data[0] | (data[1]<<8) | (data[2]<<16) | (data[3]<<24));
                    XIo_Out32(ptr,data32);
                    ptr=ptr+4;
                    xil_printf("\n\rWriting in Progress %d",i);
                }
            }
            
            xil_printf("\n\rWriting Completed %d   %d ", i, real_file_size);

 

I think, this will provide you with sufficient idea as to how to proceed. Further you can proceed as to your application. Do let me know if this helps.

 

Regards

Saransh

View solution in original post

v00d00
Visitor
Visitor
8,342 Views
Registered: ‎07-21-2010

you can find examples in $xilinxinstalldirectory/version/EDK\sw\XilinxProcessorIPLib\drivers

here open folder of any ip  and find example c codes

hope this helps you

0 Kudos
chriscorp
Visitor
Visitor
8,317 Views
Registered: ‎08-24-2010

Thanks for your reply saranshmeh,

 

You code really helped me a lot!!!!

 

Thanks again!!.

 

Thanks for your reply also v00d00,

 

will look into your suggestion as well, thanks!!

0 Kudos
lidianhao123
Newbie
Newbie
8,226 Views
Registered: ‎09-01-2010

i do for follows:

"you can find examples in $xilinxinstalldirectory/version/EDK\sw\XilinxProcessorIPLib\drivers"

but i can find example c code can you tell detials.

Thank you in advance.

0 Kudos
applistar
Visitor
Visitor
7,919 Views
Registered: ‎07-20-2010

hi

 

UART RECEIVE DATA AND SAVE INTO DDR" very useful for me.real_file_size (you define the file size you want to write to DDR2 )you use in your code? Because the uartlite has buffer limited = 16 byte and if you transfer data to uart with so many data , buffer will full with data ==> wrong. I don't know you have a way to solve about this. Can you explain for me? Your post is help me very much . Thank you!

0 Kudos
mahesr
Visitor
Visitor
7,524 Views
Registered: ‎03-05-2012
hi everry body

I'm trying to implement the same on virtex 6. only changes are i'm using DDR3. rest all is same. but when i add the above code, which header files i have to add. please let me know. Do send me full c code and which header files to be added with it...

Thanks and looking for all your suggestions!!!!....
0 Kudos