A discussion group for the PICMicro microcontroller. Also called the Microchip PIC, this list is dedicated to the use and abuse of this fine, simple, microcontroller. Close to topic posts are welcome, ie. general electronics.
|
Hello all, I have been attempting to make use of Karl Lunt's PIC Macros with no success during the build phase. I have followed his instructions and emailed him for help with no response. I'm using MPLab 6.20 and writing some test code for the 16F84A. The following text describes my code and the errors upon build. Could anyone take a look and see if you could provide some insight? Thanks in advance for any help. Regards, Stephen D. Barnes My code follows: ********************************************************************** *** ERRORLEVEL -224 ; suppress message because of tris ERRORLEVEL -302 ; suppress message because of page change list p=16F84A ; list directive to define processor #include <p16F84A.inc> ; processor specific variable definitions #include ".\macros.asm" __CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC ; '__CONFIG' directive is used to embed configuration data within .asm file. ; The lables following the directive are located in the respective .inc file. ; See respective data sheet for additional information on configuration word. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;; ;;;;;;;;;;;;;;;;; ORG 0x000 ; processor reset vector goto Main ; go to beginning of program ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;; ;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;; ;;;;;;;;;;;;;;;;; Main: clrf PORTB ; PORTB all outputs cleared bsf STATUS,5 ; Switch to Register Bank 1 for TRIS movlw B'11111111' ; all bits high in W movwf TRISA ; contents of W copied to TRISA (PORTA all inputs) movlw B'00000000' ; all bits low in W movwf TRISB ; contents of W copied to TRISB (PORTB all outputs) movlw 0 ; 0 in W movwf OPTION_REG ; contents of W copied to OPTION_REG (Port B pullups enabled) bcf STATUS,5 ; Switch back to Register Bank 0 movf PORTA ,0 ; move PORTA bit 0 to W register case 3 call Reverse endcase case 2 call Left endcase case 1 call Right endcase Reverse: return Left: return Right: return end ********************************************************************** *** When I build I get the following error: ********************************************************************** **** Executing: "E:\Program Files\MPLAB IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F84A "test1.asm" /l"test1.lst" /e"test1.err" /o"test1.o" Executing: "E:\Program Files\MPLAB IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F84A "MACROS.ASM" /l"MACROS.lst" /e"MACROS.err" /o"MACROS.o" Skipping link step. The project contains no linker script. BUILD FAILED ********************************************************************** **** Soooo... I created a linker script conforming to MPASM spec which reads as follows and is part of the MPLab project: ********************************************************************** **** FILES macros.o test1.o ********************************************************************** **** Build now reports the following error: ********************************************************************** **** Executing: "E:\Program Files\MPLAB IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F84A "test1.asm" /l"test1.lst" /e"test1.err" /o"test1.o" Executing: "E:\Program Files\MPLAB IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F84A "MACROS.ASM" /l"MACROS.lst" /e"MACROS.err" /o"MACROS.o" Executing: "E:\Program Files\MPLAB IDE\MCHIP_Tools\mplink.exe" "test1.lkr" "E:\PIC\test1.o" "E:\PIC\MACROS.o" /o"test1.cof" MPLINK 3.30, Linker Copyright (c) 2003 Microchip Technology Inc. Error - section '.cinit' can not fit the section. Section '.cinit' length=0x00000004 Errors : 1 BUILD FAILED ********************************************************************** **** |
|
|
|
Hello again! Put 'select' as an instruction before the first 'case' statement and put 'endselect' as as instruction after the last 'endcase' statement. Also, change the file name to Macros.inc and change the include statement to match. You do NOT want to assemble separately the macro library as it contains only definitions. No code is emitted until the macro is envoked (or expanded if you will). Lacking the documentation make the library hard to use. If you see these kinds of errors, look at the variable that was undefined and see where the macro library was emitting that code (the line number in the error message). Then wander around and find out why. Documentation would be better. One thing to look at - the comment on the 'movf PORTA,0' is incorrect because you are moving the entire 8 bit PORTA byte to W. More serious, using 0 instead of W for the destination makes the instruction hard to read. Both W and F are defined in the 16F84a include file - you don't need to define them. I haven't played with this particular macro library but when I saw it a while back I thought it was rather well done. Enjoy! --- In , "stephendbarnes" <stephendbarnes@h...> wrote: > Hello all, > I have been attempting to make use of Karl Lunt's PIC Macros with no > success > during the build phase. I have followed his instructions and emailed > him for > help with no response. I'm using MPLab 6.20 and writing some test > code for > the 16F84A. The > following text describes my code and the errors upon build. Could > anyone > take a look and see if you could provide some insight? Thanks in > advance for > any help. > > Regards, > Stephen D. Barnes > > My code follows: ********************************************************************** > *** > ERRORLEVEL -224 ; suppress message because of tris > ERRORLEVEL -302 ; suppress message because of page > change > > list p=16F84A ; list directive to define > processor > #include <p16F84A.inc> ; processor specific variable > definitions > #include ".\macros.asm" > > __CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC > > ; '__CONFIG' directive is used to embed configuration data > within .asm file. > ; The lables following the directive are located in the > respective .inc > file. > ; See respective data sheet for additional information on > configuration > word. > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; > ;;;;;; > ;;;;;;;;;;;;;;;;; > ORG 0x000 ; processor reset vector > goto Main ; go to beginning of program > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; > ;;;;;; > ;;;;;;;;;;;;;;;;; > > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; > ;;;;;; > ;;;;;;;;;;;;;;;;; > Main: > clrf PORTB ; PORTB all outputs cleared > bsf STATUS,5 ; Switch to Register Bank 1 for TRIS > movlw B'11111111' ; all bits high in W > movwf TRISA ; contents of W copied to TRISA (PORTA > all > inputs) > movlw B'00000000' ; all bits low in W > movwf TRISB ; contents of W copied to TRISB (PORTB > all > outputs) > movlw 0 ; 0 in W > movwf OPTION_REG ; contents of W copied to OPTION_REG (Port > B > pullups > enabled) > bcf STATUS,5 ; Switch back to Register Bank 0 > > movf PORTA ,0 ; move PORTA bit 0 to W register > > case 3 > call Reverse > endcase > > case 2 > call Left > endcase > > case 1 > call Right > endcase > > Reverse: > return > Left: > return > Right: > return > > end > ********************************************************************** > *** > > When I build I get the following error: ********************************************************************** > **** > Executing: "E:\Program Files\MPLAB > IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F84A > "test1.asm" /l"test1.lst" /e"test1.err" /o"test1.o" > Executing: "E:\Program Files\MPLAB > IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F84A > "MACROS.ASM" /l"MACROS.lst" /e"MACROS.err" /o"MACROS.o" > Skipping link step. The project contains no linker script. > BUILD FAILED > ********************************************************************** > **** > > Soooo... I created a linker script conforming to MPASM spec which > reads as > follows and is part of the MPLab project: ********************************************************************** > **** > FILES macros.o test1.o > ********************************************************************** > **** > > Build now reports the following error: ********************************************************************** > **** > Executing: "E:\Program Files\MPLAB > IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F84A > "test1.asm" /l"test1.lst" /e"test1.err" /o"test1.o" > Executing: "E:\Program Files\MPLAB > IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F84A > "MACROS.ASM" /l"MACROS.lst" /e"MACROS.err" /o"MACROS.o" > Executing: "E:\Program Files\MPLAB > IDE\MCHIP_Tools\mplink.exe" "test1.lkr" > "E:\PIC\test1.o" "E:\PIC\MACROS.o" /o"test1.cof" > MPLINK 3.30, Linker > Copyright (c) 2003 Microchip Technology Inc. > Error - section '.cinit' can not fit the section. Section '.cinit' > length=0x00000004 > Errors : 1 > BUILD FAILED > ********************************************************************** > **** |
|
|
|
Another 'readability' issue - you might think about using BANKSEL TRISA instead of BSF STATUS,5. Then you can change to bank 0 for PORTA by BANKSEL PORTA instead of BCF STATUS,5. See the help file but the short answer is that you can move quickly to the bank of ANY variable and you don't have to remember where you put it. Maybe not much of a problem with the 16F84a but the 16F877 has a 4 banks to contend with. --- In , "stephendbarnes" <stephendbarnes@h...> wrote: > Hello all, > I have been attempting to make use of Karl Lunt's PIC Macros with no > success > during the build phase. I have followed his instructions and emailed > him for > help with no response. I'm using MPLab 6.20 and writing some test > code for > the 16F84A. The > following text describes my code and the errors upon build. Could > anyone > take a look and see if you could provide some insight? Thanks in > advance for > any help. > > Regards, > Stephen D. Barnes > > My code follows: ********************************************************************** > *** > ERRORLEVEL -224 ; suppress message because of tris > ERRORLEVEL -302 ; suppress message because of page > change > > list p=16F84A ; list directive to define > processor > #include <p16F84A.inc> ; processor specific variable > definitions > #include ".\macros.asm" > > __CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC > > ; '__CONFIG' directive is used to embed configuration data > within .asm file. > ; The lables following the directive are located in the > respective .inc > file. > ; See respective data sheet for additional information on > configuration > word. > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; > ;;;;;; > ;;;;;;;;;;;;;;;;; > ORG 0x000 ; processor reset vector > goto Main ; go to beginning of program > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; > ;;;;;; > ;;;;;;;;;;;;;;;;; > > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; > ;;;;;; > ;;;;;;;;;;;;;;;;; > Main: > clrf PORTB ; PORTB all outputs cleared > bsf STATUS,5 ; Switch to Register Bank 1 for TRIS > movlw B'11111111' ; all bits high in W > movwf TRISA ; contents of W copied to TRISA (PORTA > all > inputs) > movlw B'00000000' ; all bits low in W > movwf TRISB ; contents of W copied to TRISB (PORTB > all > outputs) > movlw 0 ; 0 in W > movwf OPTION_REG ; contents of W copied to OPTION_REG (Port > B > pullups > enabled) > bcf STATUS,5 ; Switch back to Register Bank 0 > > movf PORTA ,0 ; move PORTA bit 0 to W register > > case 3 > call Reverse > endcase > > case 2 > call Left > endcase > > case 1 > call Right > endcase > > Reverse: > return > Left: > return > Right: > return > > end > ********************************************************************** > *** > > When I build I get the following error: ********************************************************************** > **** > Executing: "E:\Program Files\MPLAB > IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F84A > "test1.asm" /l"test1.lst" /e"test1.err" /o"test1.o" > Executing: "E:\Program Files\MPLAB > IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F84A > "MACROS.ASM" /l"MACROS.lst" /e"MACROS.err" /o"MACROS.o" > Skipping link step. The project contains no linker script. > BUILD FAILED > ********************************************************************** > **** > > Soooo... I created a linker script conforming to MPASM spec which > reads as > follows and is part of the MPLab project: ********************************************************************** > **** > FILES macros.o test1.o > ********************************************************************** > **** > > Build now reports the following error: ********************************************************************** > **** > Executing: "E:\Program Files\MPLAB > IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F84A > "test1.asm" /l"test1.lst" /e"test1.err" /o"test1.o" > Executing: "E:\Program Files\MPLAB > IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F84A > "MACROS.ASM" /l"MACROS.lst" /e"MACROS.err" /o"MACROS.o" > Executing: "E:\Program Files\MPLAB > IDE\MCHIP_Tools\mplink.exe" "test1.lkr" > "E:\PIC\test1.o" "E:\PIC\MACROS.o" /o"test1.cof" > MPLINK 3.30, Linker > Copyright (c) 2003 Microchip Technology Inc. > Error - section '.cinit' can not fit the section. Section '.cinit' > length=0x00000004 > Errors : 1 > BUILD FAILED > ********************************************************************** > **** |
|
|
|
Thanks to "rtstofer" for both replies. I' going to try out your suggestions. Thanks again for all the excellent help! Regards, Steve --- In , "rtstofer" <rstofer@p...> wrote: > > Hello again! > > Put 'select' as an instruction before the first 'case' statement and > put 'endselect' as as instruction after the last 'endcase' > statement. Also, change the file name to Macros.inc and change the > include statement to match. You do NOT want to assemble separately > the macro library as it contains only definitions. No code is > emitted until the macro is envoked (or expanded if you will). > > Lacking the documentation make the library hard to use. If you see > these kinds of errors, look at the variable that was undefined and > see where the macro library was emitting that code (the line number > in the error message). Then wander around and find out why. > Documentation would be better. > > One thing to look at - the comment on the 'movf PORTA,0' is incorrect > because you are moving the entire 8 bit PORTA byte to W. More > serious, using 0 instead of W for the destination makes the > instruction hard to read. Both W and F are defined in the 16F84a > include file - you don't need to define them. > > I haven't played with this particular macro library but when I saw it > a while back I thought it was rather well done. Enjoy! > > --- In , "stephendbarnes" > <stephendbarnes@h...> wrote: > > Hello all, > > I have been attempting to make use of Karl Lunt's PIC Macros with > no > > success > > during the build phase. I have followed his instructions and > emailed > > him for > > help with no response. I'm using MPLab 6.20 and writing some test > > code for > > the 16F84A. The > > following text describes my code and the errors upon build. Could > > anyone > > take a look and see if you could provide some insight? Thanks in > > advance for > > any help. > > > > Regards, > > Stephen D. Barnes > > > > My code follows: > > > > > ********************************************************************** > > *** > > ERRORLEVEL -224 ; suppress message because of tris > > ERRORLEVEL -302 ; suppress message because of page > > change > > > > list p=16F84A ; list directive to define > > processor > > #include <p16F84A.inc> ; processor specific variable > > definitions > > #include ".\macros.asm" > > > > __CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC > > > > ; '__CONFIG' directive is used to embed configuration data > > within .asm file. > > ; The lables following the directive are located in the > > respective .inc > > file. > > ; See respective data sheet for additional information on > > configuration > > word. > > > > > > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; > ;; > > ;;;;;; > > ;;;;;;;;;;;;;;;;; > > ORG 0x000 ; processor reset vector > > goto Main ; go to beginning of program > > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; > ;; > > ;;;;;; > > ;;;;;;;;;;;;;;;;; > > > > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; > ;; > > ;;;;;; > > ;;;;;;;;;;;;;;;;; > > Main: > > clrf PORTB ; PORTB all outputs cleared > > bsf STATUS,5 ; Switch to Register Bank 1 for TRIS > > movlw B'11111111' ; all bits high in W > > movwf TRISA ; contents of W copied to TRISA > (PORTA > > all > > inputs) > > movlw B'00000000' ; all bits low in W > > movwf TRISB ; contents of W copied to TRISB > (PORTB > > all > > outputs) > > movlw 0 ; 0 in W > > movwf OPTION_REG ; contents of W copied to OPTION_REG > (Port > > B > > pullups > > enabled) > > bcf STATUS,5 ; Switch back to Register Bank 0 > > > > movf PORTA ,0 ; move PORTA bit 0 to W register > > > > case 3 > > call Reverse > > endcase > > > > case 2 > > call Left > > endcase > > > > case 1 > > call Right > > endcase > > > > Reverse: > > return > > Left: > > return > > Right: > > return > > > > end > > > ********************************************************************** > > *** > > > > When I build I get the following error: > > > > > ********************************************************************** > > **** > > Executing: "E:\Program Files\MPLAB > > IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F84A > > "test1.asm" /l"test1.lst" /e"test1.err" /o"test1.o" > > Executing: "E:\Program Files\MPLAB > > IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F84A > > "MACROS.ASM" /l"MACROS.lst" /e"MACROS.err" /o"MACROS.o" > > Skipping link step. The project contains no linker script. > > BUILD FAILED > > > ********************************************************************** > > **** > > > > Soooo... I created a linker script conforming to MPASM spec which > > reads as > > follows and is part of the MPLab project: > > > > > ********************************************************************** > > **** > > FILES macros.o test1.o > > > ********************************************************************** > > **** > > > > Build now reports the following error: > > > > > ********************************************************************** > > **** > > Executing: "E:\Program Files\MPLAB > > IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F84A > > "test1.asm" /l"test1.lst" /e"test1.err" /o"test1.o" > > Executing: "E:\Program Files\MPLAB > > IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F84A > > "MACROS.ASM" /l"MACROS.lst" /e"MACROS.err" /o"MACROS.o" > > Executing: "E:\Program Files\MPLAB > > IDE\MCHIP_Tools\mplink.exe" "test1.lkr" > > "E:\PIC\test1.o" "E:\PIC\MACROS.o" /o"test1.cof" > > MPLINK 3.30, Linker > > Copyright (c) 2003 Microchip Technology Inc. > > Error - section '.cinit' can not fit the section. Section '.cinit' > > length=0x00000004 > > Errors : 1 > > BUILD FAILED > > > ********************************************************************** > > **** |
|
I'm back! Tried out your suggestions and it compiled with no errors, BUT, when I attempt to debug using MPLab SIM I get no colored pointer next to the line numbers and "step into" does not appear to work. Is this because of the inclusion of the macros? Also, the compiled hex file is only six bytes. Any clues or should I just abandon the macros and bite the bullet and learn to hard code this stuff? Regards, Steve --- In , "rtstofer" <rstofer@p...> wrote: > > Another 'readability' issue - you might think about using BANKSEL > TRISA instead of BSF STATUS,5. Then you can change to bank 0 for > PORTA by BANKSEL PORTA instead of BCF STATUS,5. > > See the help file but the short answer is that you can move quickly > to the bank of ANY variable and you don't have to remember where you > put it. Maybe not much of a problem with the 16F84a but the 16F877 > has a 4 banks to contend with. > --- In , "stephendbarnes" > <stephendbarnes@h...> wrote: > > Hello all, > > I have been attempting to make use of Karl Lunt's PIC Macros with > no > > success > > during the build phase. I have followed his instructions and > emailed > > him for > > help with no response. I'm using MPLab 6.20 and writing some test > > code for > > the 16F84A. The > > following text describes my code and the errors upon build. Could > > anyone > > take a look and see if you could provide some insight? Thanks in > > advance for > > any help. > > > > Regards, > > Stephen D. Barnes > > > > My code follows: > > > > > ********************************************************************** > > *** > > ERRORLEVEL -224 ; suppress message because of tris > > ERRORLEVEL -302 ; suppress message because of page > > change > > > > list p=16F84A ; list directive to define > > processor > > #include <p16F84A.inc> ; processor specific variable > > definitions > > #include ".\macros.asm" > > > > __CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC > > > > ; '__CONFIG' directive is used to embed configuration data > > within .asm file. > > ; The lables following the directive are located in the > > respective .inc > > file. > > ; See respective data sheet for additional information on > > configuration > > word. > > > > > > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; > ;; > > ;;;;;; > > ;;;;;;;;;;;;;;;;; > > ORG 0x000 ; processor reset vector > > goto Main ; go to beginning of program > > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; > ;; > > ;;;;;; > > ;;;;;;;;;;;;;;;;; > > > > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; > ;; > > ;;;;;; > > ;;;;;;;;;;;;;;;;; > > Main: > > clrf PORTB ; PORTB all outputs cleared > > bsf STATUS,5 ; Switch to Register Bank 1 for TRIS > > movlw B'11111111' ; all bits high in W > > movwf TRISA ; contents of W copied to TRISA > (PORTA > > all > > inputs) > > movlw B'00000000' ; all bits low in W > > movwf TRISB ; contents of W copied to TRISB > (PORTB > > all > > outputs) > > movlw 0 ; 0 in W > > movwf OPTION_REG ; contents of W copied to OPTION_REG > (Port > > B > > pullups > > enabled) > > bcf STATUS,5 ; Switch back to Register Bank 0 > > > > movf PORTA ,0 ; move PORTA bit 0 to W register > > > > case 3 > > call Reverse > > endcase > > > > case 2 > > call Left > > endcase > > > > case 1 > > call Right > > endcase > > > > Reverse: > > return > > Left: > > return > > Right: > > return > > > > end > > > ********************************************************************** > > *** > > > > When I build I get the following error: > > > > > ********************************************************************** > > **** > > Executing: "E:\Program Files\MPLAB > > IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F84A > > "test1.asm" /l"test1.lst" /e"test1.err" /o"test1.o" > > Executing: "E:\Program Files\MPLAB > > IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F84A > > "MACROS.ASM" /l"MACROS.lst" /e"MACROS.err" /o"MACROS.o" > > Skipping link step. The project contains no linker script. > > BUILD FAILED > > > ********************************************************************** > > **** > > > > Soooo... I created a linker script conforming to MPASM spec which > > reads as > > follows and is part of the MPLab project: > > > > > ********************************************************************** > > **** > > FILES macros.o test1.o > > > ********************************************************************** > > **** > > > > Build now reports the following error: > > > > > ********************************************************************** > > **** > > Executing: "E:\Program Files\MPLAB > > IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F84A > > "test1.asm" /l"test1.lst" /e"test1.err" /o"test1.o" > > Executing: "E:\Program Files\MPLAB > > IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F84A > > "MACROS.ASM" /l"MACROS.lst" /e"MACROS.err" /o"MACROS.o" > > Executing: "E:\Program Files\MPLAB > > IDE\MCHIP_Tools\mplink.exe" "test1.lkr" > > "E:\PIC\test1.o" "E:\PIC\MACROS.o" /o"test1.cof" > > MPLINK 3.30, Linker > > Copyright (c) 2003 Microchip Technology Inc. > > Error - section '.cinit' can not fit the section. Section '.cinit' > > length=0x00000004 > > Errors : 1 > > BUILD FAILED > > > ********************************************************************** > > **** |
|
|
|
No, don't give up on the concept of macros although the NEXTF macro is incorrect. Doesn't matter, you're not using it. But it shows that you can't trust anybody's code - and particularly not mine. When I assemble the code I get a map at the end of the .lst file that shows 38 words used and an additional 'x' where the status word is programmed. You show see this as well. The list file is 900 lines long! Probably should do a NOLIST before the '#include <macros.inc> and a LIST after it. This will cut the listing down to about 260 lines - but the map is the same. One thing I did (although it doesn't matter) is to move the .inc file to the same directory as the other 'includes' "C:\Program Files\MPLAB IDE\MCHIP_Tools". Are you using MPLAB IDE 6.10.0.0 or later? If so, I would expect your list file to be on the order of 900 lines with 38 words emitted. On my machine I can definitely step through the code include walking through the macros as they are expanded. Step by step perfectly. Of course after the endselect macro the code 'falls' into reverse, executes a return to nowhere and starts over again a Main. You should probably put a label ahead of the 'select' and a 'goto MyNewLabel just after the 'endselect' Don't know what else to say, it works over here! --- In , "stephendbarnes" <stephendbarnes@h...> wrote: > I'm back! Tried out your suggestions and it compiled with no errors, > BUT, when I attempt to debug using MPLab SIM I get no colored pointer > next to the line numbers and "step into" does not appear to work. Is > this because of the inclusion of the macros? Also, the compiled hex > file is only six bytes. Any clues or should I just abandon the macros > and bite the bullet and learn to hard code this stuff? > > Regards, > Steve > > --- In , "rtstofer" <rstofer@p...> wrote: > > > > Another 'readability' issue - you might think about using BANKSEL > > TRISA instead of BSF STATUS,5. Then you can change to bank 0 for > > PORTA by BANKSEL PORTA instead of BCF STATUS,5. > > > > See the help file but the short answer is that you can move quickly > > to the bank of ANY variable and you don't have to remember where > you > > put it. Maybe not much of a problem with the 16F84a but the 16F877 > > has a 4 banks to contend with. > > > > > > --- In , "stephendbarnes" > > <stephendbarnes@h...> wrote: > > > Hello all, > > > I have been attempting to make use of Karl Lunt's PIC Macros with > > no > > > success > > > during the build phase. I have followed his instructions and > > emailed > > > him for > > > help with no response. I'm using MPLab 6.20 and writing some test > > > code for > > > the 16F84A. The > > > following text describes my code and the errors upon build. Could > > > anyone > > > take a look and see if you could provide some insight? Thanks in > > > advance for > > > any help. > > > > > > Regards, > > > Stephen D. Barnes > > > > > > My code follows: > > > > > > > > > ********************************************************************** > > > *** > > > ERRORLEVEL -224 ; suppress message because of tris > > > ERRORLEVEL -302 ; suppress message because of > page > > > change > > > > > > list p=16F84A ; list directive to > define > > > processor > > > #include <p16F84A.inc> ; processor specific variable > > > definitions > > > #include ".\macros.asm" > > > > > > __CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC > > > > > > ; '__CONFIG' directive is used to embed configuration data > > > within .asm file. > > > ; The lables following the directive are located in the > > > respective .inc > > > file. > > > ; See respective data sheet for additional information on > > > configuration > > > word. > > > > > > > > > > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; > > ;; > > > ;;;;;; > > > ;;;;;;;;;;;;;;;;; > > > ORG 0x000 ; processor reset vector > > > goto Main ; go to beginning of program > > > > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; > > ;; > > > ;;;;;; > > > ;;;;;;;;;;;;;;;;; > > > > > > > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; > > ;; > > > ;;;;;; > > > ;;;;;;;;;;;;;;;;; > > > Main: > > > clrf PORTB ; PORTB all outputs cleared > > > bsf STATUS,5 ; Switch to Register Bank 1 for TRIS > > > movlw B'11111111' ; all bits high in W > > > movwf TRISA ; contents of W copied to TRISA > > (PORTA > > > all > > > inputs) > > > movlw B'00000000' ; all bits low in W > > > movwf TRISB ; contents of W copied to TRISB > > (PORTB > > > all > > > outputs) > > > movlw 0 ; 0 in W > > > movwf OPTION_REG ; contents of W copied to OPTION_REG > > (Port > > > B > > > pullups > > > enabled) > > > bcf STATUS,5 ; Switch back to Register Bank 0 > > > > > > movf PORTA ,0 ; move PORTA bit 0 to W register > > > > > > case 3 > > > call Reverse > > > endcase > > > > > > case 2 > > > call Left > > > endcase > > > > > > case 1 > > > call Right > > > endcase > > > > > > Reverse: > > > return > > > Left: > > > return > > > Right: > > > return > > > > > > end > > > > > > ********************************************************************** > > > *** > > > > > > When I build I get the following error: > > > > > > > > > ********************************************************************** > > > **** > > > Executing: "E:\Program Files\MPLAB > > > IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F84A > > > "test1.asm" /l"test1.lst" /e"test1.err" /o"test1.o" > > > Executing: "E:\Program Files\MPLAB > > > IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F84A > > > "MACROS.ASM" /l"MACROS.lst" /e"MACROS.err" /o"MACROS.o" > > > Skipping link step. The project contains no linker script. > > > BUILD FAILED > > > > > > ********************************************************************** > > > **** > > > > > > Soooo... I created a linker script conforming to MPASM spec which > > > reads as > > > follows and is part of the MPLab project: > > > > > > > > > ********************************************************************** > > > **** > > > FILES macros.o test1.o > > > > > > ********************************************************************** > > > **** > > > > > > Build now reports the following error: > > > > > > > > > ********************************************************************** > > > **** > > > Executing: "E:\Program Files\MPLAB > > > IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F84A > > > "test1.asm" /l"test1.lst" /e"test1.err" /o"test1.o" > > > Executing: "E:\Program Files\MPLAB > > > IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F84A > > > "MACROS.ASM" /l"MACROS.lst" /e"MACROS.err" /o"MACROS.o" > > > Executing: "E:\Program Files\MPLAB > > > IDE\MCHIP_Tools\mplink.exe" "test1.lkr" > > > "E:\PIC\test1.o" "E:\PIC\MACROS.o" /o"test1.cof" > > > MPLINK 3.30, Linker > > > Copyright (c) 2003 Microchip Technology Inc. > > > Error - section '.cinit' can not fit the section. Section '.cinit' > > > length=0x00000004 > > > Errors : 1 > > > BUILD FAILED > > > > > > ********************************************************************** > > > **** |
|
Also, as a programming issue, the select statement will execute the 'default' statements (those between the last endcase and the endselect) if the value in W is not one of the tested cases. This might be ok - you don't have any default statements. But you might want to force W to have only those bits under consideration: ..MOVF PORTA,W ..ANDLW B'00000011' ; look at bits 0..1 only ..select ....case 0 ......call something ....endcase .... ....case 1 ......call something_else ....endcase .... ....case 2 ......call something ....endcase .... ....case 3 ......; ignore this case ....endcase ..endselect Here every potential value has been handled - no possibility of input without matching code. Just being pedantic - I hate it when I do that! --- In , "stephendbarnes" <stephendbarnes@h...> wrote: > I'm back! Tried out your suggestions and it compiled with no errors, > BUT, when I attempt to debug using MPLab SIM I get no colored pointer > next to the line numbers and "step into" does not appear to work. Is > this because of the inclusion of the macros? Also, the compiled hex > file is only six bytes. Any clues or should I just abandon the macros > and bite the bullet and learn to hard code this stuff? > > Regards, > Steve > > --- In , "rtstofer" <rstofer@p...> wrote: > > > > Another 'readability' issue - you might think about using BANKSEL > > TRISA instead of BSF STATUS,5. Then you can change to bank 0 for > > PORTA by BANKSEL PORTA instead of BCF STATUS,5. > > > > See the help file but the short answer is that you can move quickly > > to the bank of ANY variable and you don't have to remember where > you > > put it. Maybe not much of a problem with the 16F84a but the 16F877 > > has a 4 banks to contend with. > > > > > > --- In , "stephendbarnes" > > <stephendbarnes@h...> wrote: > > > Hello all, > > > I have been attempting to make use of Karl Lunt's PIC Macros with > > no > > > success > > > during the build phase. I have followed his instructions and > > emailed > > > him for > > > help with no response. I'm using MPLab 6.20 and writing some test > > > code for > > > the 16F84A. The > > > following text describes my code and the errors upon build. Could > > > anyone > > > take a look and see if you could provide some insight? Thanks in > > > advance for > > > any help. > > > > > > Regards, > > > Stephen D. Barnes > > > > > > My code follows: > > > > > > > > > ********************************************************************** > > > *** > > > ERRORLEVEL -224 ; suppress message because of tris > > > ERRORLEVEL -302 ; suppress message because of > page > > > change > > > > > > list p=16F84A ; list directive to > define > > > processor > > > #include <p16F84A.inc> ; processor specific variable > > > definitions > > > #include ".\macros.asm" > > > > > > __CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC > > > > > > ; '__CONFIG' directive is used to embed configuration data > > > within .asm file. > > > ; The lables following the directive are located in the > > > respective .inc > > > file. > > > ; See respective data sheet for additional information on > > > configuration > > > word. > > > > > > > > > > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; > > ;; > > > ;;;;;; > > > ;;;;;;;;;;;;;;;;; > > > ORG 0x000 ; processor reset vector > > > goto Main ; go to beginning of program > > > > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; > > ;; > > > ;;;;;; > > > ;;;;;;;;;;;;;;;;; > > > > > > > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; > > ;; > > > ;;;;;; > > > ;;;;;;;;;;;;;;;;; > > > Main: > > > clrf PORTB ; PORTB all outputs cleared > > > bsf STATUS,5 ; Switch to Register Bank 1 for TRIS > > > movlw B'11111111' ; all bits high in W > > > movwf TRISA ; contents of W copied to TRISA > > (PORTA > > > all > > > inputs) > > > movlw B'00000000' ; all bits low in W > > > movwf TRISB ; contents of W copied to TRISB > > (PORTB > > > all > > > outputs) > > > movlw 0 ; 0 in W > > > movwf OPTION_REG ; contents of W copied to OPTION_REG > > (Port > > > B > > > pullups > > > enabled) > > > bcf STATUS,5 ; Switch back to Register Bank 0 > > > > > > movf PORTA ,0 ; move PORTA bit 0 to W register > > > > > > case 3 > > > call Reverse > > > endcase > > > > > > case 2 > > > call Left > > > endcase > > > > > > case 1 > > > call Right > > > endcase > > > > > > Reverse: > > > return > > > Left: > > > return > > > Right: > > > return > > > > > > end > > > > > > ********************************************************************** > > > *** > > > > > > When I build I get the following error: > > > > > > > > > ********************************************************************** > > > **** > > > Executing: "E:\Program Files\MPLAB > > > IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F84A > > > "test1.asm" /l"test1.lst" /e"test1.err" /o"test1.o" > > > Executing: "E:\Program Files\MPLAB > > > IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F84A > > > "MACROS.ASM" /l"MACROS.lst" /e"MACROS.err" /o"MACROS.o" > > > Skipping link step. The project contains no linker script. > > > BUILD FAILED > > > > > > ********************************************************************** > > > **** > > > > > > Soooo... I created a linker script conforming to MPASM spec which > > > reads as > > > follows and is part of the MPLab project: > > > > > > > > > ********************************************************************** > > > **** > > > FILES macros.o test1.o > > > > > > ********************************************************************** > > > **** > > > > > > Build now reports the following error: > > > > > > > > > ********************************************************************** > > > **** > > > Executing: "E:\Program Files\MPLAB > > > IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F84A > > > "test1.asm" /l"test1.lst" /e"test1.err" /o"test1.o" > > > Executing: "E:\Program Files\MPLAB > > > IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F84A > > > "MACROS.ASM" /l"MACROS.lst" /e"MACROS.err" /o"MACROS.o" > > > Executing: "E:\Program Files\MPLAB > > > IDE\MCHIP_Tools\mplink.exe" "test1.lkr" > > > "E:\PIC\test1.o" "E:\PIC\MACROS.o" /o"test1.cof" > > > MPLINK 3.30, Linker > > > Copyright (c) 2003 Microchip Technology Inc. > > > Error - section '.cinit' can not fit the section. Section '.cinit' > > > length=0x00000004 > > > Errors : 1 > > > BUILD FAILED > > > > > > ********************************************************************** > > > **** |
|
|
|
I am
doing an AD measurement and I need to display it correctly. For that to happen, I
think I need a constant voltage. For example, if I am using Vref as the 5 V Vdd, and
Vdd drops, then my measurement will be wrong. The voltage I am measuring is coming
from an off-board sensor.
I have
added a voltage regulator so that I have a constant 5 volts, and will run it on batteries
of more than 5 volts. But I would like to shutdown completely rather than display
wrong results. I could measure the regulated volts, but since that would be
referenced to Vdd, it wouldn't help.
Does
anyone have a suggestion on how to do this?
Bruce Partridge |
|
|
|
OOPS! Of course the new label in my prior message goes ahead of the MOVF PORTA,W. Comes from typing without thinking. --- In , "stephendbarnes" <stephendbarnes@h...> wrote: > Hello all, > I have been attempting to make use of Karl Lunt's PIC Macros with no > success > during the build phase. I have followed his instructions and emailed > him for > help with no response. I'm using MPLab 6.20 and writing some test > code for > the 16F84A. The > following text describes my code and the errors upon build. Could > anyone > take a look and see if you could provide some insight? Thanks in > advance for > any help. > > Regards, > Stephen D. Barnes > > My code follows: ********************************************************************** > *** > ERRORLEVEL -224 ; suppress message because of tris > ERRORLEVEL -302 ; suppress message because of page > change > > list p=16F84A ; list directive to define > processor > #include <p16F84A.inc> ; processor specific variable > definitions > #include ".\macros.asm" > > __CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC > > ; '__CONFIG' directive is used to embed configuration data > within .asm file. > ; The lables following the directive are located in the > respective .inc > file. > ; See respective data sheet for additional information on > configuration > word. > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; > ;;;;;; > ;;;;;;;;;;;;;;;;; > ORG 0x000 ; processor reset vector > goto Main ; go to beginning of program > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; > ;;;;;; > ;;;;;;;;;;;;;;;;; > > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; > ;;;;;; > ;;;;;;;;;;;;;;;;; > Main: > clrf PORTB ; PORTB all outputs cleared > bsf STATUS,5 ; Switch to Register Bank 1 for TRIS > movlw B'11111111' ; all bits high in W > movwf TRISA ; contents of W copied to TRISA (PORTA > all > inputs) > movlw B'00000000' ; all bits low in W > movwf TRISB ; contents of W copied to TRISB (PORTB > all > outputs) > movlw 0 ; 0 in W > movwf OPTION_REG ; contents of W copied to OPTION_REG (Port > B > pullups > enabled) > bcf STATUS,5 ; Switch back to Register Bank 0 > > movf PORTA ,0 ; move PORTA bit 0 to W register > > case 3 > call Reverse > endcase > > case 2 > call Left > endcase > > case 1 > call Right > endcase > > Reverse: > return > Left: > return > Right: > return > > end > ********************************************************************** > *** > > When I build I get the following error: ********************************************************************** > **** > Executing: "E:\Program Files\MPLAB > IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F84A > "test1.asm" /l"test1.lst" /e"test1.err" /o"test1.o" > Executing: "E:\Program Files\MPLAB > IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F84A > "MACROS.ASM" /l"MACROS.lst" /e"MACROS.err" /o"MACROS.o" > Skipping link step. The project contains no linker script. > BUILD FAILED > ********************************************************************** > **** > > Soooo... I created a linker script conforming to MPASM spec which > reads as > follows and is part of the MPLab project: ********************************************************************** > **** > FILES macros.o test1.o > ********************************************************************** > **** > > Build now reports the following error: ********************************************************************** > **** > Executing: "E:\Program Files\MPLAB > IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F84A > "test1.asm" /l"test1.lst" /e"test1.err" /o"test1.o" > Executing: "E:\Program Files\MPLAB > IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F84A > "MACROS.ASM" /l"MACROS.lst" /e"MACROS.err" /o"MACROS.o" > Executing: "E:\Program Files\MPLAB > IDE\MCHIP_Tools\mplink.exe" "test1.lkr" > "E:\PIC\test1.o" "E:\PIC\MACROS.o" /o"test1.cof" > MPLINK 3.30, Linker > Copyright (c) 2003 Microchip Technology Inc. > Error - section '.cinit' can not fit the section. Section '.cinit' > length=0x00000004 > Errors : 1 > BUILD FAILED > ********************************************************************** > **** |
|
|
|
There are a ton of precision voltage reference devices available. Maybe if you picked one the held +2.5V you could check to see if the A/D got the right answer. Among many other places, check www.maxim-ic.com/References.cfm. Note that there is also an application guide on using precision references. Good luck! --- In , Bruce Partridge <bgpartri@c...> wrote: > I am doing an AD measurement and I need to display it correctly. For that > to happen, I think I need a constant voltage. For example, if I am using > Vref as the 5 V Vdd, and Vdd drops, then my measurement will be wrong. The > voltage I am measuring is coming from an off-board sensor. > > I have added a voltage regulator so that I have a constant 5 volts, and will > run it on batteries of more than 5 volts. But I would like to shutdown > completely rather than display wrong results. I could measure the regulated > volts, but since that would be referenced to Vdd, it wouldn't help. > > Does anyone have a suggestion on how to do this? > > Bruce Partridge > http://www.rebreather.ca > Vancouver, Canada > > --- > Outgoing mail is certified Virus Free. > Checked by AVG anti-virus system (http://www.grisoft.com). > Version: 6.0.465 / Virus Database: 263 - Release Date: 3/25/2003 |
|
I think I see what is happening but I don't know what to do about it. The compiler is actually not looking at my code at all! When it gets to the "#include macros.inc" it compiles the macros and skips the rest of my source! If you would like to see the .lst I'll post it for you to look at. Thanks again for your help. Regards, Steve --- In , "rtstofer" <rstofer@p...> wrote: > > OOPS! Of course the new label in my prior message goes ahead of the > MOVF PORTA,W. Comes from typing without thinking. > > --- In , "stephendbarnes" > <stephendbarnes@h...> wrote: > > Hello all, > > I have been attempting to make use of Karl Lunt's PIC Macros with > no > > success > > during the build phase. I have followed his instructions and > emailed > > him for > > help with no response. I'm using MPLab 6.20 and writing some test > > code for > > the 16F84A. The > > following text describes my code and the errors upon build. Could > > anyone > > take a look and see if you could provide some insight? Thanks in > > advance for > > any help. > > > > Regards, > > Stephen D. Barnes > > > > My code follows: > > > > > ********************************************************************** > > *** > > ERRORLEVEL -224 ; suppress message because of tris > > ERRORLEVEL -302 ; suppress message because of page > > change > > > > list p=16F84A ; list directive to define > > processor > > #include <p16F84A.inc> ; processor specific variable > > definitions > > #include ".\macros.asm" > > > > __CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC > > > > ; '__CONFIG' directive is used to embed configuration data > > within .asm file. > > ; The lables following the directive are located in the > > respective .inc > > file. > > ; See respective data sheet for additional information on > > configuration > > word. > > > > > > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; > ;; > > ;;;;;; > > ;;;;;;;;;;;;;;;;; > > ORG 0x000 ; processor reset vector > > goto Main ; go to beginning of program > > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; > ;; > > ;;;;;; > > ;;;;;;;;;;;;;;;;; > > > > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; > ;; > > ;;;;;; > > ;;;;;;;;;;;;;;;;; > > Main: > > clrf PORTB ; PORTB all outputs cleared > > bsf STATUS,5 ; Switch to Register Bank 1 for TRIS > > movlw B'11111111' ; all bits high in W > > movwf TRISA ; contents of W copied to TRISA > (PORTA > > all > > inputs) > > movlw B'00000000' ; all bits low in W > > movwf TRISB ; contents of W copied to TRISB > (PORTB > > all > > outputs) > > movlw 0 ; 0 in W > > movwf OPTION_REG ; contents of W copied to OPTION_REG > (Port > > B > > pullups > > enabled) > > bcf STATUS,5 ; Switch back to Register Bank 0 > > > > movf PORTA ,0 ; move PORTA bit 0 to W register > > > > case 3 > > call Reverse > > endcase > > > > case 2 > > call Left > > endcase > > > > case 1 > > call Right > > endcase > > > > Reverse: > > return > > Left: > > return > > Right: > > return > > > > end > > > ********************************************************************** > > *** > > > > When I build I get the following error: > > > > > ********************************************************************** > > **** > > Executing: "E:\Program Files\MPLAB > > IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F84A > > "test1.asm" /l"test1.lst" /e"test1.err" /o"test1.o" > > Executing: "E:\Program Files\MPLAB > > IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F84A > > "MACROS.ASM" /l"MACROS.lst" /e"MACROS.err" /o"MACROS.o" > > Skipping link step. The project contains no linker script. > > BUILD FAILED > > > ********************************************************************** > > **** > > > > Soooo... I created a linker script conforming to MPASM spec which > > reads as > > follows and is part of the MPLab project: > > > > > ********************************************************************** > > **** > > FILES macros.o test1.o > > > ********************************************************************** > > **** > > > > Build now reports the following error: > > > > > ********************************************************************** > > **** > > Executing: "E:\Program Files\MPLAB > > IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F84A > > "test1.asm" /l"test1.lst" /e"test1.err" /o"test1.o" > > Executing: "E:\Program Files\MPLAB > > IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F84A > > "MACROS.ASM" /l"MACROS.lst" /e"MACROS.err" /o"MACROS.o" > > Executing: "E:\Program Files\MPLAB > > IDE\MCHIP_Tools\mplink.exe" "test1.lkr" > > "E:\PIC\test1.o" "E:\PIC\MACROS.o" /o"test1.cof" > > MPLINK 3.30, Linker > > Copyright (c) 2003 Microchip Technology Inc. > > Error - section '.cinit' can not fit the section. Section '.cinit' > > length=0x00000004 > > Errors : 1 > > BUILD FAILED > > > ********************************************************************** > > **** |
|
|
|
I finally figured out how to attach a zip file - I have to send it by email to from my registered mail account. I can't do it from work so I will post it tonight. I have a zip file with the .asm, .inc and related project files - known to work. Just extract to c:\test\ and open the project in MPASM IDE. I tried to create the failure you are having and can't seem to duplicate it. Once we are both working from the same files maybe it will become clear. --- In , "stephendbarnes" <stephendbarnes@h...> wrote: > I think I see what is happening but I don't know what to do about it. > The compiler is actually not looking at my code at all! When it gets > to the "#include macros.inc" it compiles the macros and skips the > rest of my source! If you would like to see the .lst I'll post it for > you to look at. Thanks again for your help. > > Regards, > Steve > > --- In , "rtstofer" <rstofer@p...> wrote: > > > > OOPS! Of course the new label in my prior message goes ahead of the > > MOVF PORTA,W. Comes from typing without thinking. > > > > --- In , "stephendbarnes" > > <stephendbarnes@h...> wrote: > > > Hello all, > > > I have been attempting to make use of Karl Lunt's PIC Macros with > > no > > > success > > > during the build phase. I have followed his instructions and > > emailed > > > him for > > > help with no response. I'm using MPLab 6.20 and writing some test > > > code for > > > the 16F84A. The > > > following text describes my code and the errors upon build. Could > > > anyone > > > take a look and see if you could provide some insight? Thanks in > > > advance for > > > any help. > > > > > > Regards, > > > Stephen D. Barnes > > > > > > My code follows: > > > > > > > > > ********************************************************************** > > > *** > > > ERRORLEVEL -224 ; suppress message because of tris > > > ERRORLEVEL -302 ; suppress message because of > page > > > change > > > > > > list p=16F84A ; list directive to > define > > > processor > > > #include <p16F84A.inc> ; processor specific variable > > > definitions > > > #include ".\macros.asm" > > > > > > __CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC > > > > > > ; '__CONFIG' directive is used to embed configuration data > > > within .asm file. > > > ; The lables following the directive are located in the > > > respective .inc > > > file. > > > ; See respective data sheet for additional information on > > > configuration > > > word. > > > > > > > > > > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; > > ;; > > > ;;;;;; > > > ;;;;;;;;;;;;;;;;; > > > ORG 0x000 ; processor reset vector > > > goto Main ; go to beginning of program > > > > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; > > ;; > > > ;;;;;; > > > ;;;;;;;;;;;;;;;;; > > > > > > > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; > > ;; > > > ;;;;;; > > > ;;;;;;;;;;;;;;;;; > > > Main: > > > clrf PORTB ; PORTB all outputs cleared > > > bsf STATUS,5 ; Switch to Register Bank 1 for TRIS > > > movlw B'11111111' ; all bits high in W > > > movwf TRISA ; contents of W copied to TRISA > > (PORTA > > > all > > > inputs) > > > movlw B'00000000' ; all bits low in W > > > movwf TRISB ; contents of W copied to TRISB > > (PORTB > > > all > > > outputs) > > > movlw 0 ; 0 in W > > > movwf OPTION_REG ; contents of W copied to OPTION_REG > > (Port > > > B > > > pullups > > > enabled) > > > bcf STATUS,5 ; Switch back to Register Bank 0 > > > > > > movf PORTA ,0 ; move PORTA bit 0 to W register > > > > > > case 3 > > > call Reverse > > > endcase > > > > > > case 2 > > > call Left > > > endcase > > > > > > case 1 > > > call Right > > > endcase > > > > > > Reverse: > > > return > > > Left: > > > return > > > Right: > > > return > > > > > > end > > > > > > ********************************************************************** > > > *** > > > > > > When I build I get the following error: > > > > > > > > > ********************************************************************** > > > **** > > > Executing: "E:\Program Files\MPLAB > > > IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F84A > > > "test1.asm" /l"test1.lst" /e"test1.err" /o"test1.o" > > > Executing: "E:\Program Files\MPLAB > > > IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F84A > > > "MACROS.ASM" /l"MACROS.lst" /e"MACROS.err" /o"MACROS.o" > > > Skipping link step. The project contains no linker script. > > > BUILD FAILED > > > > > > ********************************************************************** > > > **** > > > > > > Soooo... I created a linker script conforming to MPASM spec which > > > reads as > > > follows and is part of the MPLab project: > > > > > > > > > ********************************************************************** > > > **** > > > FILES macros.o test1.o > > > > > > ********************************************************************** > > > **** > > > > > > Build now reports the following error: > > > > > > > > > ********************************************************************** > > > **** > > > Executing: "E:\Program Files\MPLAB > > > IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F84A > > > "test1.asm" /l"test1.lst" /e"test1.err" /o"test1.o" > > > Executing: "E:\Program Files\MPLAB > > > IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F84A > > > "MACROS.ASM" /l"MACROS.lst" /e"MACROS.err" /o"MACROS.o" > > > Executing: "E:\Program Files\MPLAB > > > IDE\MCHIP_Tools\mplink.exe" "test1.lkr" > > > "E:\PIC\test1.o" "E:\PIC\MACROS.o" /o"test1.cof" > > > MPLINK 3.30, Linker > > > Copyright (c) 2003 Microchip Technology Inc. > > > Error - section '.cinit' can not fit the section. Section '.cinit' > > > length=0x00000004 > > > Errors : 1 > > > BUILD FAILED > > > > > > ********************************************************************** > > > **** |
|
|
|
Thank you. I have made a little progress. I found that the compiler was only compiling the macros.inc file and stopping there! I'm new to this and your comments about the .lst file made me go look at it! WOW. It reported 0 program words used! Looking at the list I saw that none of my code was present. The problem seemed to be that Karl Lunt's macro file has the compiler directive "end" at the end. I assume that this was causing the compiler to stop dead in its tracks. I removed the "end" directive from the macro file and it compiled and simulates. I do have a problem with the thing constantly going to the first case "case 3" and ignoring the other two regardless of the value W. I'll be looking forward to seeing your code. I will try debugging this myself without yelling for help at every turn (jump in with both feet and only yell when drowning!). You have been, and are being, an enormous help. Thanks again. Regards, Steve --- In , "rtstofer" <rstofer@p...> wrote: > I finally figured out how to attach a zip file - I have to send it by > email to from my registered mail account. I > can't do it from work so I will post it tonight. > > I have a zip file with the .asm, .inc and related project files - > known to work. Just extract to c:\test\ and open the project in > MPASM IDE. > > I tried to create the failure you are having and can't seem to > duplicate it. Once we are both working from the same files maybe it > will become clear. > --- In , "stephendbarnes" > <stephendbarnes@h...> wrote: > > I think I see what is happening but I don't know what to do about > it. > > The compiler is actually not looking at my code at all! When it > gets > > to the "#include macros.inc" it compiles the macros and skips the > > rest of my source! If you would like to see the .lst I'll post it > for > > you to look at. Thanks again for your help. > > > > Regards, > > Steve > > > > --- In , "rtstofer" <rstofer@p...> wrote: > > > > > > OOPS! Of course the new label in my prior message goes ahead of > the > > > MOVF PORTA,W. Comes from typing without thinking. > > > > > > --- In , "stephendbarnes" > > > <stephendbarnes@h...> wrote: > > > > Hello all, > > > > I have been attempting to make use of Karl Lunt's PIC Macros > with > > > no > > > > success > > > > during the build phase. I have followed his instructions and > > > emailed > > > > him for > > > > help with no response. I'm using MPLab 6.20 and writing some > test > > > > code for > > > > the 16F84A. The > > > > following text describes my code and the errors upon build. > Could > > > > anyone > > > > take a look and see if you could provide some insight? Thanks > in > > > > advance for > > > > any help. > > > > > > > > Regards, > > > > Stephen D. Barnes > > > > > > > > My code follows: > > > > > > > > > > > > > > ********************************************************************** > > > > *** > > > > ERRORLEVEL -224 ; suppress message because of > tris > > > > ERRORLEVEL -302 ; suppress message because of > > page > > > > change > > > > > > > > list p=16F84A ; list directive to > > define > > > > processor > > > > #include <p16F84A.inc> ; processor specific variable > > > > definitions > > > > #include ".\macros.asm" > > > > > > > > __CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC > > > > > > > > ; '__CONFIG' directive is used to embed configuration data > > > > within .asm file. > > > > ; The lables following the directive are located in the > > > > respective .inc > > > > file. > > > > ; See respective data sheet for additional information on > > > > configuration > > > > word. > > > > > > > > > > > > > > > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; > > > ;; > > > > ;;;;;; > > > > ;;;;;;;;;;;;;;;;; > > > > ORG 0x000 ; processor reset vector > > > > goto Main ; go to beginning of program > > > > > > > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; > > > ;; > > > > ;;;;;; > > > > ;;;;;;;;;;;;;;;;; > > > > > > > > > > > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; > > > ;; > > > > ;;;;;; > > > > ;;;;;;;;;;;;;;;;; > > > > Main: > > > > clrf PORTB ; PORTB all outputs cleared > > > > bsf STATUS,5 ; Switch to Register Bank 1 for TRIS > > > > movlw B'11111111' ; all bits high in W > > > > movwf TRISA ; contents of W copied to TRISA > > > (PORTA > > > > all > > > > inputs) > > > > movlw B'00000000' ; all bits low in W > > > > movwf TRISB ; contents of W copied to TRISB > > > (PORTB > > > > all > > > > outputs) > > > > movlw 0 ; 0 in W > > > > movwf OPTION_REG ; contents of W copied to OPTION_REG > > > (Port > > > > B > > > > pullups > > > > enabled) > > > > bcf STATUS,5 ; Switch back to Register Bank 0 > > > > > > > > movf PORTA ,0 ; move PORTA bit 0 to W register > > > > > > > > case 3 > > > > call Reverse > > > > endcase > > > > > > > > case 2 > > > > call Left > > > > endcase > > > > > > > > case 1 > > > > call Right > > > > endcase > > > > > > > > Reverse: > > > > return > > > > Left: > > > > return > > > > Right: > > > > return > > > > > > > > end > > > > > > > > > > ********************************************************************** > > > > *** > > > > > > > > When I build I get the following error: > > > > > > > > > > > > > > ********************************************************************** > > > > **** > > > > Executing: "E:\Program Files\MPLAB > > > > IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F84A > > > > "test1.asm" /l"test1.lst" /e"test1.err" /o"test1.o" > > > > Executing: "E:\Program Files\MPLAB > > > > IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F84A > > > > "MACROS.ASM" /l"MACROS.lst" /e"MACROS.err" /o"MACROS.o" > > > > Skipping link step. The project contains no linker script. > > > > BUILD FAILED > > > > > > > > > > ********************************************************************** > > > > **** > > > > > > > > Soooo... I created a linker script conforming to MPASM spec > which > > > > reads as > > > > follows and is part of the MPLab project: > > > > > > > > > > > > > > ********************************************************************** > > > > **** > > > > FILES macros.o test1.o > > > > > > > > > > ********************************************************************** > > > > **** > > > > > > > > Build now reports the following error: > > > > > > > > > > > > > > ********************************************************************** > > > > **** > > > > Executing: "E:\Program Files\MPLAB > > > > IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F84A > > > > "test1.asm" /l"test1.lst" /e"test1.err" /o"test1.o" > > > > Executing: "E:\Program Files\MPLAB > > > > IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F84A > > > > "MACROS.ASM" /l"MACROS.lst" /e"MACROS.err" /o"MACROS.o" > > > > Executing: "E:\Program Files\MPLAB > > > > IDE\MCHIP_Tools\mplink.exe" "test1.lkr" > > > > "E:\PIC\test1.o" "E:\PIC\MACROS.o" /o"test1.cof" > > > > MPLINK 3.30, Linker > > > > Copyright (c) 2003 Microchip Technology Inc. > > > > Error - section '.cinit' can not fit the section. > Section '.cinit' > > > > length=0x00000004 > > > > Errors : 1 > > > > BUILD FAILED > > > > > > > > > > ********************************************************************** > > > > **** |
|
|
|
We must have gotten different versions of the macros. Mine did not have an 'end' statement but I was beginning to suspect that yours did. That would be about the only reason for the assembler to stop early. I am not sure why your code would execute any case. In my version of SIM without a stimulus file the value of PORTA is always 0. This should not execute any case and if you have placed a goto loop statement following endselect you should not fall into the reverse subroutine. The label 'loop' should be before the movwf PORTA,W An easy way to trace this code is to put a movlw 3 (or something) immediately after the movwf PORTA,W. This will load W with a matching value for one of the various cases. I would still mask off the unused bits and change the select and case statements as discussed previously. --- In , "stephendbarnes" <stephendbarnes@h...> wrote: > Thank you. I have made a little progress. I found that the compiler > was only compiling the macros.inc file and stopping there! I'm new to > this and your comments about the .lst file made me go look at it! > WOW. It reported 0 program words used! Looking at the list I saw that > none of my code was present. The problem seemed to be that Karl > Lunt's macro file has the compiler directive "end" at the end. I > assume that this was causing the compiler to stop dead in its tracks. > I removed the "end" directive from the macro file and it compiled and > simulates. I do have a problem with the thing constantly going to the > first case "case 3" and ignoring the other two regardless of the > value W. I'll be looking forward to seeing your code. I will try > debugging this myself without yelling for help at every turn (jump in > with both feet and only yell when drowning!). You have been, and are > being, an enormous help. Thanks again. > > Regards, > Steve > > --- In , "rtstofer" <rstofer@p...> wrote: > > I finally figured out how to attach a zip file - I have to send it > by > > email to from my registered mail account. > I > > can't do it from work so I will post it tonight. > > > > I have a zip file with the .asm, .inc and related project files - > > known to work. Just extract to c:\test\ and open the project in > > MPASM IDE. > > > > I tried to create the failure you are having and can't seem to > > duplicate it. Once we are both working from the same files maybe > it > > will become clear. > > > > > > --- In , "stephendbarnes" > > <stephendbarnes@h...> wrote: > > > I think I see what is happening but I don't know what to do about > > it. > > > The compiler is actually not looking at my code at all! When it > > gets > > > to the "#include macros.inc" it compiles the macros and skips the > > > rest of my source! If you would like to see the .lst I'll post it > > for > > > you to look at. Thanks again for your help. > > > > > > Regards, > > > Steve > > > > > > --- In , "rtstofer" <rstofer@p...> wrote: > > > > > > > > OOPS! Of course the new label in my prior message goes ahead of > > the > > > > MOVF PORTA,W. Comes from typing without thinking. > > > > > > > > --- In , "stephendbarnes" > > > > <stephendbarnes@h...> wrote: > > > > > Hello all, > > > > > I have been attempting to make use of Karl Lunt's PIC Macros > > with > > > > no > > > > > success > > > > > during the build phase. I have followed his instructions and > > > > emailed > > > > > him for > > > > > help with no response. I'm using MPLab 6.20 and writing some > > test > > > > > code for > > > > > the 16F84A. The > > > > > following text describes my code and the errors upon build. > > Could > > > > > anyone > > > > > take a look and see if you could provide some insight? Thanks > > in > > > > > advance for > > > > > any help. > > > > > > > > > > Regards, > > > > > Stephen D. Barnes > > > > > > > > > > My code follows: > > > > > > > > > > > > > > > > > > > > ********************************************************************** > > > > > *** > > > > > ERRORLEVEL -224 ; suppress message because of > > tris > > > > > ERRORLEVEL -302 ; suppress message because of > > > page > > > > > change > > > > > > > > > > list p=16F84A ; list directive to > > > define > > > > > processor > > > > > #include <p16F84A.inc> ; processor specific > variable > > > > > definitions > > > > > #include ".\macros.asm" > > > > > > > > > > __CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC > > > > > > > > > > ; '__CONFIG' directive is used to embed configuration data > > > > > within .asm file. > > > > > ; The lables following the directive are located in the > > > > > respective .inc > > > > > file. > > > > > ; See respective data sheet for additional information on > > > > > configuration > > > > > word. > > > > > > > > > > > > > > > > > > > > > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; > > > > ;; > > > > > ;;;;;; > > > > > ;;;;;;;;;;;;;;;;; > > > > > ORG 0x000 ; processor reset vector > > > > > goto Main ; go to beginning of program > > > > > > > > > > > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; > > > > ;; > > > > > ;;;;;; > > > > > ;;;;;;;;;;;;;;;;; > > > > > > > > > > > > > > > > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; > > > > ;; > > > > > ;;;;;; > > > > > ;;;;;;;;;;;;;;;;; > > > > > Main: > > > > > clrf PORTB ; PORTB all outputs cleared > > > > > bsf STATUS,5 ; Switch to Register Bank 1 for TRIS > > > > > movlw B'11111111' ; all bits high in W > > > > > movwf TRISA ; contents of W copied to > TRISA > > > > (PORTA > > > > > all > > > > > inputs) > > > > > movlw B'00000000' ; all bits low in W > > > > > movwf TRISB ; contents of W copied to > TRISB > > > > (PORTB > > > > > all > > > > > outputs) > > > > > movlw 0 ; 0 in W > > > > > movwf OPTION_REG ; contents of W copied to > OPTION_REG > > > > (Port > > > > > B > > > > > > pullups > > > > > enabled) > > > > > bcf STATUS,5 ; Switch back to Register Bank 0 > > > > > > > > > > movf PORTA ,0 ; move PORTA bit 0 to W register > > > > > > > > > > case 3 > > > > > call Reverse > > > > > endcase > > > > > > > > > > case 2 > > > > > call Left > > > > > endcase > > > > > > > > > > case 1 > > > > > call Right > > > > > endcase > > > > > > > > > > Reverse: > > > > > return > > > > > Left: > > > > > return > > > > > Right: > > > > > return > > > > > > > > > > end > > > > > > > > > > > > > > > ********************************************************************** > > > > > *** > > > > > > > > > > When I build I get the following error: > > > > > > > > > > > > > > > > > > > > ********************************************************************** > > > > > **** > > > > > Executing: "E:\Program Files\MPLAB > > > > > IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F84A > > > > > "test1.asm" /l"test1.lst" /e"test1.err" /o"test1.o" > > > > > Executing: "E:\Program Files\MPLAB > > > > > IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F84A > > > > > "MACROS.ASM" /l"MACROS.lst" /e"MACROS.err" /o"MACROS.o" > > > > > Skipping link step. The project contains no linker script. > > > > > BUILD FAILED > > > > > > > > > > > > > > > ********************************************************************** > > > > > **** > > > > > > > > > > Soooo... I created a linker script conforming to MPASM spec > > which > > > > > reads as > > > > > follows and is part of the MPLab project: > > > > > > > > > > > > > > > > > > > > ********************************************************************** > > > > > **** > > > > > FILES macros.o test1.o > > > > > > > > > > > > > > > ********************************************************************** > > > > > **** > > > > > > > > > > Build now reports the following error: > > > > > > > > > > > > > > > > > > > > ********************************************************************** > > > > > **** > > > > > Executing: "E:\Program Files\MPLAB > > > > > IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F84A > > > > > "test1.asm" /l"test1.lst" /e"test1.err" /o"test1.o" > > > > > Executing: "E:\Program Files\MPLAB > > > > > IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F84A > > > > > "MACROS.ASM" /l"MACROS.lst" /e"MACROS.err" /o"MACROS.o" > > > > > Executing: "E:\Program Files\MPLAB > > > > > IDE\MCHIP_Tools\mplink.exe" "test1.lkr" > > > > > "E:\PIC\test1.o" "E:\PIC\MACROS.o" /o"test1.cof" > > > > > MPLINK 3.30, Linker > > > > > Copyright (c) 2003 Microchip Technology Inc. > > > > > Error - section '.cinit' can not fit the section. > > Section '.cinit' > > > > > length=0x00000004 > > > > > Errors : 1 > > > > > BUILD FAILED > > > > > > > > > > > > > > > ********************************************************************** > > > > > **** |
|
|
|
Just to check the version of the macros, look at nextf and it should look like this (after I revised it): nextf...macro..var,incf _nxtknt.set...._nxtknt-1 ........movf...incf,w..; the code was incorrect here ........addwf..var,f...; leave the result in var, not incf ........goto..._for#v(_nxtknt) _next#v(_nxtknt) ........endm --- In , "rtstofer" <rstofer@p...> wrote: > > We must have gotten different versions of the macros. Mine did not > have an 'end' statement but I was beginning to suspect that yours > did. That would be about the only reason for the assembler to stop > early. > > I am not sure why your code would execute any case. In my version of > SIM without a stimulus file the value of PORTA is always 0. This > should not execute any case and if you have placed a goto loop > statement following endselect you should not fall into the reverse > subroutine. The label 'loop' should be before the movwf PORTA,W > > An easy way to trace this code is to put a movlw 3 (or something) > immediately after the movwf PORTA,W. This will load W with a > matching value for one of the various cases. I would still mask off > the unused bits and change the select and case statements as > discussed previously. > > --- In , "stephendbarnes" > <stephendbarnes@h...> wrote: > > Thank you. I have made a little progress. I found that the compiler > > was only compiling the macros.inc file and stopping there! I'm new > to > > this and your comments about the .lst file made me go look at it! > > WOW. It reported 0 program words used! Looking at the list I saw > that > > none of my code was present. The problem seemed to be that Karl > > Lunt's macro file has the compiler directive "end" at the end. I > > assume that this was causing the compiler to stop dead in its > tracks. > > I removed the "end" directive from the macro file and it compiled > and > > simulates. I do have a problem with the thing constantly going to > the > > first case "case 3" and ignoring the other two regardless of the > > value W. I'll be looking forward to seeing your code. I will try > > debugging this myself without yelling for help at every turn (jump > in > > with both feet and only yell when drowning!). You have been, and > are > > being, an enormous help. Thanks again. > > > > Regards, > > Steve > > > > --- In , "rtstofer" <rstofer@p...> wrote: > > > I finally figured out how to attach a zip file - I have to send > it > > by > > > email to from my registered mail > account. > > I > > > can't do it from work so I will post it tonight. > > > > > > I have a zip file with the .asm, .inc and related project files - > > > known to work. Just extract to c:\test\ and open the project in > > > MPASM IDE. > > > > > > I tried to create the failure you are having and can't seem to > > > duplicate it. Once we are both working from the same files maybe > > it > > > will become clear. > > > > > > > > > --- In , "stephendbarnes" > > > <stephendbarnes@h...> wrote: > > > > I think I see what is happening but I don't know what to do > about > > > it. > > > > The compiler is actually not looking at my code at all! When it > > > gets > > > > to the "#include macros.inc" it compiles the macros and skips > the > > > > rest of my source! If you would like to see the .lst I'll post > it > > > for > > > > you to look at. Thanks again for your help. > > > > > > > > Regards, > > > > Steve > > > > > > > > --- In , "rtstofer" <rstofer@p...> wrote: > > > > > > > > > > OOPS! Of course the new label in my prior message goes ahead > of > > > the > > > > > MOVF PORTA,W. Comes from typing without thinking. > > > > > > > > > > --- In , "stephendbarnes" > > > > > <stephendbarnes@h...> wrote: > > > > > > Hello all, > > > > > > I have been attempting to make use of Karl Lunt's PIC > Macros > > > with > > > > > no > > > > > > success > > > > > > during the build phase. I have followed his instructions > and > > > > > emailed > > > > > > him for > > > > > > help with no response. I'm using MPLab 6.20 and writing > some > > > test > > > > > > code for > > > > > > the 16F84A. The > > > > > > following text describes my code and the errors upon build. > > > Could > > > > > > anyone > > > > > > take a look and see if you could provide some insight? > Thanks > > > in > > > > > > advance for > > > > > > any help. > > > > > > > > > > > > Regards, > > > > > > Stephen D. Barnes > > > > > > > > > > > > My code follows: > > > > > > > > > > > > > > > > > > > > > > > > > > > ********************************************************************** > > > > > > *** > > > > > > ERRORLEVEL -224 ; suppress message because > of > > > tris > > > > > > ERRORLEVEL -302 ; suppress message because > of > > > > page > > > > > > change > > > > > > > > > > > > list p=16F84A ; list directive > to > > > > define > > > > > > processor > > > > > > #include <p16F84A.inc> ; processor specific > > variable > > > > > > definitions > > > > > > #include ".\macros.asm" > > > > > > > > > > > > __CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC > > > > > > > > > > > > ; '__CONFIG' directive is used to embed configuration data > > > > > > within .asm file. > > > > > > ; The lables following the directive are located in the > > > > > > respective .inc > > > > > > file. > > > > > > ; See respective data sheet for additional information on > > > > > > configuration > > > > > > word. > > > > > > > > > > > > > > > > > > > > > > > > > > > > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; > > > > > ;; > > > > > > ;;;;;; > > > > > > ;;;;;;;;;;;;;;;;; > > > > > > ORG 0x000 ; processor reset vector > > > > > > goto Main ; go to beginning of program > > > > > > > > > > > > > > > > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; > > > > > ;; > > > > > > ;;;;;; > > > > > > ;;;;;;;;;;;;;;;;; > > > > > > > > > > > > > > > > > > > > > > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; > > > > > ;; > > > > > > ;;;;;; > > > > > > ;;;;;;;;;;;;;;;;; > > > > > > Main: > > > > > > clrf PORTB ; PORTB all outputs cleared > > > > > > bsf STATUS,5 ; Switch to Register Bank 1 for TRIS > > > > > > movlw B'11111111' ; all bits high in W > > > > > > movwf TRISA ; contents of W copied to > > TRISA > > > > > (PORTA > > > > > > all > > > > > > inputs) > > > > > > movlw B'00000000' ; all bits low in W > > > > > > movwf TRISB ; contents of W copied to > > TRISB > > > > > (PORTB > > > > > > all > > > > > > outputs) > > > > > > movlw 0 ; 0 in W > > > > > > movwf OPTION_REG ; contents of W copied to > > OPTION_REG > > > > > (Port > > > > > > B > > > > > > > > pullups > > > > > > enabled) > > > > > > bcf STATUS,5 ; Switch back to Register Bank 0 > > > > > > > > > > > > movf PORTA ,0 ; move PORTA bit 0 to W register > > > > > > > > > > > > case 3 > > > > > > call Reverse > > > > > > endcase > > > > > > > > > > > > case 2 > > > > > > call Left > > > > > > endcase > > > > > > > > > > > > case 1 > > > > > > call Right > > > > > > endcase > > > > > > > > > > > > Reverse: > > > > > > return > > > > > > Left: > > > > > > return > > > > > > Right: > > > > > > return > > > > > > > > > > > > end > > > > > > > > > > > > > > > > > > > > > ********************************************************************** > > > > > > *** > > > > > > > > > > > > When I build I get the following error: > > > > > > > > > > > > > > > > > > > > > > > > > > > ********************************************************************** > > > > > > **** > > > > > > Executing: "E:\Program Files\MPLAB > > > > > > IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F84A > > > > > > "test1.asm" /l"test1.lst" /e"test1.err" /o"test1.o" > > > > > > Executing: "E:\Program Files\MPLAB > > > > > > IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F84A > > > > > > "MACROS.ASM" /l"MACROS.lst" /e"MACROS.err" /o"MACROS.o" > > > > > > Skipping link step. The project contains no linker script. > > > > > > BUILD FAILED > > > > > > > > > > > > > > > > > > > > > ********************************************************************** > > > > > > **** > > > > > > > > > > > > Soooo... I created a linker script conforming to MPASM spec > > > which > > > > > > reads as > > > > > > follows and is part of the MPLab project: > > > > > > > > > > > > > > > > > > > > > > > > > > > ********************************************************************** > > > > > > **** > > > > > > FILES macros.o test1.o > > > > > > > > > > > > > > > > > > > > > ********************************************************************** > > > > > > **** > > > > > > > > > > > > Build now reports the following error: > > > > > > > > > > > > > > > > > > > > > > > > > > > ********************************************************************** > > > > > > **** > > > > > > Executing: "E:\Program Files\MPLAB > > > > > > IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F84A > > > > > > "test1.asm" /l"test1.lst" /e"test1.err" /o"test1.o" > > > > > > Executing: "E:\Program Files\MPLAB > > > > > > IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F84A > > > > > > "MACROS.ASM" /l"MACROS.lst" /e"MACROS.err" /o"MACROS.o" > > > > > > Executing: "E:\Program Files\MPLAB > > > > > > IDE\MCHIP_Tools\mplink.exe" "test1.lkr" > > > > > > "E:\PIC\test1.o" "E:\PIC\MACROS.o" /o"test1.cof" > > > > > > MPLINK 3.30, Linker > > > > > > Copyright (c) 2003 Microchip Technology Inc. > > > > > > Error - section '.cinit' can not fit the section. > > > Section '.cinit' > > > > > > length=0x00000004 > > > > > > Errors : 1 > > > > > > BUILD FAILED > > > > > > > > > > > > > > > > > > > > > ********************************************************************** > > > > > > **** |
|
|
|
Mine looks like this: nextf...macro...var,incf _nxtknt.set....._nxtknt-1 ........movf....var,w ........addwf...incf,f ........goto...._for#v(_nxtknt) _next#v(_nxtknt) ........endm --- In , "rtstofer" <rstofer@p...> wrote: > > Just to check the version of the macros, look at nextf and it should > look like this (after I revised it): > > nextf...macro..var,incf > _nxtknt.set...._nxtknt-1 > ........movf...incf,w..; the code was incorrect here > ........addwf..var,f...; leave the result in var, not incf > ........goto..._for#v(_nxtknt) > _next#v(_nxtknt) > ........endm > > --- In , "rtstofer" <rstofer@p...> wrote: > > > > We must have gotten different versions of the macros. Mine did not > > have an 'end' statement but I was beginning to suspect that yours > > did. That would be about the only reason for the assembler to stop > > early. > > > > I am not sure why your code would execute any case. In my version > of > > SIM without a stimulus file the value of PORTA is always 0. This > > should not execute any case and if you have placed a goto loop > > statement following endselect you should not fall into the reverse > > subroutine. The label 'loop' should be before the movwf PORTA,W > > > > An easy way to trace this code is to put a movlw 3 (or something) > > immediately after the movwf PORTA,W. This will load W with a > > matching value for one of the various cases. I would still mask > off > > the unused bits and change the select and case statements as > > discussed previously. > > > > --- In , "stephendbarnes" > > <stephendbarnes@h...> wrote: > > > Thank you. I have made a little progress. I found that the > compiler > > > was only compiling the macros.inc file and stopping there! I'm > new > > to > > > this and your comments about the .lst file made me go look at it! > > > WOW. It reported 0 program words used! Looking at the list I saw > > that > > > none of my code was present. The problem seemed to be that Karl > > > Lunt's macro file has the compiler directive "end" at the end. I > > > assume that this was causing the compiler to stop dead in its > > tracks. > > > I removed the "end" directive from the macro file and it compiled > > and > > > simulates. I do have a problem with the thing constantly going to > > the > > > first case "case 3" and ignoring the other two regardless of the > > > value W. I'll be looking forward to seeing your code. I will try > > > debugging this myself without yelling for help at every turn > (jump > > in > > > with both feet and only yell when drowning!). You have been, and > > are > > > being, an enormous help. Thanks again. > > > > > > Regards, > > > Steve > > > > > > --- In , "rtstofer" <rstofer@p...> wrote: > > > > I finally figured out how to attach a zip file - I have to send > > it > > > by > > > > email to from my registered mail > > account. > > > I > > > > can't do it from work so I will post it tonight. > > > > > > > > I have a zip file with the .asm, .inc and related project > files - > > > > known to work. Just extract to c:\test\ and open the project > in > > > > MPASM IDE. > > > > > > > > I tried to create the failure you are having and can't seem to > > > > duplicate it. Once we are both working from the same files > maybe > > > it > > > > will become clear. > > > > > > > > > > > > --- In , "stephendbarnes" > > > > <stephendbarnes@h...> wrote: > > > > > I think I see what is happening but I don't know what to do > > about > > > > it. > > > > > The compiler is actually not looking at my code at all! When > it > > > > gets > > > > > to the "#include macros.inc" it compiles the macros and skips > > the > > > > > rest of my source! If you would like to see the .lst I'll > post > > it > > > > for > > > > > you to look at. Thanks again for your help. > > > > > > > > > > Regards, > > > > > Steve > > > > > > > > > > --- In , "rtstofer" <rstofer@p...> > wrote: > > > > > > > > > > > > OOPS! Of course the new label in my prior message goes > ahead > > of > > > > the > > > > > > MOVF PORTA,W. Comes from typing without thinking. > > > > > > > > > > > > --- In , "stephendbarnes" > > > > > > <stephendbarnes@h...> wrote: > > > > > > > Hello all, > > > > > > > I have been attempting to make use of Karl Lunt's PIC > > Macros > > > > with > > > > > > no > > > > > > > success > > > > > > > during the build phase. I have followed his instructions > > and > > > > > > emailed > > > > > > > him for > > > > > > > help with no response. I'm using MPLab 6.20 and writing > > some > > > > test > > > > > > > code for > > > > > > > the 16F84A. The > > > > > > > following text describes my code and the errors upon > build. > > > > Could > > > > > > > anyone > > > > > > > take a look and see if you could provide some insight? > > Thanks > > > > in > > > > > > > advance for > > > > > > > any help. > > > > > > > > > > > > > > Regards, > > > > > > > Stephen D. Barnes > > > > > > > > > > > > > > My code follows: > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > ********************************************************************** > > > > > > > *** > > > > > > > ERRORLEVEL -224 ; suppress message > because > > of > > > > tris > > > > > > > ERRORLEVEL -302 ; suppress message > because > > of > > > > > page > > > > > > > change > > > > > > > > > > > > > > list p=16F84A ; list > directive > > to > > > > > define > > > > > > > processor > > > > > > > #include <p16F84A.inc> ; processor specific > > > variable > > > > > > > definitions > > > > > > > #include ".\macros.asm" > > > > > > > > > > > > > > __CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC > > > > > > > > > > > > > > ; '__CONFIG' directive is used to embed configuration > data > > > > > > > within .asm file. > > > > > > > ; The lables following the directive are located in the > > > > > > > respective .inc > > > > > > > file. > > > > > > > ; See respective data sheet for additional information on > > > > > > > configuration > > > > > > > word. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; > > > > > > ;; > > > > > > > ;;;;;; > > > > > > > ;;;;;;;;;;;;;;;;; > > > > > > > ORG 0x000 ; processor reset vector > > > > > > > goto Main ; go to beginning of program > > > > > > > > > > > > > > > > > > > > > > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; > > > > > > ;; > > > > > > > ;;;;;; > > > > > > > ;;;;;;;;;;;;;;;;; > > > > > > > > > > > > > > > > > > > > > > > > > > > > > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; > > > > > > ;; > > > > > > > ;;;;;; > > > > > > > ;;;;;;;;;;;;;;;;; > > > > > > > Main: > > > > > > > clrf PORTB ; PORTB all outputs cleared > > > > > > > bsf STATUS,5 ; Switch to Register Bank 1 for > TRIS > > > > > > > movlw B'11111111' ; all bits high in W > > > > > > > movwf TRISA ; contents of W copied to > > > TRISA > > > > > > (PORTA > > > > > > > all > > > > > > > inputs) > > > > > > > movlw B'00000000' ; all bits low in W > > > > > > > movwf TRISB ; contents of W copied to > > > TRISB > > > > > > (PORTB > > > > > > > all > > > > > > > outputs) > > > > > > > movlw 0 ; 0 in W > > > > > > > movwf OPTION_REG ; contents of W copied to > > > OPTION_REG > > > > > > (Port > > > > > > > B > > > > > > > > > > pullups > > > > > > > enabled) > > > > > > > bcf STATUS,5 ; Switch back to Register Bank 0 > > > > > > > > > > > > > > movf PORTA ,0 ; move PORTA bit 0 to W register > > > > > > > > > > > > > > case 3 > > > > > > > call Reverse > > > > > > > endcase > > > > > > > > > > > > > > case 2 > > > > > > > call Left > > > > > > > endcase > > > > > > > > > > > > > > case 1 > > > > > > > call Right > > > > > > > endcase > > > > > > > > > > > > > > Reverse: > > > > > > > return > > > > > > > Left: > > > > > > > return > > > > > > > Right: > > > > > > > return > > > > > > > > > > > > > > end > > > > > > > > > > > > > > > > > > > > > > > > > > > > ********************************************************************** > > > > > > > *** > > > > > > > > > > > > > > When I build I get the following error: > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > ********************************************************************** > > > > > > > **** > > > > > > > Executing: "E:\Program Files\MPLAB > > > > > > > IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F84A > > > > > > > "test1.asm" /l"test1.lst" /e"test1.err" /o"test1.o" > > > > > > > Executing: "E:\Program Files\MPLAB > > > > > > > IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F84A > > > > > > > "MACROS.ASM" /l"MACROS.lst" /e"MACROS.err" /o"MACROS.o" > > > > > > > Skipping link step. The project contains no linker > script. > > > > > > > BUILD FAILED > > > > > > > > > > > > > > > > > > > > > > > > > > > > ********************************************************************** > > > > > > > **** > > > > > > > > > > > > > > Soooo... I created a linker script conforming to MPASM > spec > > > > which > > > > > > > reads as > > > > > > > follows and is part of the MPLab project: > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > ********************************************************************** > > > > > > > **** > > > > > > > FILES macros.o test1.o > > > > > > > > > > > > > > > > > > > > > > > > > > > > ********************************************************************** > > > > > > > **** > > > > > > > > > > > > > > Build now reports the following error: > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > ********************************************************************** > > > > > > > **** > > > > > > > Executing: "E:\Program Files\MPLAB > > > > > > > IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F84A > > > > > > > "test1.asm" /l"test1.lst" /e"test1.err" /o"test1.o" > > > > > > > Executing: "E:\Program Files\MPLAB > > > > > > > IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F84A > > > > > > > "MACROS.ASM" /l"MACROS.lst" /e"MACROS.err" /o"MACROS.o" > > > > > > > Executing: "E:\Program Files\MPLAB > > > > > > > IDE\MCHIP_Tools\mplink.exe" "test1.lkr" > > > > > > > "E:\PIC\test1.o" "E:\PIC\MACROS.o" /o"test1.cof" > > > > > > > MPLINK 3.30, Linker > > > > > > > Copyright (c) 2003 Microchip Technology Inc. > > > > > > > Error - section '.cinit' can not fit the section. > > > > Section '.cinit' > > > > > > > length=0x00000004 > > > > > > > Errors : 1 > > > > > > > BUILD FAILED > > > > > > > > > > > > > > > > > > > > > > > > > > > > ********************************************************************** > > > > > > > **** |
|
|
|
This will be a problem. The code is loading the loop variable 'var' into W and then adding 'incf' and leaving the result in 'incf'. It needs to be stored in 'var' as in my previous post. At some point you may want to correct your version. Maybe write a small program and test that it works. --- In , "stephendbarnes" <stephendbarnes@h...> wrote: > Mine looks like this: > > nextf...macro...var,incf > _nxtknt.set....._nxtknt-1 > ........movf....var,w > ........addwf...incf,f > ........goto...._for#v(_nxtknt) > _next#v(_nxtknt) > ........endm > > --- In , "rtstofer" <rstofer@p...> wrote: > > > > Just to check the version of the macros, look at nextf and it > should > > look like this (after I revised it): > > > > nextf...macro..var,incf > > _nxtknt.set...._nxtknt-1 > > ........movf...incf,w..; the code was incorrect here > > ........addwf..var,f...; leave the result in var, not incf > > ........goto..._for#v(_nxtknt) > > _next#v(_nxtknt) > > ........endm > > > > --- In , "rtstofer" <rstofer@p...> wrote: > > > > > > We must have gotten different versions of the macros. Mine did > not > > > have an 'end' statement but I was beginning to suspect that yours > > > did. That would be about the only reason for the assembler to > stop > > > early. > > > > > > I am not sure why your code would execute any case. In my > version > > of > > > SIM without a stimulus file the value of PORTA is always 0. This > > > should not execute any case and if you have placed a goto loop > > > statement following endselect you should not fall into the > reverse > > > subroutine. The label 'loop' should be before the movwf PORTA,W > > > > > > An easy way to trace this code is to put a movlw 3 (or something) > > > immediately after the movwf PORTA,W. This will load W with a > > > matching value for one of the various cases. I would still mask > > off > > > the unused bits and change the select and case statements as > > > discussed previously. > > > > > > --- In , "stephendbarnes" > > > <stephendbarnes@h...> wrote: > > > > Thank you. I have made a little progress. I found that the > > compiler > > > > was only compiling the macros.inc file and stopping there! I'm > > new > > > to > > > > this and your comments about the .lst file made me go look at > it! > > > > WOW. It reported 0 program words used! Looking at the list I > saw > > > that > > > > none of my code was present. The problem seemed to be that Karl > > > > Lunt's macro file has the compiler directive "end" at the end. > I > > > > assume that this was causing the compiler to stop dead in its > > > tracks. > > > > I removed the "end" directive from the macro file and it > compiled > > > and > > > > simulates. I do have a problem with the thing constantly going > to > > > the > > > > first case "case 3" and ignoring the other two regardless of > the > > > > value W. I'll be looking forward to seeing your code. I will > try > > > > debugging this myself without yelling for help at every turn > > (jump > > > in > > > > with both feet and only yell when drowning!). You have been, > and > > > are > > > > being, an enormous help. Thanks again. > > > > > > > > Regards, > > > > Steve > > > > > > > > --- In , "rtstofer" <rstofer@p...> wrote: > > > > > I finally figured out how to attach a zip file - I have to > send > > > it > > > > by > > > > > email to from my registered mail > > > account. > > > > I > > > > > can't do it from work so I will post it tonight. > > > > > > > > > > I have a zip file with the .asm, .inc and related project > > files - > > > > > known to work. Just extract to c:\test\ and open the project > > in > > > > > MPASM IDE. > > > > > > > > > > I tried to create the failure you are having and can't seem > to > > > > > duplicate it. Once we are both working from the same files > > maybe > > > > it > > > > > will become clear. > > > > > > > > > > > > > > > --- In , "stephendbarnes" > > > > > <stephendbarnes@h...> wrote: > > > > > > I think I see what is happening but I don't know what to do > > > about > > > > > it. > > > > > > The compiler is actually not looking at my code at all! > When > > it > > > > > gets > > > > > > to the "#include macros.inc" it compiles the macros and > skips > > > the > > > > > > rest of my source! If you would like to see the .lst I'll > > post > > > it > > > > > for > > > > > > you to look at. Thanks again for your help. > > > > > > > > > > > > Regards, > > > > > > Steve > > > > > > > > > > > > --- In , "rtstofer" <rstofer@p...> > > wrote: > > > > > > > > > > > > > > OOPS! Of course the new label in my prior message goes > > ahead > > > of > > > > > the > > > > > > > MOVF PORTA,W. Comes from typing without thinking. > > > > > > > > > > > > > > --- In , "stephendbarnes" > > > > > > > <stephendbarnes@h...> wrote: > > > > > > > > Hello all, > > > > > > > > I have been attempting to make use of Karl Lunt's PIC > > > Macros > > > > > with > > > > > > > no > > > > > > > > success > > > > > > > > during the build phase. I have followed his > instructions > > > and > > > > > > > emailed > > > > > > > > him for > > > > > > > > help with no response. I'm using MPLab 6.20 and writing > > > some > > > > > test > > > > > > > > code for > > > > > > > > the 16F84A. The > > > > > > > > following text describes my code and the errors upon > > build. > > > > > Could > > > > > > > > anyone > > > > > > > > take a look and see if you could provide some insight? > > > Thanks > > > > > in > > > > > > > > advance for > > > > > > > > any help. > > > > > > > > > > > > > > > > Regards, > > > > > > > > Stephen D. Barnes > > > > > > > > > > > > > > > > My code follows: > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > ********************************************************************** > > > > > > > > *** > > > > > > > > ERRORLEVEL -224 ; suppress message > > because > > > of > > > > > tris > > > > > > > > ERRORLEVEL -302 ; suppress message > > because > > > of > > > > > > page > > > > > > > > change > > > > > > > > > > > > > > > > list p=16F84A ; list > > directive > > > to > > > > > > define > > > > > > > > processor > > > > > > > > #include <p16F84A.inc> ; processor specific > > > > variable > > > > > > > > definitions > > > > > > > > #include ".\macros.asm" > > > > > > > > > > > > > > > > __CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC > > > > > > > > > > > > > > > > ; '__CONFIG' directive is used to embed configuration > > data > > > > > > > > within .asm file. > > > > > > > > ; The lables following the directive are located in the > > > > > > > > respective .inc > > > > > > > > file. > > > > > > > > ; See respective data sheet for additional information > on > > > > > > > > configuration > > > > > > > > word. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; > > > > > > > ;; > > > > > > > > ;;;;;; > > > > > > > > ;;;;;;;;;;;;;;;;; > > > > > > > > ORG 0x000 ; processor reset vector > > > > > > > > goto Main ; go to beginning of program > > > > > > > > > > > > > > > > > > > > > > > > > > > > > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; > > > > > > > ;; > > > > > > > > ;;;;;; > > > > > > > > ;;;;;;;;;;;;;;;;; > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; > > > > > > > ;; > > > > > > > > ;;;;;; > > > > > > > > ;;;;;;;;;;;;;;;;; > > > > > > > > Main: > > > > > > > > clrf PORTB ; PORTB all outputs > cleared > > > > > > > > bsf STATUS,5 ; Switch to Register Bank 1 for > > TRIS > > > > > > > > movlw B'11111111' ; all bits high in W > > > > > > > > movwf TRISA ; contents of W copied > to > > > > TRISA > > > > > > > (PORTA > > > > > > > > all > > > > > > > > inputs) > > > > > > > > movlw B'00000000' ; all bits low in W > > > > > > > > movwf TRISB ; contents of W copied > to > > > > TRISB > > > > > > > (PORTB > > > > > > > > all > > > > > > > > outputs) > > > > > > > > movlw 0 ; 0 in W > > > > > > > > movwf OPTION_REG ; contents of W copied to > > > > OPTION_REG > > > > > > > (Port > > > > > > > > B > > > > > > > > > > > > pullups > > > > > > > > enabled) > > > > > > > > bcf STATUS,5 ; Switch back to Register > Bank 0 > > > > > > > > > > > > > > > > movf PORTA ,0 ; move PORTA bit 0 to W register > > > > > > > > > > > > > > > > case 3 > > > > > > > > call Reverse > > > > > > > > endcase > > > > > > > > > > > > > > > > case 2 > > > > > > > > call Left > > > > > > > > endcase > > > > > > > > > > > > > > > > case 1 > > > > > > > > call Right > > > > > > > > endcase > > > > > > > > > > > > > > > > Reverse: > > > > > > > > return > > > > > > > > Left: > > > > > > > > return > > > > > > > > Right: > > > > > > > > return > > > > > > > > > > > > > > > > end > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > ********************************************************************** > > > > > > > > *** > > > > > > > > > > > > > > > > When I build I get the following error: > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > ********************************************************************** > > > > > > > > **** > > > > > > > > Executing: "E:\Program Files\MPLAB > > > > > > > > IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F84A > > > > > > > > "test1.asm" /l"test1.lst" /e"test1.err" /o"test1.o" > > > > > > > > Executing: "E:\Program Files\MPLAB > > > > > > > > IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F84A > > > > > > > > "MACROS.ASM" /l"MACROS.lst" /e"MACROS.err" /o"MACROS.o" > > > > > > > > Skipping link step. The project contains no linker > > script. > > > > > > > > BUILD FAILED > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > ********************************************************************** > > > > > > > > **** > > > > > > > > > > > > > > > > Soooo... I created a linker script conforming to MPASM > > spec > > > > > which > > > > > > > > reads as > > > > > > > > follows and is part of the MPLab project: > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > ********************************************************************** > > > > > > > > **** > > > > > > > > FILES macros.o test1.o > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > ********************************************************************** > > > > > > > > **** > > > > > > > > > > > > > > > > Build now reports the following error: > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > ********************************************************************** > > > > > > > > **** > > > > > > > > Executing: "E:\Program Files\MPLAB > > > > > > > > IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F84A > > > > > > > > "test1.asm" /l"test1.lst" /e"test1.err" /o"test1.o" > > > > > > > > Executing: "E:\Program Files\MPLAB > > > > > > > > IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F84A > > > > > > > > "MACROS.ASM" /l"MACROS.lst" /e"MACROS.err" /o"MACROS.o" > > > > > > > > Executing: "E:\Program Files\MPLAB > > > > > > > > IDE\MCHIP_Tools\mplink.exe" "test1.lkr" > > > > > > > > "E:\PIC\test1.o" "E:\PIC\MACROS.o" /o"test1.cof" > > > > > > > > MPLINK 3.30, Linker > > > > > > > > Copyright (c) 2003 Microchip Technology Inc. > > > > > > > > Error - section '.cinit' can not fit the section. > > > > > Section '.cinit' > > > > > > > > length=0x00000004 > > > > > > > > Errors : 1 > > > > > > > > BUILD FAILED > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > ********************************************************************** > > > > > > > > **** |
|
|
|
I changed it to match your example and I'm ready to start debugging again! Thanks a million! Regards, Steve --- In , "rtstofer" <rstofer@p...> wrote: > > This will be a problem. The code is loading the loop variable 'var' > into W and then adding 'incf' and leaving the result in 'incf'. It > needs to be stored in 'var' as in my previous post. > > At some point you may want to correct your version. Maybe write a > small program and test that it works. > > --- In , "stephendbarnes" > <stephendbarnes@h...> wrote: > > Mine looks like this: > > > > nextf...macro...var,incf > > _nxtknt.set....._nxtknt-1 > > ........movf....var,w > > ........addwf...incf,f > > ........goto...._for#v(_nxtknt) > > _next#v(_nxtknt) > > ........endm > > > > > > > > --- In , "rtstofer" <rstofer@p...> wrote: > > > > > > Just to check the version of the macros, look at nextf and it > > should > > > look like this (after I revised it): > > > > > > nextf...macro..var,incf > > > _nxtknt.set...._nxtknt-1 > > > ........movf...incf,w..; the code was incorrect here > > > ........addwf..var,f...; leave the result in var, not incf > > > ........goto..._for#v(_nxtknt) > > > _next#v(_nxtknt) > > > ........endm > > > > > > --- In , "rtstofer" <rstofer@p...> wrote: > > > > > > > > We must have gotten different versions of the macros. Mine did > > not > > > > have an 'end' statement but I was beginning to suspect that > yours > > > > did. That would be about the only reason for the assembler to > > stop > > > > early. > > > > > > > > I am not sure why your code would execute any case. In my > > version > > > of > > > > SIM without a stimulus file the value of PORTA is always 0. > This > > > > should not execute any case and if you have placed a goto loop > > > > statement following endselect you should not fall into the > > reverse > > > > subroutine. The label 'loop' should be before the movwf PORTA,W > > > > > > > > An easy way to trace this code is to put a movlw 3 (or > something) > > > > immediately after the movwf PORTA,W. This will load W with a > > > > matching value for one of the various cases. I would still > mask > > > off > > > > the unused bits and change the select and case statements as > > > > discussed previously. > > > > > > > > --- In , "stephendbarnes" > > > > <stephendbarnes@h...> wrote: > > > > > Thank you. I have made a little progress. I found that the > > > compiler > > > > > was only compiling the macros.inc file and stopping there! > I'm > > > new > > > > to > > > > > this and your comments about the .lst file made me go look at > > it! > > > > > WOW. It reported 0 program words used! Looking at the list I > > saw > > > > that > > > > > none of my code was present. The problem seemed to be that > Karl > > > > > Lunt's macro file has the compiler directive "end" at the > end. > > I > > > > > assume that this was causing the compiler to stop dead in its > > > > tracks. > > > > > I removed the "end" directive from the macro file and it > > compiled > > > > and > > > > > simulates. I do have a problem with the thing constantly > going > > to > > > > the > > > > > first case "case 3" and ignoring the other two regardless of > > the > > > > > value W. I'll be looking forward to seeing your code. I will > > try > > > > > debugging this myself without yelling for help at every turn > > > (jump > > > > in > > > > > with both feet and only yell when drowning!). You have been, > > and > > > > are > > > > > being, an enormous help. Thanks again. > > > > > > > > > > Regards, > > > > > Steve > > > > > > > > > > --- In , "rtstofer" <rstofer@p...> > wrote: > > > > > > I finally figured out how to attach a zip file - I have to > > send > > > > it > > > > > by > > > > > > email to from my registered mail > > > > account. > > > > > I > > > > > > can't do it from work so I will post it tonight. > > > > > > > > > > > > I have a zip file with the .asm, .inc and related project > > > files - > > > > > > known to work. Just extract to c:\test\ and open the > project > > > in > > > > > > MPASM IDE. > > > > > > > > > > > > I tried to create the failure you are having and can't seem > > to > > > > > > duplicate it. Once we are both working from the same files > > > maybe > > > > > it > > > > > > will become clear. > > > > > > > > > > > > > > > > > > --- In , "stephendbarnes" > > > > > > <stephendbarnes@h...> wrote: > > > > > > > I think I see what is happening but I don't know what to > do > > > > about > > > > > > it. > > > > > > > The compiler is actually not looking at my code at all! > > When > > > it > > > > > > gets > > > > > > > to the "#include macros.inc" it compiles the macros and > > skips > > > > the > > > > > > > rest of my source! If you would like to see the .lst I'll > > > post > > > > it > > > > > > for > > > > > > > you to look at. Thanks again for your help. > > > > > > > > > > > > > > Regards, > > > > > > > Steve > > > > > > > > > > > > > > --- In , "rtstofer" <rstofer@p...> > > > wrote: > > > > > > > > > > > > > > > > OOPS! Of course the new label in my prior message goes > > > ahead > > > > of > > > > > > the > > > > > > > > MOVF PORTA,W. Comes from typing without thinking. > > > > > > > > > > > > > > > > --- In , "stephendbarnes" > > > > > > > > <stephendbarnes@h...> wrote: > > > > > > > > > Hello all, > > > > > > > > > I have been attempting to make use of Karl Lunt's PIC > > > > Macros > > > > > > with > > > > > > > > no > > > > > > > > > success > > > > > > > > > during the build phase. I have followed his > > instructions > > > > and > > > > > > > > emailed > > > > > > > > > him for > > > > > > > > > help with no response. I'm using MPLab 6.20 and > writing > > > > some > > > > > > test > > > > > > > > > code for > > > > > > > > > the 16F84A. The > > > > > > > > > following text describes my code and the errors upon > > > build. > > > > > > Could > > > > > > > > > anyone > > > > > > > > > take a look and see if you could provide some > insight? > > > > Thanks > > > > > > in > > > > > > > > > advance for > > > > > > > > > any help. > > > > > > > > > > > > > > > > > > Regards, > > > > > > > > > Stephen D. Barnes > > > > > > > > > > > > > > > > > > My code follows: > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > ********************************************************************** > > > > > > > > > *** > > > > > > > > > ERRORLEVEL -224 ; suppress message > > > because > > > > of > > > > > > tris > > > > > > > > > ERRORLEVEL -302 ; suppress message > > > because > > > > of > > > > > > > page > > > > > > > > > change > > > > > > > > > > > > > > > > > > list p=16F84A ; list > > > directive > > > > to > > > > > > > define > > > > > > > > > processor > > > > > > > > > #include <p16F84A.inc> ; processor specific > > > > > variable > > > > > > > > > definitions > > > > > > > > > #include ".\macros.asm" > > > > > > > > > > > > > > > > > > __CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & > _XT_OSC > > > > > > > > > > > > > > > > > > ; '__CONFIG' directive is used to embed configuration > > > data > > > > > > > > > within .asm file. > > > > > > > > > ; The lables following the directive are located in > the > > > > > > > > > respective .inc > > > > > > > > > file. > > > > > > > > > ; See respective data sheet for additional > information > > on > > > > > > > > > configuration > > > > > > > > > word. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; > > > > > > > > ;; > > > > > > > > > ;;;;;; > > > > > > > > > ;;;;;;;;;;;;;;;;; > > > > > > > > > ORG 0x000 ; processor reset vector > > > > > > > > > goto Main ; go to beginning of program > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; > > > > > > > > ;; > > > > > > > > > ;;;;;; > > > > > > > > > ;;;;;;;;;;;;;;;;; > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; > > > > > > > > ;; > > > > > > > > > ;;;;;; > > > > > > > > > ;;;;;;;;;;;;;;;;; > > > > > > > > > Main: > > > > > > > > > clrf PORTB ; PORTB all outputs > > cleared > > > > > > > > > bsf STATUS,5 ; Switch to Register Bank 1 > for > > > TRIS > > > > > > > > > movlw B'11111111' ; all bits high in W > > > > > > > > > movwf TRISA ; contents of W copied > > to > > > > > TRISA > > > > > > > > (PORTA > > > > > > > > > all > > > > > > > > > inputs) > > > > > > > > > movlw B'00000000' ; all bits low in W > > > > > > > > > movwf TRISB ; contents of W copied > > to > > > > > TRISB > > > > > > > > (PORTB > > > > > > > > > all > > > > > > > > > outputs) > > > > > > > > > movlw 0 ; 0 in W > > > > > > > > > movwf OPTION_REG ; contents of W copied to > > > > > OPTION_REG > > > > > > > > (Port > > > > > > > > > B > > > > > > > > > > > > > > > pullups > > > > > > > > > enabled) > > > > > > > > > bcf STATUS,5 ; Switch back to Register > > Bank 0 > > > > > > > > > > > > > > > > > > movf PORTA ,0 ; move PORTA bit 0 to W > register > > > > > > > > > > > > > > > > > > case 3 > > > > > > > > > call Reverse > > > > > > > > > endcase > > > > > > > > > > > > > > > > > > case 2 > > > > > > > > > call Left > > > > > > > > > endcase > > > > > > > > > > > > > > > > > > case 1 > > > > > > > > > call Right > > > > > > > > > endcase > > > > > > > > > > > > > > > > > > Reverse: > > > > > > > > > return > > > > > > > > > Left: > > > > > > > > > return > > > > > > > > > Right: > > > > > > > > > return > > > > > > > > > > > > > > > > > > end > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > ********************************************************************** > > > > > > > > > *** > > > > > > > > > > > > > > > > > > When I build I get the following error: > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > ********************************************************************** > > > > > > > > > **** > > > > > > > > > Executing: "E:\Program Files\MPLAB > > > > > > > > > IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F84A > > > > > > > > > "test1.asm" /l"test1.lst" /e"test1.err" /o"test1.o" > > > > > > > > > Executing: "E:\Program Files\MPLAB > > > > > > > > > IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F84A > > > > > > > > > > "MACROS.ASM" /l"MACROS.lst" /e"MACROS.err" /o"MACROS.o" > > > > > > > > > Skipping link step. The project contains no linker > > > script. > > > > > > > > > BUILD FAILED > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > ********************************************************************** > > > > > > > > > **** > > > > > > > > > > > > > > > > > > Soooo... I created a linker script conforming to > MPASM > > > spec > > > > > > which > > > > > > > > > reads as > > > > > > > > > follows and is part of the MPLab project: > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > ********************************************************************** > > > > > > > > > **** > > > > > > > > > FILES macros.o test1.o > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > ********************************************************************** > > > > > > > > > **** > > > > > > > > > > > > > > > > > > Build now reports the following error: > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > ********************************************************************** > > > > > > > > > **** > > > > > > > > > Executing: "E:\Program Files\MPLAB > > > > > > > > > IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F84A > > > > > > > > > "test1.asm" /l"test1.lst" /e"test1.err" /o"test1.o" > > > > > > > > > Executing: "E:\Program Files\MPLAB > > > > > > > > > IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F84A > > > > > > > > > > "MACROS.ASM" /l"MACROS.lst" /e"MACROS.err" /o"MACROS.o" > > > > > > > > > Executing: "E:\Program Files\MPLAB > > > > > > > > > IDE\MCHIP_Tools\mplink.exe" "test1.lkr" > > > > > > > > > "E:\PIC\test1.o" "E:\PIC\MACROS.o" /o"test1.cof" > > > > > > > > > MPLINK 3.30, Linker > > > > > > > > > Copyright (c) 2003 Microchip Technology Inc. > > > > > > > > > Error - section '.cinit' can not fit the section. > > > > > > Section '.cinit' > > > > > > > > > length=0x00000004 > > > > > > > > > Errors : 1 > > > > > > > > > BUILD FAILED > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > ********************************************************************** > > > > > > > > > **** |
|
|
|
The code wants to execute the first case argument it sees. I have followed it in step mode but I don't yet understand what the macro is doing. I can comment out the first case (case 3) and it executes the the first case it sees regardless of the W reg value! I'm stumped and drowning!! Regards, Steve --- In , "stephendbarnes" <stephendbarnes@h...> wrote: > I changed it to match your example and I'm ready to start debugging > again! > Thanks a million! > > Regards, > Steve > > --- In , "rtstofer" <rstofer@p...> wrote: > > > > This will be a problem. The code is loading the loop > variable 'var' > > into W and then adding 'incf' and leaving the result in 'incf'. It > > needs to be stored in 'var' as in my previous post. > > > > At some point you may want to correct your version. Maybe write a > > small program and test that it works. > > > > --- In , "stephendbarnes" > > <stephendbarnes@h...> wrote: > > > Mine looks like this: > > > > > > nextf...macro...var,incf > > > _nxtknt.set....._nxtknt-1 > > > ........movf....var,w > > > ........addwf...incf,f > > > ........goto...._for#v(_nxtknt) > > > _next#v(_nxtknt) > > > ........endm > > > > > > > > > > > > --- In , "rtstofer" <rstofer@p...> wrote: > > > > > > > > Just to check the version of the macros, look at nextf and it > > > should > > > > look like this (after I revised it): > > > > > > > > nextf...macro..var,incf > > > > _nxtknt.set...._nxtknt-1 > > > > ........movf...incf,w..; the code was incorrect here > > > > ........addwf..var,f...; leave the result in var, not incf > > > > ........goto..._for#v(_nxtknt) > > > > _next#v(_nxtknt) > > > > ........endm > > > > > > > > --- In , "rtstofer" <rstofer@p...> wrote: > > > > > > > > > > We must have gotten different versions of the macros. Mine > did > > > not > > > > > have an 'end' statement but I was beginning to suspect that > > yours > > > > > did. That would be about the only reason for the assembler > to > > > stop > > > > > early. > > > > > > > > > > I am not sure why your code would execute any case. In my > > > version > > > > of > > > > > SIM without a stimulus file the value of PORTA is always 0. > > This > > > > > should not execute any case and if you have placed a goto > loop > > > > > statement following endselect you should not fall into the > > > reverse > > > > > subroutine. The label 'loop' should be before the movwf > PORTA,W > > > > > > > > > > An easy way to trace this code is to put a movlw 3 (or > > something) > > > > > immediately after the movwf PORTA,W. This will load W with a > > > > > matching value for one of the various cases. I would still > > mask > > > > off > > > > > the unused bits and change the select and case statements as > > > > > discussed previously. > > > > > > > > > > --- In , "stephendbarnes" > > > > > <stephendbarnes@h...> wrote: > > > > > > Thank you. I have made a little progress. I found that the > > > > compiler > > > > > > was only compiling the macros.inc file and stopping there! > > I'm > > > > new > > > > > to > > > > > > this and your comments about the .lst file made me go look > at > > > it! > > > > > > WOW. It reported 0 program words used! Looking at the list > I > > > saw > > > > > that > > > > > > none of my code was present. The problem seemed to be that > > Karl > > > > > > Lunt's macro file has the compiler directive "end" at the > > end. > > > I > > > > > > assume that this was causing the compiler to stop dead in > its > > > > > tracks. > > > > > > I removed the "end" directive from the macro file and it > > > compiled > > > > > and > > > > > > simulates. I do have a problem with the thing constantly > > going > > > to > > > > > the > > > > > > first case "case 3" and ignoring the other two regardless > of > > > the > > > > > > value W. I'll be looking forward to seeing your code. I > will > > > try > > > > > > debugging this myself without yelling for help at every > turn > > > > (jump > > > > > in > > > > > > with both feet and only yell when drowning!). You have > been, > > > and > > > > > are > > > > > > being, an enormous help. Thanks again. > > > > > > > > > > > > Regards, > > > > > > Steve > > > > > > > > > > > > --- In , "rtstofer" <rstofer@p...> > > wrote: > > > > > > > I finally figured out how to attach a zip file - I have > to > > > send > > > > > it > > > > > > by > > > > > > > email to from my registered > > > > > account. > > > > > > I > > > > > > > can't do it from work so I will post it tonight. > > > > > > > > > > > > > > I have a zip file with the .asm, .inc and related project > > > > files - > > > > > > > known to work. Just extract to c:\test\ and open the > > project > > > > in > > > > > > > MPASM IDE. > > > > > > > > > > > > > > I tried to create the failure you are having and can't > seem > > > to > > > > > > > duplicate it. Once we are both working from the same > files > > > > maybe > > > > > > it > > > > > > > will become clear. > > > > > > > > > > > > > > > > > > > > > --- In , "stephendbarnes" > > > > > > > <stephendbarnes@h...> wrote: > > > > > > > > I think I see what is happening but I don't know what > to > > do > > > > > about > > > > > > > it. > > > > > > > > The compiler is actually not looking at my code at all! > > > When > > > > it > > > > > > > gets > > > > > > > > to the "#include macros.inc" it compiles the macros and > > > skips > > > > > the > > > > > > > > rest of my source! If you would like to see the .lst > I'll > > > > post > > > > > it > > > > > > > for > > > > > > > > you to look at. Thanks again for your help. > > > > > > > > > > > > > > > > Regards, > > > > > > > > Steve > > > > > > > > > > > > > > > > --- In , "rtstofer" > <rstofer@p...> > > > > wrote: > > > > > > > > > > > > > > > > > > OOPS! Of course the new label in my prior message > goes > > > > ahead > > > > > of > > > > > > > the > > > > > > > > > MOVF PORTA,W. Comes from typing without thinking. > > > > > > > > > > > > > > > > > > --- In , "stephendbarnes" > > > > > > > > > <stephendbarnes@h...> wrote: > > > > > > > > > > Hello all, > > > > > > > > > > I have been attempting to make use of Karl Lunt's > PIC > > > > > Macros > > > > > > > with > > > > > > > > > no > > > > > > > > > > success > > > > > > > > > > during the build phase. I have followed his > > > instructions > > > > > and > > > > > > > > > emailed > > > > > > > > > > him for > > > > > > > > > > help with no response. I'm using MPLab 6.20 and > > writing > > > > > some > > > > > > > test > > > > > > > > > > code for > > > > > > > > > > the 16F84A. The > > > > > > > > > > following text describes my code and the errors > upon > > > > build. > > > > > > > Could > > > > > > > > > > anyone > > > > > > > > > > take a look and see if you could provide some > > insight? > > > > > Thanks > > > > > > > in > > > > > > > > > > advance for > > > > > > > > > > any help. > > > > > > > > > > > > > > > > > > > > Regards, > > > > > > > > > > Stephen D. Barnes > > > > > > > > > > > > > > > > > > > > My code follows: > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > ********************************************************************** > > > > > > > > > > *** > > > > > > > > > > ERRORLEVEL -224 ; suppress message > > > > because > > > > > of > > > > > > > tris > > > > > > > > > > ERRORLEVEL -302 ; suppress message > > > > because > > > > > of > > > > > > > > page > > > > > > > > > > change > > > > > > > > > > > > > > > > > > > > list p=16F84A ; list > > > > directive > > > > > to > > > > > > > > define > > > > > > > > > > processor > > > > > > > > > > #include <p16F84A.inc> ; processor > specific > > > > > > variable > > > > > > > > > > definitions > > > > > > > > > > #include ".\macros.asm" > > > > > > > > > > > > > > > > > > > > __CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & > > _XT_OSC > > > > > > > > > > > > > > > > > > > > ; '__CONFIG' directive is used to embed > configuration > > > > data > > > > > > > > > > within .asm file. > > > > > > > > > > ; The lables following the directive are located in > > the > > > > > > > > > > respective .inc > > > > > > > > > > file. > > > > > > > > > > ; See respective data sheet for additional > > information > > > on > > > > > > > > > > configuration > > > > > > > > > > word. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; > > > > > > > > > ;; > > > > > > > > > > ;;;;;; > > > > > > > > > > ;;;;;;;;;;;;;;;;; > > > > > > > > > > ORG 0x000 ; processor reset vector > > > > > > > > > > goto Main ; go to beginning of program > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; > > > > > > > > > ;; > > > > > > > > > > ;;;;;; > > > > > > > > > > ;;;;;;;;;;;;;;;;; > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; > > > > > > > > > ;; > > > > > > > > > > ;;;;;; > > > > > > > > > > ;;;;;;;;;;;;;;;;; > > > > > > > > > > Main: > > > > > > > > > > clrf PORTB ; PORTB all outputs > > > cleared > > > > > > > > > > bsf STATUS,5 ; Switch to Register Bank 1 > > for > > > > TRIS > > > > > > > > > > movlw B'11111111' ; all bits high in W > > > > > > > > > > movwf TRISA ; contents of W > copied > > > to > > > > > > TRISA > > > > > > > > > (PORTA > > > > > > > > > > all > > > > > > > > > > inputs) > > > > > > > > > > movlw B'00000000' ; all bits low in W > > > > > > > > > > movwf TRISB ; contents of W > copied > > > to > > > > > > TRISB > > > > > > > > > (PORTB > > > > > > > > > > all > > > > > > > > > > outputs) > > > > > > > > > > movlw 0 ; 0 in W > > > > > > > > > > movwf OPTION_REG ; contents of W copied > to > > > > > > OPTION_REG > > > > > > > > > (Port > > > > > > > > > > B > > > > > > > > > > > > > > > > > > pullups > > > > > > > > > > enabled) > > > > > > > > > > bcf STATUS,5 ; Switch back to Register > > > Bank 0 > > > > > > > > > > > > > > > > > > > > movf PORTA ,0 ; move PORTA bit 0 to W > > register > > > > > > > > > > > > > > > > > > > > case 3 > > > > > > > > > > call Reverse > > > > > > > > > > endcase > > > > > > > > > > > > > > > > > > > > case 2 > > > > > > > > > > call Left > > > > > > > > > > endcase > > > > > > > > > > > > > > > > > > > > case 1 > > > > > > > > > > call Right > > > > > > > > > > endcase > > > > > > > > > > > > > > > > > > > > Reverse: > > > > > > > > > > return > > > > > > > > > > Left: > > > > > > > > > > return > > > > > > > > > > Right: > > > > > > > > > > return > > > > > > > > > > > > > > > > > > > > end > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > ********************************************************************** > > > > > > > > > > *** > > > > > > > > > > > > > > > > > > > > When I build I get the following error: > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > ********************************************************************** > > > > > > > > > > **** > > > > > > > > > > Executing: "E:\Program Files\MPLAB > > > > > > > > > > IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F84A > > > > > > > > > > "test1.asm" /l"test1.lst" /e"test1.err" /o"test1.o" > > > > > > > > > > Executing: "E:\Program Files\MPLAB > > > > > > > > > > IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F84A > > > > > > > > > > > > "MACROS.ASM" /l"MACROS.lst" /e"MACROS.err" /o"MACROS.o" > > > > > > > > > > Skipping link step. The project contains no linker > > > > script. > > > > > > > > > > BUILD FAILED > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > ********************************************************************** > > > > > > > > > > **** > > > > > > > > > > > > > > > > > > > > Soooo... I created a linker script conforming to > > MPASM > > > > spec > > > > > > > which > > > > > > > > > > reads as > > > > > > > > > > follows and is part of the MPLab project: > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > ********************************************************************** > > > > > > > > > > **** > > > > > > > > > > FILES macros.o test1.o > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > ********************************************************************** > > > > > > > > > > **** > > > > > > > > > > > > > > > > > > > > Build now reports the following error: > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > ********************************************************************** > > > > > > > > > > **** > > > > > > > > > > Executing: "E:\Program Files\MPLAB > > > > > > > > > > IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F84A > > > > > > > > > > "test1.asm" /l"test1.lst" /e"test1.err" /o"test1.o" > > > > > > > > > > Executing: "E:\Program Files\MPLAB > > > > > > > > > > IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F84A > > > > > > > > > > > > "MACROS.ASM" /l"MACROS.lst" /e"MACROS.err" /o"MACROS.o" > > > > > > > > > > Executing: "E:\Program Files\MPLAB > > > > > > > > > > IDE\MCHIP_Tools\mplink.exe" "test1.lkr" > > > > > > > > > > "E:\PIC\test1.o" "E:\PIC\MACROS.o" /o"test1.cof" > > > > > > > > > > MPLINK 3.30, Linker > > > > > > > > > > Copyright (c) 2003 Microchip Technology Inc. > > > > > > > > > > Error - section '.cinit' can not fit the section. > > > > > > > Section '.cinit' > > > > > > > > > > length=0x00000004 > > > > > > > > > > Errors : 1 > > > > > > > > > > BUILD FAILED > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > ********************************************************************** > > > > > > > > > > **** |
|
|
|
This is what the generated code should loook like - I have removed the comments. The left column is the program address, the second column is the instruction code, the third is the line number (and yours will vary if you have not put a NOLIST before #include "macros.inc" and a LIST after. Some of the fixes I mentioned earlier are not included - some are. At line 28 we grab the port value to W and then XOR it with B'00000011' (3). If the result is zero (beq) we go to 'cas1' just before line 32, XOR it again to restore the value and then call Reverse. After Reverse returns we go to sel1 just after line 40. If the value was not 3 then we repeat the process at line 34 for a value of 2. If the XOR results in zero we call Left, etc. Lastly we try for a value of 1 and if the result of XOR 3 lines past line 37 is zero we call Right. Now, we know that the value grabbed from PORTA and stuffed in W is 0, right? Unless you have somehow gotten a value in PORTA of the simulator it just has to be. Well, 0 is not going to match 3, 2 or 1 and we are going to fall through to line 40 (endselect) and then goto loop. My great attempt to email a zip file hasn't worked yet so I'll post this instead. Your generated code should look exactly like this - let me know if there are differences. 0000 00013 ORG 0x000 0000 2801 00014 goto Main 00015 0001 00016 Main: 0001 0186 00017 clrf PORTB 0002 1683 00018 bsf STATUS,5 0003 30FF 00019 movlw B'11111111' 0004 0085 00020 movwf TRISA 0005 3000 00021 movlw B'00000000' 0006 0086 00022 movwf TRISB 0007 3000 00023 movlw 0 ; 0 in W 0008 0081 00024 movwf OPTION_REG 0009 1283 00025 bcf STATUS,5 00026 000A 00027 loop: 000A 0805 00028 movf PORTA ,0 00029 00030 select 00000001 M _seltot set _seltot+1 00000001 M _selknt set _seltot 00031 case 3 00000001 M _castot set _castot+1 00000001 M _casknt set _castot 000B 3A03 M xorlw 3 M beq cas1 000C 1903 M btfsc STATUS,Z 000D 2810 M goto cas1 000E 3A03 M xorlw 3 000F 2813 M goto ecas1 0010 M cas1 0010 3A03 M xorlw 3 0011 2024 00032 call Reverse 00033 endcase 0012 2823 M goto sel1 0013 M ecas1 00000000 M _casknt set _casknt-1 00034 case 2 00000002 M _castot set _castot+1 MPASM 03.20.07 Released TEST.ASM 4-17- 2003 17:45:47 PAGE 2 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00000002 M _casknt set _castot 0013 3A02 M xorlw 2 M beq cas2 0014 1903 M btfsc STATUS,Z 0015 2818 M goto cas2 0016 3A02 M xorlw 2 0017 281B M goto ecas2 0018 M cas2 0018 3A02 M xorlw 2 0019 2025 00035 call Left 00036 endcase 001A 2823 M goto sel1 001B M ecas2 00000001 M _casknt set _casknt-1 00037 case 1 00000003 M _castot set _castot+1 00000003 M _casknt set _castot 001B 3A01 M xorlw 1 M beq cas3 001C 1903 M btfsc STATUS,Z 001D 2820 M goto cas3 001E 3A01 M xorlw 1 001F 2823 M goto ecas3 0020 M cas3 0020 3A01 M xorlw 1 0021 2026 00038 call Right 00039 endcase 0022 2823 M goto sel1 0023 M ecas3 00000002 M _casknt set _casknt-1 00040 endselect 0023 M sel1 00000000 M _selknt set _selknt-1 0023 280A 00041 goto loop 00042 0024 00043 Reverse: 0024 0008 00044 return 0025 00045 Left: 0025 0008 00046 return 0026 00047 Right: 0026 0008 00048 return 00049 00050 end --- In , "stephendbarnes" <stephendbarnes@h...> wrote: > The code wants to execute the first case argument it sees. I have > followed it in step mode but I don't yet understand what the macro is > doing. I can comment out the first case (case 3) and it executes the > the first case it sees regardless of the W reg value! I'm stumped and > drowning!! > > Regards, > Steve |
|
|
|
Well, the group list software made a mess out of that - I guess you'll have to straighten it out in a text editor to make sense of it. Sorry about that! --- In , "rtstofer" <rstofer@p...> wrote: > > This is what the generated code should loook like - I have removed > the comments. The left column is the program address, the second > column is the instruction code, the third is the line number (and > yours will vary if you have not put a NOLIST before > #include "macros.inc" and a LIST after. > > Some of the fixes I mentioned earlier are not included - some are. > > At line 28 we grab the port value to W and then XOR it with > B'00000011' (3). If the result is zero (beq) we go to 'cas1' just > before line 32, XOR it again to restore the value and then call > Reverse. After Reverse returns we go to sel1 just after line 40. > > If the value was not 3 then we repeat the process at line 34 for a > value of 2. If the XOR results in zero we call Left, etc. > > Lastly we try for a value of 1 and if the result of XOR 3 lines past > line 37 is zero we call Right. > > Now, we know that the value grabbed from PORTA and stuffed in W is 0, > right? Unless you have somehow gotten a value in PORTA of the > simulator it just has to be. Well, 0 is not going to match 3, 2 or 1 > and we are going to fall through to line 40 (endselect) and then goto > loop. > > My great attempt to email a zip file hasn't worked yet so I'll post > this instead. Your generated code should look exactly like this - > let me know if there are differences. > > 0000 00013 ORG 0x000 > 0000 2801 00014 goto Main > 00015 > 0001 00016 Main: > 0001 0186 00017 clrf PORTB > 0002 1683 00018 bsf STATUS,5 > 0003 30FF 00019 movlw B'11111111' > 0004 0085 00020 movwf TRISA > 0005 3000 00021 movlw B'00000000' > 0006 0086 00022 movwf TRISB > 0007 3000 00023 movlw 0 ; 0 in W > 0008 0081 00024 movwf OPTION_REG > 0009 1283 00025 bcf STATUS,5 > 00026 > 000A 00027 loop: > 000A 0805 00028 movf PORTA ,0 > 00029 > 00030 select > 00000001 M _seltot set _seltot+1 > 00000001 M _selknt set _seltot > 00031 case 3 > 00000001 M _castot set _castot+1 > 00000001 M _casknt set _castot > 000B 3A03 M xorlw 3 > M beq cas1 > 000C 1903 M btfsc STATUS,Z > 000D 2810 M goto cas1 > 000E 3A03 M xorlw 3 > 000F 2813 M goto ecas1 > 0010 M cas1 > 0010 3A03 M xorlw 3 > 0011 2024 00032 call Reverse > 00033 endcase > 0012 2823 M goto sel1 > 0013 M ecas1 > 00000000 M _casknt set _casknt-1 > 00034 case 2 > 00000002 M _castot set _castot+1 > MPASM 03.20.07 Released TEST.ASM 4-17- > 2003 17:45:47 PAGE 2 > LOC OBJECT CODE LINE SOURCE TEXT > VALUE > > 00000002 M _casknt set _castot > 0013 3A02 M xorlw 2 > M beq cas2 > 0014 1903 M btfsc STATUS,Z > 0015 2818 M goto cas2 > 0016 3A02 M xorlw 2 > 0017 281B M goto ecas2 > 0018 M cas2 > 0018 3A02 M xorlw 2 > 0019 2025 00035 call Left > 00036 endcase > 001A 2823 M goto sel1 > 001B M ecas2 > 00000001 M _casknt set _casknt-1 > 00037 case 1 > 00000003 M _castot set _castot+1 > 00000003 M _casknt set _castot > 001B 3A01 M xorlw 1 > M beq cas3 > 001C 1903 M btfsc STATUS,Z > 001D 2820 M goto cas3 > 001E 3A01 M xorlw 1 > 001F 2823 M goto ecas3 > 0020 M cas3 > 0020 3A01 M xorlw 1 > 0021 2026 00038 call Right > 00039 endcase > 0022 2823 M goto sel1 > 0023 M ecas3 > 00000002 M _casknt set _casknt-1 > 00040 endselect > 0023 M sel1 > 00000000 M _selknt set _selknt-1 > 0023 280A 00041 goto loop > 00042 > 0024 00043 Reverse: > 0024 0008 00044 return > 0025 00045 Left: > 0025 0008 00046 return > 0026 00047 Right: > 0026 0008 00048 return > 00049 > 00050 end > --- In , "stephendbarnes" > <stephendbarnes@h...> wrote: > > The code wants to execute the first case argument it sees. I have > > followed it in step mode but I don't yet understand what the macro > is > > doing. I can comment out the first case (case 3) and it executes > the > > the first case it sees regardless of the W reg value! I'm stumped > and > > drowning!! > > > > Regards, > > Steve |
|
Just a thought - is the code actually calling your subroutines or just messing about with the xor beq stuff? There is a bunch of code being executed in sequence - there is certainly no magic that makes the select statement jump to the proper case right off the bat. First the code evaluates whether W is 3, if not it evaluates whether W is 2, if not it evaluates whether W is 1, if not it loops back and gets a new value for W and does the process again. If any test is true, the appropriate subroutine is called and the code loops back for a new value of W. And yes, using a computed goto table is probably faster but the table gets ugly if there are unused values of W: 1, 3, 19, 22, 29, 234 for example. You would need a table with 235 entries (0..234) most of which would branch to an error subroutine for invalid values. Where the values can be limited to something like [0..3] then a computed goto table can be faster. Just be sure to forcibly limit them with something like ANDLW B'00000011' after the value is placed in W. Something to think about later. --- In , "stephendbarnes" <stephendbarnes@h...> wrote: > The code wants to execute the first case argument it sees. I have > followed it in step mode but I don't yet understand what the macro is > doing. I can comment out the first case (case 3) and it executes the > the first case it sees regardless of the W reg value! I'm stumped and > drowning!! > > Regards, > Steve |
|
|
|
Yes, it is actually calling the routine specified by the first case it sees! I have just arrived at home and looked at your replies. Thanks for the input. I'm going to compare my listing to yours and correct the problem areas. In all honesty, I think I'm attempting to use the macros as a crutch...I should be learning how to write this code first and then use the macros as a convenience. My PIC projects are not work related so I've got the time to learn. I will use the info you have given me to test my project ideas on the PIC to see if they work. Then I'm going to continue with the learning curve! Thanks for the help and I'll post what I've done for all to see. Regards, Steve --- In , "rtstofer" <rstofer@p...> wrote: > > Just a thought - is the code actually calling your subroutines or > just messing about with the xor beq stuff? There is a bunch of code > being executed in sequence - there is certainly no magic that makes > the select statement jump to the proper case right off the bat. > > First the code evaluates whether W is 3, if not it evaluates whether > W is 2, if not it evaluates whether W is 1, if not it loops back and > gets a new value for W and does the process again. > > If any test is true, the appropriate subroutine is called and the > code loops back for a new value of W. > > And yes, using a computed goto table is probably faster but the table > gets ugly if there are unused values of W: 1, 3, 19, 22, 29, 234 for > example. You would need a table with 235 entries (0..234) most of > which would branch to an error subroutine for invalid values. > > Where the values can be limited to something like [0..3] then a > computed goto table can be faster. Just be sure to forcibly limit > them with something like ANDLW B'00000011' after the value is placed > in W. > > Something to think about later. > > --- In , "stephendbarnes" > <stephendbarnes@h...> wrote: > > The code wants to execute the first case argument it sees. I have > > followed it in step mode but I don't yet understand what the macro > is > > doing. I can comment out the first case (case 3) and it executes > the > > the first case it sees regardless of the W reg value! I'm stumped > and > > drowning!! > > > > Regards, > > Steve |
|
|
|
I never think of macros as a crutch - they are a readability aid and, in some cases, an application specific instruction. If you use them, you can learn from the emitted code and anytime you can see good code and good coding it is worthwhile. That macro library is excellent code. I have two Mark III Minisumo Robots - one uses modified servo motors where a bit is pulsed about 50 times per second. The width of the pulse causes the servo to move at a speed either forward or reverse. The other has an H bridge control and it uses the PWM output of the 16F877. So I have a macro that takes a motor, direction and speed and does conditional assembly depending on the robot I am coding for. The advantage is that the strategy of moving the robot is independent of the hardware. Just call a macro: Motor Left, Foward, Fast Motor Right, Forward, Fast Once I know the macros work correctly I can use them as application specific instructions and not have to worry about the details. No excess code is generated - the instructions are exactly what I would have written in either case. But I only have to do it once. If you write code once, fine. If you write it twice it should be a macro or a subroutine in a library. In my opinion only. Let me know how it works out - the listing I posted does work correctly. None of the subroutines are actually called unless I insert a statement like: MOVLW 3 ; insert before 'select' Good luck! --- In , "stephendbarnes" <stephendbarnes@h...> wrote: > Yes, it is actually calling the routine specified by the first case > it sees! I have just arrived at home and looked at your replies. > Thanks for the input. I'm going to compare my listing to yours and > correct the problem areas. In all honesty, I think I'm attempting to > use the macros as a crutch...I should be learning how to write this > code first and then use the macros as a convenience. My PIC projects > are not work related so I've got the time to learn. I will use the > info you have given me to test my project ideas on the PIC to see if > they work. Then I'm going to continue with the learning curve! > Thanks for the help and I'll post what I've done for all to see. > > Regards, > Steve > --- In , "rtstofer" <rstofer@p...> wrote: > > > > Just a thought - is the code actually calling your subroutines or > > just messing about with the xor beq stuff? There is a bunch of > code > > being executed in sequence - there is certainly no magic that makes > > the select statement jump to the proper case right off the bat. > > > > First the code evaluates whether W is 3, if not it evaluates > whether > > W is 2, if not it evaluates whether W is 1, if not it loops back > and > > gets a new value for W and does the process again. > > > > If any test is true, the appropriate subroutine is called and the > > code loops back for a new value of W. > > > > And yes, using a computed goto table is probably faster but the > table > > gets ugly if there are unused values of W: 1, 3, 19, 22, 29, 234 > for > > example. You would need a table with 235 entries (0..234) most of > > which would branch to an error subroutine for invalid values. > > > > Where the values can be limited to something like [0..3] then a > > computed goto table can be faster. Just be sure to forcibly limit > > them with something like ANDLW B'00000011' after the value is > placed > > in W. > > > > Something to think about later. > > > > > > > > --- In , "stephendbarnes" > > <stephendbarnes@h...> wrote: > > > The code wants to execute the first case argument it sees. I have > > > followed it in step mode but I don't yet understand what the > macro > > is > > > doing. I can comment out the first case (case 3) and it executes > > the > > > the first case it sees regardless of the W reg value! I'm stumped > > and > > > drowning!! > > > > > > Regards, > > > Steve |
|
I agree with you. My point was that as a raw beginner in
assembly language, the easy way out has a way of making one loose sight of the objective
(learning how to code). At times, one is so focused on the project at hand that looking at
the results of the macro plays second fiddle to enjoying the end product! What is the
saying...."Know thy self"? ;-)
Back to the subject...I have not tried the macro example
listing you posted yet (but I will soon) because I solve this particular problem with
inline code! I have always used high level languages when writing software for PC's,
PLC's, etc., so assembly has really made me think about new ways (to me) to solve old
problems. If you have the time, take a look at the attached file to see what I have done.
It is well commented and is a work in progress so please excuse the time delay stuff which
came from the MIT piclist examples page (any suggestions would be welcome).
Regards,
Steve
| |||
| |||
|
|
|
I'm not sure why the group doesn't accept your email posts. It took
about eight tries before it finally posted from my email client!
Good suggestion concerning the self relative jumps...I've implemented
that. What are your thoughts about the timing loops?
Regards,
Steve
|
|
|
|
Thank you. I would really like to see what you have
created!
Regards,
Steve
|
|
Attached is the code we discussed. Thinking about it today I have decided that since the A/D values are only used every 20 mS (by throttle and steering code) it would be better to pull that code out of the interrupt routine and use two tasks separated in time by a couple of mS. The first task would grab the previous conversion, update the channel selection and exit. A couple of mS later the second task would start the conversion. This gives plenty of time for settling after channel selection and the actual conversion. It also reduces the amount of overhead in the interrupt routine. Work in progress but maybe there are some tidbits. | |||
|
|
Thanks for the attachment. I'll be looking at it tonight.
Regards,
Steve
|
|
|
|
Hi RT,
I like the boat controller code! I'm spending some time with it to
understand how it works and to adapt it to the f84a. For a few days I will only be able to
simulate my work because of a mishap with a pair of wayward needle nose
pliers that wasted the f84a chip (dropped 'em on my breadboard and shorted som portb
pins)! I have been lucky in the fact that this is the first component I have destroyed in
about 2 years and I have prototyped hundreds of designs both professionally and
personally! I have a couple more on the way and also an f628! If you have any experience
with the 628 can you give me your thoughts on the internal oscillator (only going to use
it for testing code on the breadboard).
Thanks for all the correspondence. You have really helped jump start
my education with the PIC!
Regards,
Steve
|
|
|
|
I like the 16F876 and 877 too.
If you really like the 18-pin format of the 16F628, the
16F819 (I think I got the # right) trades the USART for 5-pins A/D converter, but is
otherwise very similar to the 16F628. It has the new "internal software osc block"
of the 16F628A too.
Microchip doesn't recommend using the USART with the
internal osc anyway, so the 16F819 may become the low-end chip of choice for minimal
component work.
|
|
|
|
> However for the
16F628 the USART is working perfect up to 2400bps.
Good to know!
I've never tried the USART without a xtal, since an
xtal and caps is only
$1.50 or so more, and pretty small, but it is good to know it WILL work if you want to use
it. I've heard the 16F628A (or some other newer chip) will have a higher
precision more stable internal osc that should help. Anyone have any experience with
that?
|
|
|