Maker Pro
Maker Pro

MPLAB

D

david

using mplab you can set the config fuses in the asm file. but can you set
the processor type
so if working with two pic as you assemble code for one the config word AND
the processor type is set ??

David
 
S

Spehro Pefhany

using mplab you can set the config fuses in the asm file. but can you set
the processor type
so if working with two pic as you assemble code for one the config word AND
the processor type is set ??

David

Example:

LIST P=18F8520
#include "P18F8520.INC"
....


Best regards,
Spehro Pefhany
 
D

david

Spehro Pefhany said:
Example:

LIST P=18F8520
#include "P18F8520.INC"
...


Best regards,
Spehro Pefhany
well sort of but that example is a compiler directive.
I use a picstart plus programmer if the processor type is set to 18F8520, I
was looking
for an instruction like:-
__CONFIG _CP_OFF & _WDT_OFF & _BODEN_OFF & _PWRTE_OFF & _INTRC_OSC_NOCLKOUT
& _MCLRE_OFF & _LVP_OFF

which will change the config settings in MPLAB but I want to change the
processor type in mplab ??

but thanks for reply.

David
 
S

Spehro Pefhany

use a picstart plus programmer if the processor type is set to 18F8520, I
was looking
for an instruction like:-
__CONFIG _CP_OFF & _WDT_OFF & _BODEN_OFF & _PWRTE_OFF & _INTRC_OSC_NOCLKOUT
& _MCLRE_OFF & _LVP_OFF

which will change the config settings in MPLAB but I want to change the
processor type in mplab ??

Oh, I see what you mean now. I don't think so, that info is stored in
the .mcw (workspace) file. You can't just use two workspaces?
but thanks for reply.

;-)

Best regards,
Spehro Pefhany
 
D

david

Spehro Pefhany said:
Oh, I see what you mean now. I don't think so, that info is stored in
the .mcw (workspace) file. You can't just use two workspaces?


;-)

Best regards,
Spehro Pefhany

You can't just use two workspaces?
I think that is the only way but as this project uses 11 pics, ok so only 2
types.I was trying to keep it all together. Last night I was jumping from
877 to 628 and back again
it seemed a pain to change the device by hand if there was another way. but
hey thanks anyway..

David
 
A

Alex Gibson

david said:
using mplab you can set the config fuses in the asm file. but can you set
the processor type
so if working with two pic as you assemble code for one the config word AND
the processor type is set ??

David

You can. A friend pointed this out to me ealier this year

;************************************************************
#define Processor 16F877 ; or 16F628
;************************************************************


if Processor == 16F628
list p=16f628 ; set processor type
#include <P16f628.INC>
__config _CP_OFF & _PWRTE_ON & _HS_OSC & _WDT_OFF & _BODEN_ON &
_LVP_OFF
else ;Must be the 16F877
LIST P=16F877, F=INHX8M
#include <P16F877.inc>
__config _CP_OFF & _DEBUG_OFF & _WRT_ENABLE_OFF & _LVP_OFF & _BODEN_ON
& _WDT_OFF & _HS_OSC & _PWRTE_ON
endif

Use the same thing for different setup (intialisation code) code
and in your subroutines. Fine if there is only a few small differences.

Can be easier to just use seperate files with processor in the name
to avoid forgetting to set the processor define to the one you need
and then spending ages before you realise.

Alex
 
D

david

Alex Gibson said:
You can. A friend pointed this out to me ealier this year

;************************************************************
#define Processor 16F877 ; or 16F628
;************************************************************


if Processor == 16F628
list p=16f628 ; set processor type
#include <P16f628.INC>
__config _CP_OFF & _PWRTE_ON & _HS_OSC & _WDT_OFF & _BODEN_ON &
_LVP_OFF
else ;Must be the 16F877
LIST P=16F877, F=INHX8M
#include <P16F877.inc>
__config _CP_OFF & _DEBUG_OFF & _WRT_ENABLE_OFF & _LVP_OFF & _BODEN_ON
& _WDT_OFF & _HS_OSC & _PWRTE_ON
endif

Use the same thing for different setup (intialisation code) code
and in your subroutines. Fine if there is only a few small differences.

Can be easier to just use seperate files with processor in the name
to avoid forgetting to set the processor define to the one you need
and then spending ages before you realise.

Alex

many thanks I havent tried it yet but that is just what i wanted ( hope it
works ) :)

David
 
A

Alex Gibson

david said:
many thanks I havent tried it yet but that is just what i wanted ( hope it
works ) :)

works well.

Use it for the example programs for a subject I'm tutoring at uni.

Just have to remember to check the differences for intialisation / setup.
Like this for using the usart


Start
if Processor == 16F628 ;Initialisation routine for 16f628
CLRF PIR1 ;Clear interrupt flags register
CLRF PORTA
CLRF PORTB ;Clear ports to output all 0's
BSF STATUS, RP0 ;Set RAM Bank 1
CLRF PIE1 ;Clear interrupt enable flags
CLRF TRISA ;Set all port a to outputs
MOVLW .6
MOVWF TRISB ;Port B all outputs except for USART TX/RX
else ;Initialisation for 16f877
CLRF PIR1
CLRF PIR2 ;Clear interrupt flags registers
CLRF PORTA
CLRF PORTB
CLRF PORTC
CLRF PORTD
CLRF PORTE ;Clear ports to output all 0's
BSF STATUS, RP0 ; Set RAM Bank 1
MOVLW .7
MOVWF ADCON1 ;PortA and PortE all digital I/O
CLRF TRISA ;Port A all outputs
CLRF TRISB ;Port B all outputs
MOVLW .192 ;Port C all outputs except for UART RX TX
MOVWF TRISC
CLRF TRISD ;Port D all outputs
CLRF TRISE ;Port E all outputs
endif


Alex
 
Top