Sign in

username:

password:



Not a member?

Search piclist



Search tips

Subscribe to piclist



piclist by Keywords

12F675 | 16F628 | 16F84 | 16f877 | 16F877A | 16F88 | 18F458 | ADC | AVR | Bootloader | CAN | CCS | CRC | EAGLE | EEPROM | ICD | ICSP | IDE | JDM | LED | Macros | Microchip | MPLAB | PCB-CAD | PIC10F | Pic12f675 | PIC16F84 | PIC16F84A | PIC16F877 | PIC18 | PIC18F452 | PicBasic | PICC | PICSTART | PWM | RS-485 | RS232 | SMT | SPI | UART | USART | USB | Wireless | Wisp628 | Xilinx


Ads

Discussion Groups

See Also

DSPFPGAElectronics

Discussion Groups | Piclist | Need help with PIC Macros

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.

Need help with PIC Macros - stephendbarnes - Apr 16 18:35:00 2003

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
**********************************************************************
****





(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )


Re: Need help with PIC Macros - rtstofer - Apr 16 20:42:00 2003


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
>
**********************************************************************
> ****





(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )

Re: Need help with PIC Macros - Readability issue - rtstofer - Apr 16 20:59:00 2003


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
>
**********************************************************************
> ****





(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )

Re: Need help with PIC Macros - stephendbarnes - Apr 16 22:02:00 2003

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
> >
>
**********************************************************************
> > ****




(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )

Re: Need help with PIC Macros - Readability issue - stephendbarnes - Apr 16 22:40:00 2003

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
> >
>
**********************************************************************
> > ****



______________________________
Stellaris® MCU Family: New Parts, New Package, New Price.


(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )

Re: Need help with PIC Macros - Readability issue - rtstofer - Apr 16 23:44:00 2003


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
> > >
> >
>
**********************************************************************
> > > ****




(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )

Re: Need help with PIC Macros - Readability issue - rtstofer - Apr 16 23:52:00 2003


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
> > >
> >
>
**********************************************************************
> > > ****





(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )

Low voltage shutdown - Bruce Partridge - Apr 17 0:24:00 2003

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

 





(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )

Re: Need help with PIC Macros - rtstofer - Apr 17 0:26:00 2003


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
>
**********************************************************************
> ****





(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )

Re: Low voltage shutdown - rtstofer - Apr 17 0:40:00 2003


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




(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )

Re: Need help with PIC Macros - stephendbarnes - Apr 17 12:24:00 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
> >
>
**********************************************************************
> > ****





(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )

Re: Need help with PIC Macros - rtstofer - Apr 17 13:35:00 2003

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
> > >
> >
>
**********************************************************************
> > > ****





(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )

Re: Need help with PIC Macros - stephendbarnes - Apr 17 14:03:00 2003

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
> > > >
> > >
> >
>
**********************************************************************
> > > > ****





(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )

Re: Need help with PIC Macros - rtstofer - Apr 17 14:48:00 2003


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
> > > > >
> > > >
> > >
> >
>
**********************************************************************
> > > > > ****



______________________________
Stellaris® MCU Family: New Parts, New Package, New Price.


(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )

Re: Need help with PIC Macros - rtstofer - Apr 17 15:22:00 2003


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
> > > > > >
> > > > >
> > > >
> > >
> >
>
**********************************************************************
> > > > > > ****





(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )

Re: Need help with PIC Macros - stephendbarnes - Apr 17 15:40:00 2003

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
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>
**********************************************************************
> > > > > > > ****



______________________________
Stellaris® MCU Family: New Parts, New Package, New Price.


(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )

Re: Need help with PIC Macros - rtstofer - Apr 17 15:51:00 2003


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
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>
**********************************************************************
> > > > > > > > ****





(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )

Re: Need help with PIC Macros - stephendbarnes - Apr 17 17:03:00 2003

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
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>
**********************************************************************
> > > > > > > > > ****





(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )

Re: Need help with PIC Macros - stephendbarnes - Apr 17 18:09:00 2003

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
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
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>
**********************************************************************
> > > > > > > > > > ****





(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )

Re: Need help with PIC Macros - rtstofer - Apr 17 19:59:00 2003


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



______________________________
Stellaris® MCU Family: New Parts, New Package, New Price.


(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )

Re: Need help with PIC Macros - rtstofer - Apr 17 20:04:00 2003


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




(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )

Re: Need help with PIC Macros - rtstofer - Apr 17 20:35:00 2003


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





(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )

Re: Need help with PIC Macros - stephendbarnes - Apr 18 20:39:00 2003

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





(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )

Re: Need help with PIC Macros - rtstofer - Apr 19 0:38:00 2003


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




(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )

Re: Re: Need help with PIC Macros - Stephen D. Barnes - Apr 19 15:50:00 2003

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
----- Original Message -----
From: rtstofer
To: p...@yahoogroups.com
Sent: Saturday, April 19, 2003 1:38 AM
Subject: [piclist] Re: Need help with PIC Macros


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 p...@yahoogroups.com, "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 p...@yahoogroups.com, "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 p...@yahoogroups.com, "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



to unsubscribe, go to http://www.yahoogroups.com and follow the instructions

Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.


Attachment (not stored)
sallybot.asm
Type: application/octet-stream




(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )

Re: Re: Need help with PIC Macros - Stephen D. Barnes - Apr 19 21:52:00 2003

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
----- Original Message -----
From: rtstofer
To: p...@yahoogroups.com
Sent: Saturday, April 19, 2003 10:03 PM
Subject: [piclist] Re: Need help with PIC Macros


Wonder why my email post never made it.  Strange.

OK, the only thing I would reconsider is using self-relative jumps as
in 'goto $ - 3'.  If you ever add a little debug code in the middle
of the loop that instruction will come back to bite you.  In fact,
any change in the loop is a problem.

I would consider adding 3 labels (Reverse1, Left1, Right1) as the
targets for the 3 self-relative jumps.

I like the idea of assigning names to port bits with #define.  I have
been trying to use that at every opportunity.

Looking good!

--- In p...@yahoogroups.com, "Stephen D. Barnes"
<stephendbarnes@h...> wrote:
> 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
>   ----- Original Message -----
>   From: rtstofer
>   To: p...@yahoogroups.com
>   Sent: Saturday, April 19, 2003 1:38 AM
>   Subject: [piclist] Re: Need help with PIC Macros>
>   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 p...@yahoogroups.com, "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 p...@yahoogroups.com, "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 p...@yahoogroups.com, "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>         Yahoo! Groups Sponsor
>       
>       
>
>   to unsubscribe, go to http://www.yahoogroups.com and follow the
instructions
>
>   Your use of Yahoo! Groups is subject to the Yahoo! Terms of
Service.



to unsubscribe, go to http://www.yahoogroups.com and follow the instructions

Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.





(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )

Re: Re: Need help with PIC Macros - Stephen D. Barnes - Apr 20 15:32:00 2003

Thank you. I would really like to see what you have created!
 
Regards,
Steve
----- Original Message -----
From: rtstofer
To: p...@yahoogroups.com
Sent: Sunday, April 20, 2003 1:56 PM
Subject: [piclist] Re: Need help with PIC Macros


Well, as you have no doubt discovered, timing loops consume 100% of
the CPU cycles.  Maybe that is ok, maybe not.  I have been using a
cooperative multi-task scheduler which doesn't take a lot of code. 
Not coincidentally it uses a few macros to generate the code and
tables.

Basically, tasks are statically created at assembly time and an
interrupt routine schedules them for execution on a periodic basis. 
One of the neat things is that not only do the tasks repeat every so
many clock ticks but they can be delayed an initial amount of time
and this achieves an interleave effect.

Take something as simple as flashing an LED.  What happens is that
every 250 mS the flash task is scheduled by the interrupt routine and
subsequently executed by the dispatch loop.  The routine itself just
alternates the state of the LED.  Very fast task, just invert the
output bit and return.

A couple of other thoughts: infrared proximity sensors (Sharp GP2D12,
etc) only update every 28.7 to 37.9 mS.  Then a handfull of
microseconds for the A/D conversion and the data is ready.  At most
these devices need to be sampled every 14 mS.  So, if there are 8 A/D
channels why not schedule it such that at every 1 mS tick a channel
is read and the value placed in an A/D array.  This implies that the
latest A/D conversion of any sensor is immediately available for the
code - no time lost selecting a channel, starting a conversion and
fetching the result.  Just get the value from the array!  Overlap and
pipeline - these are the keys to getting a lot of processing out of a
small processor.

My interrupt routine does two things: it grabs an A/D conversion,
sticks it in an array, updates the channel selection and ultimately
starts the conversion.  Second, it looks through an array of task
schedule information for a task to initiate and sets a flag for those
that are ready.  One assumption is that any given task will be
complete before the next mS tick.  This is pretty easy to do since
the processor can execute about 5000 instructions in a mS (generally
I am using a 20 MHz 16F87x).  Now, there is the fixed overhead of the
interrupt handler and the dispatch loop that takes a certain amount
of time out of every mS tick but there is still a lot of time for
each task.  This is where staggering the tasks really pays off -
assuming that every task doesn't have to be scheduled every mS.

Outside the interrupt routine is a round robin task dispatcher as the
main code for the program.  It simply looks through the ready flags
and calls the various routines.  No real processing being done in the
main loop - just test and call.

By creating tasks the larger problem has been partitioned into
smaller pieces that can be developed separately.  Intellectually the
progam is easier to comprehend because a certain structure has been
forced on a complex problem.

So, my thoughts on delay loops are that they waste resources that
could better be used for other things like strategy and tactics and
that, in most cases, they are unnecessary.  Further, eliminating them
actually simplifies the program while adding structure and clarity.

When I get home I will try to polish up what I have and see if I can
post it using MS Outlook instead of Linux sendmail.
--- In p...@yahoogroups.com, "Stephen D. Barnes"
<stephendbarnes@h...> wrote:
> 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
>   ----- Original Message -----
>   From: rtstofer
>   To: p...@yahoogroups.com
>   Sent: Saturday, April 19, 2003 10:03 PM
>   Subject: [piclist] Re: Need help with PIC Macros>
>   Wonder why my email post never made it.  Strange.
>
>   OK, the only thing I would reconsider is using self-relative
jumps as
>   in 'goto $ - 3'.  If you ever add a little debug code in the
middle
>   of the loop that instruction will come back to bite you.  In
fact,
>   any change in the loop is a problem.
>
>   I would consider adding 3 labels (Reverse1, Left1, Right1) as the
>   targets for the 3 self-relative jumps.
>
>   I like the idea of assigning names to port bits with #define.  I
have
>   been trying to use that at every opportunity.
>
>   Looking good!


to unsubscribe, go to http://www.yahoogroups.com and follow the instructions

Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.




(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )

Re: Need help with PIC Macros - rstofer - Apr 21 20:07:00 2003


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.


Attachment (not stored)
ElectricBoat.zip
Type: application/x-zip-compressed



(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )

Re: Re: Need help with PIC Macros - Stephen D. Barnes - Apr 21 21:51:00 2003

Thanks for the attachment. I'll be looking at it tonight.
 
Regards,
Steve
----- Original Message -----
From: rstofer
To: p...@yahoogroups.com
Sent: Monday, April 21, 2003 9:07 PM
Subject: [piclist] Re: Need help with PIC Macros


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.


to unsubscribe, go to http://www.yahoogroups.com and follow the instructions

Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.





(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )

Re: Re: Need help with PIC Macros - Stephen D. Barnes - Apr 22 10:47:00 2003

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
----- Original Message -----
From: rtstofer
To: p...@yahoogroups.com
Sent: Tuesday, April 22, 2003 2:38 AM
Subject: [piclist] Re: Need help with PIC Macros


During the 'clean-up' process at least one problem crept in.  The
definition of Delay in CBLOCK has a semicolon where a colon is
required.

I started playing with the cleaned up version plus the task changes
and noted the problem.

--- In p...@yahoogroups.com, "Stephen D. Barnes"
<stephendbarnes@h...> wrote:
> Thanks for the attachment. I'll be looking at it tonight.
>
> Regards,
> Steve
>   ----- Original Message -----
>   From: rstofer
>   To: p...@yahoogroups.com
>   Sent: Monday, April 21, 2003 9:07 PM
>   Subject: [piclist] Re: Need help with PIC Macros>
>   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.
>
>         Yahoo! Groups Sponsor
>
>             
>       
>       
>
>   to unsubscribe, go to http://www.yahoogroups.com and follow the
instructions
>
>   Your use of Yahoo! Groups is subject to the Yahoo! Terms of
Service.



to unsubscribe, go to http://www.yahoogroups.com and follow the instructions

Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.





(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )

Re: Re: Need help with PIC Macros - Bert Drake - Apr 22 11:32:00 2003

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.
----- Original Message -----
From: rtstofer
To: p...@yahoogroups.com
Sent: Tuesday, April 22, 2003 11:06 AM
Subject: [piclist] Re: Need help with PIC Macros


Oddly enough I just finished a project with the 628 and I used the
internal oscillator.  Why not?  I wasn't in a hurry.

This project is a water level alarm for my sailboat.  All of the
leaks are not always above the water line!  It too uses a co-
operative multitasker but the code is written in C.  Much easier to
deal with.

There are 4 water level probes in the bilge and when water is
detected at any level an LED flashes and a Sonalert start beeping. 
There is also a heartbeat LED.  Again these are flashed as tasks.

The horn can be silenced, of course, but the real reason for all of
this effort was to interface water level to a programmable alarm
dialer.  When the level reaches some stage a relay is energized which
signals the alarm dialer.  The dialer calls my cell phone and my home
phone and recites a message about the water level.  This works only
when the boat is docked of course and that is the reason for the LEDs
and Sonalert.  I could be standing 3 feet away and the dialer is
useless.

I like the 628 but...  There is no A/D converter only analog
comparators.  Ok for this project but I prefer the 16F876 for .300
pin spacing and the 16F877 when only a 40 pin will do.

--- In p...@yahoogroups.com, "Stephen D. Barnes"
<stephendbarnes@h...> wrote:
> 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
>   ----- Original Message -----
>   From: rtstofer
>   To: p...@yahoogroups.com
>   Sent: Tuesday, April 22, 2003 2:38 AM
>   Subject: [piclist] Re: Need help with PIC Macros>
>   During the 'clean-up' process at least one problem crept in.  The
>   definition of Delay in CBLOCK has a semicolon where a colon is
>   required.
>
>   I started playing with the cleaned up version plus the task
changes
>   and noted the problem.
>
>   --- In p...@yahoogroups.com, "Stephen D. Barnes"
>   <stephendbarnes@h...> wrote:
>   > Thanks for the attachment. I'll be looking at it tonight.
>   >
>   > Regards,
>   > Steve
>   >   ----- Original Message -----
>   >   From: rstofer
>   >   To: p...@yahoogroups.com
>   >   Sent: Monday, April 21, 2003 9:07 PM
>   >   Subject: [piclist] Re: Need help with PIC Macros
>   >
>   >
>   >
>   >   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.
>   >
>   >         Yahoo! Groups Sponsor
>   >
>   >             
>   >       
>   >       
>   >
>   >   to unsubscribe, go to http://www.yahoogroups.com and follow
the
>   instructions
>   >
>   >   Your use of Yahoo! Groups is subject to the Yahoo! Terms of
>   Service.>         Yahoo! Groups Sponsor
>
>             
>       
>       
>
>   to unsubscribe, go to http://www.yahoogroups.com and follow the
instructions
>
>   Your use of Yahoo! Groups is subject to the Yahoo! Terms of
Service.



to unsubscribe, go to http://www.yahoogroups.com and follow the instructions

Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.





(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )

Re: Re: Need help with PIC Macros - Bert Drake - Apr 23 10:30:00 2003

> 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?
----- Original Message -----
From: Vasile Surducan
To: p...@yahoogroups.com
Sent: Wednesday, April 23, 2003 1:22 AM
Subject: Re: [piclist] Re: Need help with PIC Macros

On Tue, 22 Apr 2003, Bert Drake wrote:

> 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.

Microchip doesn't recomand many other usefull things like a small
overclocking or using internal osc with usart. However for the 16F628
the USART is working perfect up to 2400bps.
In 12F675 the oscal feature is allowing up to 4800bps with internal
oscillator (and software usart, of course).Vasile


to unsubscribe, go to http://www.yahoogroups.com and follow the instructions

Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.



______________________________
Stellaris® MCU Family: New Parts, New Package, New Price.


(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )