[PIC] making a big table of constants in program space?

Status
Not open for further replies.

MathGeek

Member level 3
Joined
Aug 16, 2005
Messages
67
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Visit site
Activity points
1,806
c30 creating constants in program space

I am trying to make a good size table of constants.

I am using dsPIC30F4011, and although it has a good size RAM, I am reserving that for other purposes, and need to use the even bigger program (code) space for storing a table of constants.

I am using C30, and would like to do this.

I just need some key points and guiding remarks on how to get started.

Thanks.
 

You can store constants in C like this:
Code:
const unsigned char numbers[10][8]=
	{{0x1C, 0x22, 0x26, 0x2A, 0x32, 0x22, 0x1C, 0x00},
	 {0x08, 0x18, 0x08, 0x08, 0x08, 0x08, 0x1C, 0x00},
	 {0x1C, 0x22, 0x02, 0x04, 0x08, 0x10, 0x3E, 0x00},
	 {0x1C, 0x22, 0x02, 0x0C, 0x02, 0x22, 0x1C, 0x00},
	 {0x04, 0x08, 0x10, 0x24, 0x3E, 0x04, 0x04, 0x00},
	 {0x3E, 0x20, 0x20, 0x3C, 0x02, 0x02, 0x3C, 0x00},
	 {0x1C, 0x22, 0x20, 0x3C, 0x22, 0x22, 0x1C, 0x00},
	 {0x3E, 0x02, 0x02, 0x04, 0x08, 0x10, 0x20, 0x00},
	 {0x1C, 0x22, 0x22, 0x1C, 0x22, 0x22, 0x1C, 0x00},
	 {0x1C, 0x22, 0x22, 0x1E, 0x02, 0x22, 0x1C, 0x00}};
 

that is part of my question. does "const" store the value into program space or precious RAM?

Which datasheet should I look into? C30 manual? 30F programmer's manual?
 

Definitely the C30 manual. I don't know how this compiler handles constants, but gcc for example uses program space to store constants. I guess the C30 does the same, but you better check it.
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…