PDA

View Full Version : directive in pbp to select pic



josepic
- 31st July 2022, 19:29
friends greetings


friends make a code in PBP, I have looked in the notepad of the pic 16f886.inc of the PBP and I have configured the fuses for the pic 16f886.
#CONFIG
__config _CONFIG1, _INTRC_OSC_NOCLKOUT & _WDT_OFF & _MCLRE_ON & _LVP_OFF & _CP_ON & _CPD_ON
#ENDCONFIG


define osc 8


what I can't find is the directive to tell the compiler which pic to use, in this case pic 16f886.


I know that by default the pbp assigns the default configuration and uses a 4 Mhz crystal, in my case I configured the fuses for the 16f886 pic and I defined the crystal to use in this case an 8 Mhz oscillator.
but the only thing I need is to define the pic 16f886 in the pbp.
Could you please help me and tell me what is the pbp directive to define the pic to use in the compiler.


thanks friends

Ioannis
- 31st July 2022, 19:51
Why don't you use the free MCS IDE?

josepic
- 31st July 2022, 20:19
do you mean msc ide bascom avr?

HenrikOlsson
- 1st August 2022, 10:10
Which device the compiler builds the code for is specified using the -p option passed to the compiler exectuable. There is, as far as I know, no way to specify that in the source code itself. See section 8.3 in the manual.

If you use MicroCodeStudio it will handle this for you, generating the correct command line parameters based on the selected device and other options.

Tip: define osc 8 won't work, osc needs to be in upper case:

define OSC 8

josepic
- 1st August 2022, 12:41
I correct DEFINE OSC 8 this should be in uppercase, I have read the manual again page 281 section 8.1.3.
in section 4.9 page 100 of the manual I found the following

#CONFIG...#ENDCONFIG
#CONFIG
;configuration directives in Assembly Language
#ENDCONFIG
#CONFIG can be used to insert a block of Assembly Language directives that specify
settings for target device's configuration words. These settings control things like the
oscillator type, code protection, and other parameters that must be set before the
program code executes. For detailed information about configuration words, see the
datasheet for the specific PIC microcontroller that you are compiling for. Most
datasheets will list the information in a section named "Configuration" or "Special
Features".
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.
Microchip determines the form and syntax of the actual configuration directives, and
they are not consistent for different families of PIC microcontrollers. We have
attempted to include the information for each chip in a device information file. The
files are located in your PBP install in the Device Reference folder.
(PIC16F877.INFO, PIC18F4620.INFO, etc.)
Here are a few examples that you might use for various parts:
'Config for 16F877A
#CONFIG
__config _XT_OSC & _WDT_ON & _LVP_OFF & _CP_OFF
#ENDCONFIG
'Config for 18F46J50
#CONFIG
CONFIG XINST = OFF
CONFIG PLLDIV = 5
CONFIG WDTPS = 512
CONFIG CPUDIV = OSC1
CONFIG OSC = HSPLL
#ENDCONFIG

Ioannis
- 1st August 2022, 14:26
And still there is no way to direct the use of specific PIC in the #config block.

Use the MCS IDE that came with your purchase of PBP. Is the easiest solution.

Ioannis

9260

josepic
- 1st August 2022, 14:53
In the pbp manual page 100 section 4.9 it says the following.

'Config for 16F877A
#CONFIG
__config _XT_OSC & _WDT_ON & _LVP_OFF & _CP_OFF
#ENDCONFIG

If the pic to use and the fuses are not specified, the pbp defaults to 4 mhz.

mpgmike
- 2nd August 2022, 18:56
You have "include fp2032.bas" which doesn't look right. It should be "include pic16f886.bas" (or whatever your PIC is).

josepic
- 2nd August 2022, 19:35
You have "include fp2032.bas" which doesn't look right. It should be "include pic16f886.bas" (or whatever your PIC is).

fp2032.bas library is included for floating point.
I also took into account the .inc file of each pic of the pbp to configure the fuses of the selected pic.
I had to read the pbp manual page 100 section 4.9 to configure the fuses of the selected pic, read the pbp manual and you will see

Ioannis
- 5th August 2022, 09:08
If the pic to use and the fuses are not specified, the pbp defaults to 4 mhz.


That is correct. Not a problem but the default state of the compiler.

Ioannis