Hi Michael, Thanks for your suggestions. From the C18 manual, it is said that the "const" does not imply program memory. Does anyone know how to select bank in PIC18F258 under the C18 compiler? Thanks in advance! Luke -----Original Message----- From: Michael Rigby-Jones [mailto:mrjones@NORTELNETWORKS.COM] Sent: Wednesday, August 14, 2002 2:46 AM To: PICLIST@MITVMA.MIT.EDU Subject: Re: [PIC] MPLAB C18 Compiler data memory usage (deep design) > -----Original Message----- > From: Hu, Luhui [SMTP:Luhui_Hu@PLUGPOWER.COM] > Sent: Tuesday, August 13, 2002 2:02 PM > To: PICLIST@MITVMA.MIT.EDU > Subject: [PIC] MPLAB C18 Compiler data memory usage (deep design) > > Hi, > > I am using Microchip MPLAB C18 compiler for PIC18F258. I have some > questions: > > (1) How can I store variables using bank selection? > > (2) How can I use "#pragma varlocate n"? > > (3) Where do the compiler store "const" variables, "#define" constants and > "enum" member lists? In the Flash program memory or RAM data memory? > When I look at the Assembly code (after compiling), "const" variables are > stored in the Flash but they also use the RAM data memory. The "#define" > constants and "enum" member lists seem that they do not take RAM data > memory > nor Flash memory but they are replaced by the represented values directly > in > the assembly code. Therefore, I should use "define" and "enum" instead of > "const" variables when I want to use constants. > Sorry, I'm not familiar with the C18 compiler, but a const will always be stored in program memory on a PIC. #define is a pre-processor directive, and is used for assigning a string to a literal nummber (or statement). However, const and #define are not interchangeable. If you have a const variable, the variable is stored in a known memory location and can be accessed by pointers. This probably dosen't sound very usefull for single bytes, but when you wish to use a lookup table (i.e. an array) then you won't be able to use a #define. Regards Mike -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu