View previous topic :: View next topic |
Author |
Message |
jacqueskleynhans
Joined: 10 Apr 2008 Posts: 109 Location: Cape Town, South Africa
|
Out Of Memory |
Posted: Wed Jun 09, 2010 7:55 am |
|
|
HI Guys I have to send about 150 I2c commands to a peripheral camera sensor but I have seemed to run out of ROM space....
Can any suggest something that may condense space the I2c commands are in this fastion:
Code: | //Command used to initiated a soft restart
i2c_start();
i2c_write(OV5620_WRITE_ADDR);
i2c_write(0x12);
i2c_write(0x80);
i2c_stop();
delay_us(2); // Bus Free time
//Setup Common control 8
i2c_start();
i2c_write(OV5620_WRITE_ADDR);
i2c_write(0x13);
i2c_write(0x00);
i2c_stop();
delay_us(2);
//Set (11110) to AEC[10:3] Automatic Exposure Control
i2c_start();
i2c_write(OV5620_WRITE_ADDR);
i2c_write(0x10);
i2c_write(0x1E);
i2c_stop();
delay_us(2);
//Reserved
i2c_start();
i2c_write(OV5620_WRITE_ADDR);
i2c_write(0x3B);
i2c_write(0x07);
i2c_stop();
delay_us(2);
//Reserved
i2c_start();
i2c_write(OV5620_WRITE_ADDR);
i2c_write(0x5B);
i2c_write(0x40);
i2c_stop();
delay_us(2);
//Reserved
i2c_start();
i2c_write(OV5620_WRITE_ADDR);
i2c_write(0x39);
i2c_write(0x07);
i2c_stop();
delay_us(2);
//Reserved
i2c_start();
i2c_write(OV5620_WRITE_ADDR);
i2c_write(0x53);
i2c_write(0x02);
i2c_stop();
delay_us(2);
//Reseved
i2c_start();
i2c_write(OV5620_WRITE_ADDR);
i2c_write(0x54);
i2c_write(0x60);
i2c_stop();
delay_us(2);
|
Thanks in advance
Jacques _________________ "THE ONLY EASY DAY WAS YESTERDAY" |
|
 |
mskala
Joined: 06 Mar 2007 Posts: 100 Location: Massachusetts, USA
|
|
Posted: Wed Jun 09, 2010 8:55 am |
|
|
Create a subroutine for the write, you only even need 2 parameters. |
|
 |
rnielsen
Joined: 23 Sep 2003 Posts: 852 Location: Utah
|
|
Posted: Wed Jun 09, 2010 10:08 am |
|
|
One thing that causes Out of Rom errors is if you have too much code in one function, including main(). The PIC's memory space is like a book. You have several pages in the book but your code(function) has to fit on each page and cannot carry over to the next page. I would imagine this is your problem. Try chopping your I2C commands into separate functions and then just call those functions in order to create the same effect.
Ronald |
|
 |
jacqueskleynhans
Joined: 10 Apr 2008 Posts: 109 Location: Cape Town, South Africa
|
|
Posted: Wed Jun 09, 2010 2:44 pm |
|
|
thx i will give that a try _________________ "THE ONLY EASY DAY WAS YESTERDAY" |
|
 |
|