Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
Thread Tools Display Modes
Old 3rd February 2008, 03:57 PM   (permalink)
Default Variable specify in flash

Hi,
How can i specify a variable in flash or ROM of PIC16F877A. (MicroC compiler)
my variable is "unsigned char temp[1024];" but this is so larg for RAM. i want specify this variable in flash but i don't know how can i.
Hesam Kamalan is offline   Reply With Quote
Old 3rd February 2008, 04:04 PM   (permalink)
Default

Quote:
Originally Posted by Hesam Kamalan
Hi,
How can i specify a variable in flash or ROM of PIC16F877A. (MicroC compiler)
my variable is "unsigned char temp[1024];" but this is so larg for RAM. i want specify this variable in flash but i don't know how can i.
You can't, by definition you can't have a variable in ROM.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is online now   Reply With Quote
Old 3rd February 2008, 04:29 PM   (permalink)
Default

Thanks Nigle,

I have 512K EEPROM and i want to write 1024 byte of EEPROM in ROM. i write this code :
I2C_Start();
I2C_Wr(0xA2); // send byte via I2C (device address + W)
I2C_Wr(2); // send byte (data address)
I2C_Repeated_Start(); // issue I2C signal repeated start
I2C_Wr(0xA3); // send byte (device address + R)
for(i=0; i<1024; i++)
temp[i] = I2C_Rd(0u); // Read the data (NO acknowledge)
I2C_Stop();

but "temp" is larger than RAM size and error appeared.
how can i write EEPROM data on ROM?
Hesam Kamalan is offline   Reply With Quote
Old 3rd February 2008, 04:31 PM   (permalink)
Default

Quote:
Originally Posted by Hesam Kamalan
but "temp" is larger than RAM size and error appeared.
how can i write EEPROM data on ROM?
I suggest you consider what ROM stands for?

READ ONLY memory.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is online now   Reply With Quote
Old 4th February 2008, 09:07 AM   (permalink)
Default

As Nigel says, you can't have variables in ROM but you can have constant in ROM.

In C18 you would do,
Code:
rom char RomData[] = "This is character data";
rom char RomHex[]="\x23\x45\x67";                  // will be bytes 0x23,0x45,0x67
Check your compilers manual for something similar.

Alternatively you could do a large table in asm using retlw.

Edit, I just noticed you want to write to your variable. This can be done but you have to write the bit that does the writing in asm. Check out the EEPROM section in the data sheet.

Mike.

Last edited by Pommie; 4th February 2008 at 09:11 AM.
Pommie is online now   Reply With Quote
Old 4th February 2008, 09:13 AM   (permalink)
Default

Quote:
Originally Posted by Nigel Goodwin
I suggest you consider what ROM stands for?

READ ONLY memory.
That is why it isn't referred to as ROM anymore. It's flash and can be written to.

Mike.
Pommie is online now   Reply With Quote
Old 4th February 2008, 09:44 AM   (permalink)
Default

Quote:
Originally Posted by Pommie
That is why it isn't referred to as ROM anymore. It's flash and can be written to.
Some is FLASH and some is EEPROM, and some can be reprogrammed within a program, and some can't - depending on the chip - however, self modifying code has always been fraught with danger!
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is online now   Reply With Quote
Old 4th February 2008, 09:57 AM   (permalink)
Default

Quote:
Originally Posted by Nigel Goodwin
Some is FLASH and some is EEPROM, and some can be reprogrammed within a program, and some can't - depending on the chip - however, self modifying code has always been fraught with danger!
All very true but, in this case the OP is asking about storing data in program memory which is easily done on an 877. However, I do wonder why, as he has the I²C capabilities, he doesn't just stick another serial EEPROM on the same bus.

Mike.
Pommie is online now   Reply With Quote
Old 4th February 2008, 10:02 AM   (permalink)
Default

Quote:
Originally Posted by Pommie
All very true but, in this case the OP is asking about storing data in program memory which is easily done on an 877. However, I do wonder why, as he has the I²C capabilities, he doesn't just stick another serial EEPROM on the same bus.
Would there be any point?, why not just leave it in the existing one? - presumably he's wanting to process it in some way?, but he's never suggested what he's trying to do.

But I would suggest he needs to rethink what he's doing?, I suspect he's a PC programmed and used to fairly unlimited resources.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is online now   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Latest
Logic circuit for two cameras and one flash. Hermit Electronic Projects Design/Ideas/Reviews 30 10th December 2007 03:25 AM
Using Oscilloscopes mechie Electronic Theory 9 29th November 2007 09:48 PM
Disposiable camera flash modification HarveyH42 Electronic Projects Design/Ideas/Reviews 9 5th April 2006 04:24 PM
How to reset SCR used for triggering camera flash shootfirst Electronic Projects Design/Ideas/Reviews 20 28th September 2005 08:40 PM
electronic switch to enable a camera to fire a flashgun tony ellis Electronic Projects Design/Ideas/Reviews 10 30th September 2004 10:18 AM



All times are GMT. The time now is 11:42 AM.


Electronic Circuits  |  Electronics Wiki
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.