PDA

View Full Version : Clarification need about #CONFIG...#ENDCONFIG / asm ...endasm.



Wirecut
- 6th April 2013, 11:20
Hi

I'm using MCS 5.0.0.3 & PBP 3.0.6.1 (trial version).

I have a big doubt about the #CONFIG...#ENDCONFIG

On the Darrel Taylor USB sample program (USB.pbp) there are:

;--- if you un-comment these, you must comment the ones in the .inc file ---
asm ; 18F2550/4550, 8mhz crystal
__CONFIG _CONFIG1L, _PLLDIV_2_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L
__CONFIG _CONFIG1H, _FOSC_HSPLL_HS_1H
__CONFIG _CONFIG2L, _PWRT_ON_2L & _BOR_OFF_2L & _VREGEN_ON_2L
__CONFIG _CONFIG2H, _WDT_ON_2H & _WDTPS_512_2H
__CONFIG _CONFIG3H, _PBADEN_OFF_3H
__CONFIG _CONFIG4L, _LVP_OFF_4L & _XINST_OFF_4L
endasm

and on the related file: "C:\PBP3\DEVICES\PIC18F4550.PBPINC" file there are

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; The #CONFIG block is passed directly to the asm file, but PBP will replace it
; automagically with the contents of a user-defined #CONFIG block if one is
; found in the PBP source program. There is no need to edit or comment this
; block in this file. Simply copy it to your source program and edit it there.

#CONFIG
__CONFIG _CONFIG1L, _PLLDIV_5_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L
__CONFIG _CONFIG1H, _FOSC_HSPLL_HS_1H & _FCMEN_OFF_1H & _IESO_OFF_1H
__CONFIG _CONFIG2L, _PWRT_OFF_2L & _BOR_ON_2L & _BORV_3_2L & _VREGEN_ON_2L
__CONFIG _CONFIG2H, _WDT_ON_2H & _WDTPS_512_2H
__CONFIG _CONFIG3H, _CCP2MX_ON_3H & _PBADEN_OFF_3H & _LPT1OSC_OFF_3H & _MCLRE_ON_3H
__CONFIG _CONFIG4L, _STVREN_ON_4L & _LVP_OFF_4L & _ICPRT_OFF_4L & _XINST_OFF_4L
#ENDCONFIG :

And the PBP3 manual say:

The #CONFIG block is similar to the ASM..ENDASM and @ runtime commands
because its contents are written in Assembly Language. It is a special case,
however, and differs from the runtime commands in significant ways. The code
enclosed in a #CONFIG block always replaces the default configuration settings
that PBP would normally include. The code is placed in a special location in the
generated Assembly Language. This location is reserved for configuration
directives; therefore #CONFIG should not be used for other Assembly instructions.

That seem self explicative; if I leave all as is. I should compile the program without any trouble, but this is not true. When I compile I see the following:

Error[118] C:\PIC\MEL\PBP3061\18F4550\USB\USB_PIC\USB.ASM 301 : Overwriting previous address contents (0000)
Error[118] C:\PIC\MEL\PBP3061\18F4550\USB\USB_PIC\USB.ASM 301 : Overwriting previous address contents (0001)
Error[118] C:\PIC\MEL\PBP3061\18F4550\USB\USB_PIC\USB.ASM 302 : Overwriting previous address contents (0000)
Error[118] C:\PIC\MEL\PBP3061\18F4550\USB\USB_PIC\USB.ASM 302 : Overwriting previous address contents (0001)
Error[118] C:\PIC\MEL\PBP3061\18F4550\USB\USB_PIC\USB.ASM 303 : Overwriting previous address contents (0002)
Error[118] C:\PIC\MEL\PBP3061\18F4550\USB\USB_PIC\USB.ASM 303 : Overwriting previous address contents (0003)
Error[118] C:\PIC\MEL\PBP3061\18F4550\USB\USB_PIC\USB.ASM 304 : Overwriting previous address contents (0002)
Error[118] C:\PIC\MEL\PBP3061\18F4550\USB\USB_PIC\USB.ASM 304 : Overwriting previous address contents (0003)
Error[118] C:\PIC\MEL\PBP3061\18F4550\USB\USB_PIC\USB.ASM 305 : Overwriting previous address contents (0004)
Error[118] C:\PIC\MEL\PBP3061\18F4550\USB\USB_PIC\USB.ASM 305 : Overwriting previous address contents (0005)
Error[118] C:\PIC\MEL\PBP3061\18F4550\USB\USB_PIC\USB.ASM 306 : Overwriting previous address contents (0006)
Error[118] C:\PIC\MEL\PBP3061\18F4550\USB\USB_PIC\USB.ASM 306 : Overwriting previous address contents (0007)

I need to improve my understand on english language or there are actions that I do not have done?

Leo

HenrikOlsson
- 6th April 2013, 16:26
Hi,
The #CONFIG/#ENDCONFIG was introduced in PBP3 and the first piece of code you posted was written when the CONFIG was handled in a different way.
If you have a config block within ASM/ENDASM and compile it with PBP3 you will get the error message that you get because PBP3 then it then tries to use "both" the default configuration from the .PBPINC file AND the ones in the ASM/ENDASM block - kind of.

If you want to use the configuration in the first piece of code then simply change ASM to #CONFIG and ENDASM to #ENDCONFIG. It'll then use that configuration instead of the defauly and I think you'll be fine.

/Henrik.

HenrikOlsson
- 6th April 2013, 18:22
Hi,
(This is very weird, I posted an answer to this thread but it just disapeared. So, here's a second attempt)

#CONFIG/#ENDCONFIG was introduced with PBP3. The first code snippet shows the old way of handling the config (which required the default ones to be commented out).
You get the errors because it now tries to use the default ones and the ones within the ASM/ENDASM block. Change ASM/ENDASM to #CONFIG/#ENDCONFIG and it will use the ones within the block instead of the default ones. The errors should then go away.

/Henrik.

Ioannis
- 6th April 2013, 19:10
I see the post you did Henrik as moderated. Maybe that is why you do not see it.

Ioannis


Edit by Robert:

Weird, even this post was awaiting to be moderated.

Wirecut
- 7th April 2013, 01:46
Thanks HenrikOllson

I have made the modification as you say and "automagically" all woks.

I will become crazy without your help.

Thanks again.