PDA

View Full Version : XT oscillator mode & configuration bits



Ramonetnet
- 22nd April 2008, 23:48
Good evening. I want to use 18F452 with "XT" oscillator mode (4 MHz xtal)

I have read the thread "18F Config fuses", and there is just one question in my mind :

If I use the statement "config OSC=XT" in MPASM,
then I do NOT have to write into "CONFIG1H" ?
( I think the "XT oscillator" corresponds to a value of 0x21 )

Is there any way to confirm this, watching the CODE.HEX file ?

Thanks. Ramon.

Raflex
- 23rd April 2008, 07:58
Good evening. I want to use 18F452 with "XT" oscillator mode (4 MHz xtal)

I have read the thread "18F Config fuses", and there is just one question in my mind :

If I use the statement "config OSC=XT" in MPASM,
then I do NOT have to write into "CONFIG1H" ?
( I think the "XT oscillator" corresponds to a value of 0x21 )


Just one time


Is there any way to confirm this, watching the CODE.HEX file ?

Thanks. Ramon.


Import .hex file and check configuration fuses

Ramonetnet
- 23rd April 2008, 10:29
Xcuse my poor english, mr Raflex, but ... what does "Just one time" mean ?
I HAVE TO SET "CONFIG1H" or NOT ?

And to the second part ... when you say "IMPORT THE HEX FILE" ...
... you mean into which tool ???

Thanks for your help. Ramon.

Acetronics2
- 23rd April 2008, 10:40
Hi, Ramon

hre you have an example for a '452




'************************************************* ****************************
'************************************************* ****************************
'Config processeur
'************************************************* ****************************
'

'@ __CONFIG _CONFIG1L, _WDT_OFF_1L & _WDTPS_128_1L
@ __CONFIG _CONFIG1H, _OSCS_OFF_1H & _XT_OSC_1H
@ __CONFIG _CONFIG2L, _BOR_OFF_2L & _BORV_27_2L & _PWRT_ON_2L
@ __CONFIG _CONFIG2H, _WDT_OFF_2H & _WDTPS_128_2H
'@ __CONFIG _CONFIG3L, _WDT_OFF_3L & _WDTPS_128_3L
@ __CONFIG _CONFIG3H, _CCP2MX_OFF_3H
@ __CONFIG _CONFIG4L, _STVR_OFF_4L & _LVP_OFF_4L & _DEBUG_OFF_4L
'@ __CONFIG _CONFIG4H, _WDT_ON_4H & _WDTPS_128_4H
@ __CONFIG _CONFIG5L, _CP0_OFF_5L & _CP1_OFF_5L & _CP2_OFF_5L & _CP3_OFF_5L
@ __CONFIG _CONFIG5H, _CPB_OFF_5H & _CPD_OFF_5H
@ __CONFIG _CONFIG6L, _WRT0_OFF_6L & _WRT1_OFF_6L & _WRT2_OFF_6L & _WRT3_OFF_6L
@ __CONFIG _CONFIG6H, _WRTC_OFF_6H & _WRTB_OFF_6H & _WRTD_OFF_6H
@ __CONFIG _CONFIG7L, _EBTR0_OFF_7L & _EBTR1_OFF_7L & _EBTR2_OFF_7L & _EBTR3_OFF_7L
@ __CONFIG _CONFIG7H, _EBTRB_OFF_7H



It's a PbP example, so ... just remove the "@" if pure asm from MPLAB ...

Better to write ALL the config at top of program : that avoids bad surprises !!!

Alain

PS: to verify in MPLAB :

1) FILE\ Import \ Yourfile.Hex

2) CONFIGURE\ Configuration bits

Ramonetnet
- 24th April 2008, 11:51
mr ACETRONICS : thanks for the sample.

Here is my code ( I am using MPLAB IDE v 8.0, just downloaded from MicroPic ),
which says basically the same : a value for configuration bits.

My question was if that line ( config OSC=XT ) is enough at run time,
as I see it does NOT generate any code, and we want position 0x300001 to have a 0x25, don't we ?

Thanks for the "IMPORT HEX FILE" trick.
It looks like "config OSC=XT" does generate the code !

Maybe it is this line in the HEX file :

:0100010021DD

In some (strange) way, the first "01" shall say "0x300000", the next "00001" selects "0x300001", then the data is "0021" hex, and 0xDD must be some kind of checksum ...

Ramon.

================================================== =============

;
; primer programa ASM del PIC
;
; Conectar el pin 5 (RA3) a R=1 K cap al Anode del LED.
; XTAL 4 MHz entre pin 13 i 14.
; 2x C (22pf) del pin 13 i 14 a massa.

; list p=16f452
#include <p18f452.inc>

; Configuration bits :
;
; Oscillator mode := XT ;
; Watch Dog Timer := off ;
; Low Voltage Programming := on :

config WDT=OFF
config OSC=XT

; User data

===================================

> type FLED.hex

:020000040000FA
:0400000080EF00F09D
:08000800D59EF2942190110035
:0400180020EF00F0E5
:02002A000000D4
:10004000D8CF23F0E8CF24F0E0CF22F022C0E0FFA9
:0A00500024C0E8FF23C0D8FF100011
:100100000F01936A816A926A806A0F01F28EF28A05
:10011000550E806E92EC00F0AA0E806E9CEC00F002
:1001200088EF00F0F00ED66E216A2180C80ED56EE1
:1001300021B098EF00F01200FF0E206E202E9EEFEF
:1001400000F012005555AAAA320C320C2F0C300CBC
:10015000340C2F0C320C300C300C380C2C0C200CC6
:10016000760C200C310C2E0C320C610C5555AAAAC1
:020000040030CA
:0100010021DD
:010003000EEE
:00000001FF