I posted this question last weekend but I didn't get any reply's. I know someone in this group knows the answer. Max I'm trying to run a build on a program that I found on the internet. It makes use of the "ifdef" command but has no "define" command in the program. Since I'm new at this I went to the help files to see what I could find. The examples show "ifdef" and "#ifdef" but it doesn't say what the difference is. I tried adding a "#define __12c509" at the beginning, but that didn't work. Most of the build errors are because the "include" isn't being processed but there are other "ifdef" statements on down into the program. I included just the beginning of the program so hopefully someone can help. Thanks Max ifdef __16f84 processor 16f84 list f=inhx8m include "p16f84.inc" __config _cp_off & _wdt_on & _hs_osc endif ifdef __12c509 processor 12c509a list f=inhx8m include "P12C509A.INC" ifdef jw __config _mclre_off & _cp_off & _wdt_on & _iNTrc_osc endif ifdef cp __config _mclre_off & _cp_on & _wdt_on & _iNTrc_osc endif endif ifdef __16f84 base equ 0x0c ; first free file register address stack equ 0x4f+1 ; end address of stack port equ portb ; port on which bits are used movwt macro ; move w to tris tris trisb endm bank0 macro endm bank1 macro endm endif ifdef __16f84 endif ifdef __12c509 base equ 0x07 ; first free file register address stack equ 0x1f+1 ; end address of stack port equ gpio ; port on which bits are used movwt macro ; move w to tris tris gpio endm bank0 macro ; select low bank for goto/call bcf status,pa0 endm bank1 macro ; select high bank for goto/call bsf status,pa0 endm endif |
ifdef and #ifdef
Started by ●March 2, 2005
Reply by ●March 2, 20052005-03-02
Hi, The assembler does not care if you use #define or define. They do the same thing. I always use #define though since I'm used to that syntax. It's possible there might be some difference but a quick glance through the MPSAM manual does not show anything. Try stepping through the code in the simulator. It's possible a typo or other issue is preventing one of your defines from working. You should spot this immediately if you simulate. You can also try using an explicit path to the include file if it's not being loaded. In other words #include "c:\mydirectory\myinclude.inc". Finally, the processor defines (__12C509, __16f84, etc) are set when you define the processor being used. This is done in your source file using the list pF84A directive. This directive needs to appear before you include the processor specific include file. The code should look something like this: list pF84A #include p16F84A.inc Or in your case: list p=<some processor> #ifdef __16f84 processor 16f84 #include "p16f84.inc" __config _cp_off & _wdt_on & _hs_osc #endif #ifdef __12c509 #include "P12C509A.INC" __config <your config settings> #endif etcetera ..... Hope this helps. -Chris http://pic.rocklizard.org -----Original Message----- From: kg4pid [mailto:] Sent: Wednesday, March 02, 2005 12:28 PM To: Subject: [piclist] ifdef and #ifdef I posted this question last weekend but I didn't get any reply's. I know someone in this group knows the answer. Max I'm trying to run a build on a program that I found on the internet. It makes use of the "ifdef" command but has no "define" command in the program. Since I'm new at this I went to the help files to see what I could find. The examples show "ifdef" and "#ifdef" but it doesn't say what the difference is. I tried adding a "#define __12c509" at the beginning, but that didn't work. Most of the build errors are because the "include" isn't being processed but there are other "ifdef" statements on down into the program. I included just the beginning of the program so hopefully someone can help. Thanks Max ifdef __16f84 processor 16f84 list f=inhx8m include "p16f84.inc" __config _cp_off & _wdt_on & _hs_osc endif ifdef __12c509 processor 12c509a list f=inhx8m include "P12C509A.INC" ifdef jw __config _mclre_off & _cp_off & _wdt_on & _iNTrc_osc endif ifdef cp __config _mclre_off & _cp_on & _wdt_on & _iNTrc_osc endif endif ifdef __16f84 base equ 0x0c ; first free file register address stack equ 0x4f+1 ; end address of stack port equ portb ; port on which bits are used movwt macro ; move w to tris tris trisb endm bank0 macro endm bank1 macro endm endif ifdef __16f84 endif ifdef __12c509 base equ 0x07 ; first free file register address stack equ 0x1f+1 ; end address of stack port equ gpio ; port on which bits are used movwt macro ; move w to tris tris gpio endm bank0 macro ; select low bank for goto/call bcf status,pa0 endm bank1 macro ; select high bank for goto/call bsf status,pa0 endm endif to unsubscribe, go to http://www.yahoogroups.com and follow the instructions Yahoo! Groups Links |
Reply by ●March 2, 20052005-03-02
Have you set the processor in MPLAB(configure->select device)? when you set the processor in MPLAB it should define the symbol '__12c509'. The code looks like it Redefines the processor type though. If you set the processor as 12c509 in MPLAB the preprocessor directives: > ifdef __12c509 > processor 12c509a will reset it to the A version. If the assembler or linker pass thru multiple times that could screw thinks up. --- In , "kg4pid" <kg4pid@y...> wrote: > > I posted this question last weekend but I didn't get any reply's. > I know someone in this group knows the answer. Max > > I'm trying to run a build on a program that I found on the > internet. It makes use of the "ifdef" command but has no "define" > command in the program. Since I'm new at this I went to the help > files to see what I could find. The examples show "ifdef" > and "#ifdef" but it doesn't say what the difference is. I tried > adding a "#define __12c509" at the beginning, but that didn't work. > Most of the build errors are because the "include" isn't being > processed but there are other "ifdef" statements on down into the > program. I included just the beginning of the program so hopefully > someone can help. > > Thanks Max > ifdef __16f84 > processor 16f84 > list f=inhx8m > include "p16f84.inc" > __config _cp_off & _wdt_on & _hs_osc > endif > > ifdef __12c509 > processor 12c509a > list f=inhx8m > include "P12C509A.INC" > ifdef jw > __config _mclre_off & _cp_off & _wdt_on & _iNTrc_osc > endif > ifdef cp > __config _mclre_off & _cp_on & _wdt_on & _iNTrc_osc > endif > endif > > ifdef __16f84 > base equ 0x0c ; first free file register address > stack equ 0x4f+1 ; end address of stack > port equ portb ; port on which bits are used > movwt macro ; move w to tris > tris trisb > endm > bank0 macro > endm > bank1 macro > endm > endif > ifdef __16f84 > endif > > ifdef __12c509 > base equ 0x07 ; first free file register address > stack equ 0x1f+1 ; end address of stack > port equ gpio ; port on which bits are used > movwt macro ; move w to tris > tris gpio > endm > bank0 macro ; select low bank for goto/call > bcf status,pa0 > endm > bank1 macro ; select high bank for goto/call > bsf status,pa0 > endm > endif |
Reply by ●March 2, 20052005-03-02
Yes I have set the processor in MPLAB. I also renamed __12c509 and added the 'a' on the end so that the 'ifdef' and the processor matched. It still doesent seem to process the include statement because most of the errors are things like Symbol not previously defined (fsr) Symbol not previously defined (indf) Symbol not previously defined (status) Symbol not previously defined (c) these should be in the include file correct? I even added the next 2 statements at the beginning of the program but didn't help either. include "P12C509A.INC" #define __12c509a Thanks, Max --- In , "john" <j_funk1425@y...> wrote: > > Have you set the processor in MPLAB(configure->select device)? > when you set the processor in MPLAB it should define the > symbol '__12c509'. The code looks like it Redefines the processor > type though. If you set the processor as 12c509 in MPLAB the > preprocessor directives: > > ifdef __12c509 > > processor 12c509a > will reset it to the A version. If the assembler or linker pass thru > multiple times that could screw thinks up. > --- In , "kg4pid" <kg4pid@y...> wrote: > > > > I posted this question last weekend but I didn't get any reply's. > > I know someone in this group knows the answer. Max > > > > I'm trying to run a build on a program that I found on the > > internet. It makes use of the "ifdef" command but has no "define" > > command in the program. Since I'm new at this I went to the help > > files to see what I could find. The examples show "ifdef" > > and "#ifdef" but it doesn't say what the difference is. I tried > > adding a "#define __12c509" at the beginning, but that didn't > work. > > Most of the build errors are because the "include" isn't being > > processed but there are other "ifdef" statements on down into the > > program. I included just the beginning of the program so hopefully > > someone can help. > > > > Thanks Max > > > > > > ifdef __16f84 > > processor 16f84 > > list f=inhx8m > > include "p16f84.inc" > > __config _cp_off & _wdt_on & _hs_osc > > endif > > > > ifdef __12c509 > > processor 12c509a > > list f=inhx8m > > include "P12C509A.INC" > > ifdef jw > > __config _mclre_off & _cp_off & _wdt_on & _iNTrc_osc > > endif > > ifdef cp > > __config _mclre_off & _cp_on & _wdt_on & _iNTrc_osc > > endif > > endif > > > > ifdef __16f84 > > base equ 0x0c ; first free file register address > > stack equ 0x4f+1 ; end address of stack > > port equ portb ; port on which bits are used > > movwt macro ; move w to tris > > tris trisb > > endm > > bank0 macro > > endm > > bank1 macro > > endm > > endif > > ifdef __16f84 > > endif > > > > ifdef __12c509 > > base equ 0x07 ; first free file register address > > stack equ 0x1f+1 ; end address of stack > > port equ gpio ; port on which bits are used > > movwt macro ; move w to tris > > tris gpio > > endm > > bank0 macro ; select low bank for goto/call > > bcf status,pa0 > > endm > > bank1 macro ; select high bank for goto/call > > bsf status,pa0 > > endm > > endif |
Reply by ●March 3, 20052005-03-03
The symbol names are case sensitive. Make the variables in the code match the include file which are all uppercase. --- In , "kg4pid" <kg4pid@y...> wrote: > > Yes I have set the processor in MPLAB. I also renamed __12c509 and > added the 'a' on the end so that the 'ifdef' and the processor > matched. It still doesent seem to process the include statement > because most of the errors are things like > Symbol not previously defined (fsr) > Symbol not previously defined (indf) > Symbol not previously defined (status) > Symbol not previously defined (c) > these should be in the include file correct? > I even added the next 2 statements at the beginning of the program > but didn't help either. > > include "P12C509A.INC" > #define __12c509a > > Thanks, Max > > --- In , "john" <j_funk1425@y...> wrote: > > > > Have you set the processor in MPLAB(configure->select device)? > > when you set the processor in MPLAB it should define the > > symbol '__12c509'. The code looks like it Redefines the processor > > type though. If you set the processor as 12c509 in MPLAB the > > preprocessor directives: > > > ifdef __12c509 > > > processor 12c509a > > will reset it to the A version. If the assembler or linker pass thru > > multiple times that could screw thinks up. > > > > > > --- In , "kg4pid" <kg4pid@y...> wrote: > > > > > > I posted this question last weekend but I didn't get any reply's. > > > I know someone in this group knows the answer. Max > > > > > > I'm trying to run a build on a program that I found on the > > > internet. It makes use of the "ifdef" command but has no "define" > > > command in the program. Since I'm new at this I went to the help > > > files to see what I could find. The examples show "ifdef" > > > and "#ifdef" but it doesn't say what the difference is. I tried > > > adding a "#define __12c509" at the beginning, but that didn't > > work. > > > Most of the build errors are because the "include" isn't being > > > processed but there are other "ifdef" statements on down into the > > > program. I included just the beginning of the program so > hopefully > > > someone can help. > > > > > > Thanks Max > > > > > > > > > ifdef __16f84 > > > processor 16f84 > > > list f=inhx8m > > > include "p16f84.inc" > > > __config _cp_off & _wdt_on & _hs_osc > > > endif > > > > > > ifdef __12c509 > > > processor 12c509a > > > list f=inhx8m > > > include "P12C509A.INC" > > > ifdef jw > > > __config _mclre_off & _cp_off & _wdt_on & _iNTrc_osc > > > endif > > > ifdef cp > > > __config _mclre_off & _cp_on & _wdt_on & _iNTrc_osc > > > endif > > > endif > > > > > > ifdef __16f84 > > > base equ 0x0c ; first free file register address > > > stack equ 0x4f+1 ; end address of stack > > > port equ portb ; port on which bits are used > > > movwt macro ; move w to tris > > > tris trisb > > > endm > > > bank0 macro > > > endm > > > bank1 macro > > > endm > > > endif > > > ifdef __16f84 > > > endif > > > > > > ifdef __12c509 > > > base equ 0x07 ; first free file register address > > > stack equ 0x1f+1 ; end address of stack > > > port equ gpio ; port on which bits are used > > > movwt macro ; move w to tris > > > tris gpio > > > endm > > > bank0 macro ; select low bank for goto/call > > > bcf status,pa0 > > > endm > > > bank1 macro ; select high bank for goto/call > > > bsf status,pa0 > > > endm > > > endif |
Reply by ●March 3, 20052005-03-03
For a windowed version: list pc509 radix dec #INCLUDE <P12C509.INC> __CONFIG _CP_OFF & _WDT_OFF & _MCLRE_OFF & _IntRC_OSC Try this header instead all if defs. Then edit your header acording to this. Remmember to define jw or cp in your program. |
Reply by ●March 3, 20052005-03-03
One of the reasons it doesn't have any definitions could be that the symbols were defined on the command line to the assembler from a 'make' file. I tried the code, as submitted, and it didn't work. I'm not sure why it didn't work but it wasn't interesting enough to spend a lot of time on. Were it me, I would scrap the stuff that doesn't apply and start from there. Also, I seldom expect downloaded code to work properly. --- In , Chad Russel <chadrussel@y...> wrote: > Max, > I did reply, but it must have gone to Windo-limbo. That happens > sometimes. :-( What everyone else has said. It should work. Make sure > directives are not in column 1 and #ifdef is not correct as far as I > know. > > Worse case if you are only going to use one processor, rip out all the > code you don't need. > > Chad > --- kg4pid <kg4pid@y...> wrote: > > > > > I posted this question last weekend but I didn't get any reply's. > > I know someone in this group knows the answer. Max > > > > I'm trying to run a build on a program that I found on the > > internet. It makes use of the "ifdef" command but has no "define" > > command in the program. Since I'm new at this I went to the help > > files to see what I could find. The examples show "ifdef" > > and "#ifdef" but it doesn't say what the difference is. I tried > > adding a "#define __12c509" at the beginning, but that didn't work. > > Most of the build errors are because the "include" isn't being > > processed but there are other "ifdef" statements on down into the > > program. I included just the beginning of the program so hopefully > > someone can help. > > > > Thanks Max > > > > > > ifdef __16f84 > > processor 16f84 > > list f=inhx8m > > include "p16f84.inc" > > __config _cp_off & _wdt_on & _hs_osc > > endif > > > > ifdef __12c509 > > processor 12c509a > > list f=inhx8m > > include "P12C509A.INC" > > ifdef jw > > __config _mclre_off & _cp_off & _wdt_on & _iNTrc_osc > > endif > > ifdef cp > > __config _mclre_off & _cp_on & _wdt_on & _iNTrc_osc > > endif > > endif > > > > ifdef __16f84 > > base equ 0x0c ; first free file register address > > stack equ 0x4f+1 ; end address of stack > > port equ portb ; port on which bits are used > > movwt macro ; move w to tris > > tris trisb > > endm > > bank0 macro > > endm > > bank1 macro > > endm > > endif > > ifdef __16f84 > > endif > > > > ifdef __12c509 > > base equ 0x07 ; first free file register address > > stack equ 0x1f+1 ; end address of stack > > port equ gpio ; port on which bits are used > > movwt macro ; move w to tris > > tris gpio > > endm > > bank0 macro ; select low bank for goto/call > > bcf status,pa0 > > endm > > bank1 macro ; select high bank for goto/call > > bsf status,pa0 > > endm > > endif > > > > > > > > > > ===== > My software has no bugs, only undocumented features. |
Reply by ●March 3, 20052005-03-03
Most of the problems where due to case sensitive variables in the include file. Rather than change the whole program, I turnded of the case sensitivity in MPLAB and that fixed alot of the problems, but not all. I might have removed the "ifdef" statements but there is alot of them and I wanted to get it to build clean before changing too much. Thanks for everyones help. Max --- In , "john" <j_funk1425@y...> wrote: > > > The symbol names are case sensitive. Make the variables in the code > match the include file which are all uppercase. > > > --- In , "kg4pid" <kg4pid@y...> wrote: > > > > Yes I have set the processor in MPLAB. I also renamed __12c509 and > > added the 'a' on the end so that the 'ifdef' and the processor > > matched. It still doesent seem to process the include statement > > because most of the errors are things like > > Symbol not previously defined (fsr) > > Symbol not previously defined (indf) > > Symbol not previously defined (status) > > Symbol not previously defined (c) > > these should be in the include file correct? > > I even added the next 2 statements at the beginning of the > program > > but didn't help either. > > > > include "P12C509A.INC" > > #define __12c509a > > > > Thanks, Max > > > > --- In , "john" <j_funk1425@y...> wrote: > > > > > > Have you set the processor in MPLAB(configure->select device)? > > > when you set the processor in MPLAB it should define the > > > symbol '__12c509'. The code looks like it Redefines the > processor > > > type though. If you set the processor as 12c509 in MPLAB the > > > preprocessor directives: > > > > ifdef __12c509 > > > > processor 12c509a > > > will reset it to the A version. If the assembler or linker pass > thru > > > multiple times that could screw thinks up. > > > > > > > > > --- In , "kg4pid" <kg4pid@y...> wrote: > > > > > > > > I posted this question last weekend but I didn't get any > reply's. > > > > I know someone in this group knows the answer. Max > > > > > > > > I'm trying to run a build on a program that I found on the > > > > internet. It makes use of the "ifdef" command but has > no "define" > > > > command in the program. Since I'm new at this I went to the > help > > > > files to see what I could find. The examples show "ifdef" > > > > and "#ifdef" but it doesn't say what the difference is. I > tried > > > > adding a "#define __12c509" at the beginning, but that didn't > > > work. > > > > Most of the build errors are because the "include" isn't being > > > > processed but there are other "ifdef" statements on down into > the > > > > program. I included just the beginning of the program so > > hopefully > > > > someone can help. > > > > > > > > Thanks Max > > > > > > > > > > > > ifdef __16f84 > > > > processor 16f84 > > > > list f=inhx8m > > > > include "p16f84.inc" > > > > __config _cp_off & _wdt_on & _hs_osc > > > > endif > > > > > > > > ifdef __12c509 > > > > processor 12c509a > > > > list f=inhx8m > > > > include "P12C509A.INC" > > > > ifdef jw > > > > __config _mclre_off & _cp_off & _wdt_on & _iNTrc_osc > > > > endif > > > > ifdef cp > > > > __config _mclre_off & _cp_on & _wdt_on & _iNTrc_osc > > > > endif > > > > endif > > > > > > > > ifdef __16f84 > > > > base equ 0x0c ; first free file register address > > > > stack equ 0x4f+1 ; end address of stack > > > > port equ portb ; port on which bits are used > > > > movwt macro ; move w to tris > > > > tris trisb > > > > endm > > > > bank0 macro > > > > endm > > > > bank1 macro > > > > endm > > > > endif > > > > ifdef __16f84 > > > > endif > > > > > > > > ifdef __12c509 > > > > base equ 0x07 ; first free file register address > > > > stack equ 0x1f+1 ; end address of stack > > > > port equ gpio ; port on which bits are used > > > > movwt macro ; move w to tris > > > > tris gpio > > > > endm > > > > bank0 macro ; select low bank for goto/call > > > > bcf status,pa0 > > > > endm > > > > bank1 macro ; select high bank for goto/call > > > > bsf status,pa0 > > > > endm > > > > endif |