element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      • Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Avnet Boards Forums
  • Products
  • Dev Tools
  • Avnet & Tria Boards Community
  • Avnet Boards Forums
  • More
  • Cancel
Avnet Boards Forums
Avnet Boards General Store a frame into the RAM
  • Forum
  • Documents
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Avnet Boards Forums to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Not Answered
  • Replies 1 reply
  • Subscribers 354 subscribers
  • Views 237 views
  • Users 0 members are here
Related

Store a frame into the RAM

Former Member
Former Member over 11 years ago

I have following code that save one line of pixel data into 64k block memory. I want to save this line into the 512 MB RAM. Would anyone help me out



#include "lwip/err.h"
#include "lwip/udp.h"
#include "netif/xadapter.h"


#include "xil_types.h"
#include "xil_printf.h"
#include "xparameters.h"


#include "stereo_axi_a_lib.h"
#include "stereo_axi_a.h"

struct camera_config
{
tint cam_address;
tint cam_iic;
};


void udp_recv_callback(void *arg, struct udp_pcb *pcb, struct pbuf *p,ip_addr_t *addr, u16_t port);
void InitializeCameraSystem (struct camera_config config, void *mem);

#define WIDTH 700
#define HEIGHT 600

#define UDP_PORT 10024


///////////////////////////////////////////////////////////////////////////////////////
/////////////////////////// The actual application ////////////////////////////////////
//////////////// @netif = eithernet interface initialized in the main function ////////
///////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////
void start_udp_application (struct netif *netif)
{
txil_printf("start udp application ... Ahmed Elhossini
r");
tstruct pbuf *buffer;


tint i = 0,line = 0, oldline = 0;

tu8 *image_ram = (u8 *)XPAR_IMGRAM_CTRL_CORESIDE_S_AXI_BASEADDR;

tstruct udp_pcb *udp, *udp2;

tstruct ip_addr ipaddr_d, ipaddr_s;

tif(NULL == (udp = udp_new()))
ttxil_printf("Problems initializing udp pcb!
r");
tif(NULL == (udp2 = udp_new()))
ttxil_printf("Problems initializing 2nd udp pcb!
r");

tIP4_ADDR(&ipaddr_d,  130, 149,   224, 5);
tIP4_ADDR(&ipaddr_s,  130, 149,   224, 4);


tif(ERR_OK != udp_connect(udp,&ipaddr_d,10024))
ttxil_printf("Problems connecting to destination address!
r");
tif(ERR_OK != udp_bind(udp,&ipaddr_s,10024))
ttxil_printf("Problems binding address!
r");

tif(ERR_OK != udp_bind(udp2,&ipaddr_s,10025))
ttxil_printf("Problems binding to second port address!
r");


tstruct camera_config config1, config2;

tconfig1.cam_address = XPAR_STEREO_AXI_A_0_BASEADDR;
tconfig1.cam_iic = XPAR_IIC_FPGA_CAM1_BASEADDR;

tconfig2.cam_address = XPAR_STEREO_AXI_A_1_BASEADDR;
tconfig2.cam_iic = XPAR_IIC_FPGA_CAM2_BASEADDR;

tudp_recv(udp,udp_recv_callback,&config1);
tudp_recv(udp2,udp_recv_callback,&config2);

tbuffer = pbuf_alloc(PBUF_RAW,WIDTH*2+10,PBUF_ROM);
tif(buffer == NULL)
ttxil_printf("buffer could not allocate!
r");

tbuffer->payload = (void *)XPAR_IMGRAM_CTRL_CORESIDE_S_AXI_BASEADDR;

tfor (i=0;i<WIDTH*2+10;i++)
ttimage_ram[i] = 0;
timage_ram[0] = 1; // 1=RGB565

txil_printf("start udp application ... done
r");
txil_printf("initializing camera ...
r");

tInitializeCameraSystem (config1,(void *)(XPAR_IMGRAM_CTRL_CORESIDE_S_AXI_BASEADDR+4));



t////// Loop for ever //////
twhile(1)
t{


ttxemacif_input(netif);

ttline = image_ram[5] + 256 * image_ram[4];

ttif (line!=oldline)
tt{
ttt/////////////////////////////////////////////////////////////////////////
ttt/////////////////////////////////////////////////////////////////////////
ttt///////////// Send one line of image data to the other host /////////////
ttt/////////////////////////////////////////////////////////////////////////
ttt/////////////////////////////////////////////////////////////////////////

tttudp_send(udp,buffer);

tttoldline = line;
tt}
t}
txil_printf("UDP Completed!!");
}


/////////////////////////////////////////////////////////////////
////// Initialize the camera module /////////////////////////////
////// @config = address of the camera modules//////////////////////
////// @mem = memory address to be used    //////////////////////
//////        for video output ttt   //////////////////////
////// Originally was set to = XPAR_STEREO_AXI_A_0_BASEADDR /////
/////////////////////////////////////////////////////////////////
void InitializeCameraSystem (struct camera_config config, void *mem)
{
t t int i = 0, j = 0;

t t int CAM1 = config.cam_iic;
t t int cam_address = config.cam_address;

t t u32 filter[] = {
t tttt t t  0xFFFFFFFF, 0xFFFFFFFD, 0xFFFFFFFC, 0xFFFFFFFD, 0xFFFFFFFF,
t tttt          0xFFFFFFFD, 0x0      , 0x06      , 0x0      , 0xFFFFFFFD,
t tttt          0xFFFFFFFC, 0x06      , 0x14     , 0x06      , 0xFFFFFFFC,
t tttt          0xFFFFFFFD, 0x0      , 0x06      , 0x0      , 0xFFFFFFFD,
t tttt          0xFFFFFFFF, 0xFFFFFFFD, 0xFFFFFFFC, 0xFFFFFFFD, 0xFFFFFFFF,
t tttt          0x00,0x3F,0xFFFFFFFF ,0xFFFFFFFF
t tttt          ,4//PIPELINE_MUX_CONVOLUTION|PIPELINE_MUX_ACTIVE
t tttt          ,4//PIPELINE_MUX_BW|PIPELINE_MUX_ACTIVE
t tttt          ,5//PIPELINE_MUX_MORPH1|PIPELINE_MUX_ACTIVE
t tttt          ,6//PIPELINE_MUX_MORPH2|PIPELINE_MUX_ACTIVE
t tttt          ,3//PIPELINE_MUX_CONVOLUTION
t tttt          ,0
t tt t t t t  ,0
t tt };



t tu32 *ipcore_regs = (u32 *)cam_address;

t tWriteRegister (CAM1,0x301A,0x02CD);t// Turn off the output


t    xil_printf("r
This line is to force some delay before actual communication:)");

t    i = ReadRegister(CAM1,0x3000);

t    xil_printf("r
Camera ID Register value (0x3000) = 0x%04x",i);


t    //// Soft reset the core
t    i = ReadRegister(CAM1,0x3386);

t    xil_printf("r
Camera Soft reset value (0x3386) = 0x%04x",i);
t    ResetCamera(CAM1);


t    WriteRegister (CAM1,0x3202,0x0008);
t    i = ReadRegister(CAM1,0x3202);
t    xil_printf("r
Camera Wake up Register (0x3202) = 0x%04x",i);

t    i = ReadVariable (CAM1,0x2703);
t    xil_printf("r
Current output width (A)= %d",i);
t    i = ReadVariable (CAM1,0x2705);
t    xil_printf("r
Current output height (A)= %dr
",i);

t    i = ReadVariable (CAM1,0x2707);
t    xil_printf("r
Current output width (B) = %d",i);
t    i = ReadVariable (CAM1,0x2709);
t    xil_printf("r
Current output height (B)= %dr
",i);


t    i = ReadRegister(CAM1,0x341E);

t    /// Disable PLL
t    i = i |0x0001;
t    WriteRegister(CAM1,0x341E,i);
t    i= i |0x0002;
t    WriteRegister(CAM1,0x341E,i);

t    xil_printf("r
Reseting.... Hope this will be enough to reset!!");
t    for (i = 0;i<1000;i++);

t    xil_printf("r
Configure the camera..");

//t    ConfigureCamera(CAM1,CONTEXT_A,WIDTH,HEIGHT,FORMAT_MONOCHROME);
t    ConfigureCamera(CAM1,CONTEXT_A,WIDTH,HEIGHT,FORMAT_RGB565);

t    i = ReadVariable (CAM1,0x2703);
t    xil_printf("r
Current output width (A)= %d",i);
t    i = ReadVariable (CAM1,0x2705);
t    xil_printf("r
Current output height (A)= %dr
",i);

t    i = ReadVariable (CAM1,0x2707);
t    xil_printf("r
Current output width (B) = %d",i);
t    i = ReadVariable (CAM1,0x2709);
t    xil_printf("r
Current output height (B)= %dr
",i);

t   // SwitchContext (CAM1,CONTEXT_A);
t    xil_printf("Turning output onr
");
t    WriteRegister (CAM1,0x301A,0x02CC);t// Turn on the output
t    ////////////////////////////////////////////////////////////

t    for (i = 0; i <= 0x23;i++)
t        WriteVMODVariable((u32 *)cam_address, i, filter[i]);


t    xil_printf("r
Filter data:");

t    for (i = 0; i <= 0x23;i++)
t         xil_printf("0x%x (expected 0x%x),
r",ReadVMODVariable((u32 *)cam_address, i),filter[i]);

t    xil_printf("r
");

t    ////////////////////////////////////////////////////////////


t    xil_printf("r
Start Address = 0x%08xr
",mem);

t    SSR_AXI_MasterSendWord(cam_address,(int )mem);


t    for (i = 0;i<10000;i++)
t    tj = ipcore_regs[0];

t    xil_printf ("r
Image Size  W,H: = %05x,%05xr
",j&0x0000FFFF, (j>>16)&0x0000FFFF);
}



void udp_recv_callback(void *arg, struct udp_pcb *pcb, struct pbuf *p, ip_addr_t *addr, u16_t port)
{
t struct camera_config *config = (struct camera_config *)arg;

t int rAdd = 0;
t int rVal = 0;
t int rType = 0;

t int *data = (int *)p->payload;
t int retData[2*(6+25+4)+1];
t int i;

t int CAM1 = config->cam_iic;
t int cam_address = config->cam_address;
txil_printf("r
I got something r
");

trAdd = data[0];
trVal = data[1];
trType= data[2];

txil_printf("Register = %x , Value = %x , Type = %xr
",rAdd,rVal, rType);

tswitch (rType)
t{
ttcase 0:
ttWriteVMODVariable((u32*)cam_address, rAdd, rVal);

ttxil_printf("Read back Value = %xr
", ReadVMODVariable((u32*)cam_address, rAdd));
ttbreak;

ttcase 1:
tttWriteRegister(CAM1,rAdd,rVal);
tttxil_printf("Writing CAM Register!!r
");
tttbreak;
ttcase 2:
tttWriteVariable(CAM1,rAdd,rVal);
tttxil_printf("Writing CAM Variable!!r
");
tttbreak;
ttcase 3:
tttfor(i=0;i<35;i++)
ttt{
ttttretData[i]=ReadVMODVariable((u32*)cam_address, i);
ttt}

tttfor(i=0;i<35;i++)
ttttretData[i+35]=ReadVMODVariable((u32*)cam_address, 0x100+i);
tttretData[70]=ReadVMODVariable((u32*)cam_address, 0x200);

tttudp_connect(pcb,addr,port);

tttpbuf_free(p);
tttp = pbuf_alloc(PBUF_RAW,71*sizeof(int),PBUF_REF);
tttp->payload = &retData;
tttif(udp_send(pcb,p) != ERR_OK)
ttttxil_printf("Error sending configuration detail!!
r");

tttudp_disconnect(pcb);S
tttbreak;

ttdefault:
tttbreak;

t}


tpbuf_free(p);
treturn;
}
S

  • Sign in to reply
  • Cancel
  • bhfletcher
    0 bhfletcher over 11 years ago

    It's not clear which board or which version Xilinx tools or if an OS is involved. A little more info would have been helpful. However, we do have a few different video tutorials available, all of which probably have some kind of frame buffer. For example, with ZedBoard:

    HDMI Bare Metal Reference Design Using ADV7511 and ADI IP

    Building a Zynq Video Design from Scratch

    Zedboard HDMI Display Controller Tutorial for Vivado using Xilinx VIPP

     

    Bryan

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2026 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube