View Full Version : 18f452 initialization
Moldava
- 18th June 2004, 00:46
Hello,
i wrote a program for the 16f877,and want to port it to the 18f452..i know i have to use mpasm to complie it...i'd also like to know how to initialize it for using the internal 40mhz from a 10mhz crystal...
Thanks!!!!
TONIGALEA
- 18th June 2004, 20:08
Its not difficult at all
the way i do this is to modify the 18f452.INC file in pbp to the following :
;************************************************* ***************
;* 18F452.INC *
;* *
;* By : Leonard Zerman, Jeff Schmoyer *
;* Notice : Copyright (c) 2001 microEngineering Labs, Inc. *
;* All Rights Reserved *
;* Date : 12/19/01 *
;* Version : 2.41 *
;* Notes : *
;************************************************* ***************
NOLIST
ifdef PM_USED
LIST
"Error: PM does not support this device. Use MPASM."
NOLIST
else
LIST
LIST p = 18F452, r = dec, w = -302, f = inhx32
INCLUDE "P18F452.INC" ; MPASM Header
; Configuration BYTE 1H Options
;_OSCS_ON_1H Oscillator Switch enable
;_OSCS_OFF_1H
;_LP_OSC_1H Oscillator type
;_XT_OSC_1H
;_HS_OSC_1H
;_RC_OSC_1H
;_EC_OSC_1H External Clock w/OSC2 output divide by 4
;_ECIO_OSC_1H w/OSC2 as an IO pin (RA6)
;_HSPLL_OSC_1H HS PLL
;_RCIO_OSC_1H RC w/OSC2 as an IO pin (RA6)
NOLIST
endif
LIST
EEPROM_START EQU 0F00000h
BLOCK_SIZE EQU 8
i then use the following
'@ __CONFIG _CONFIG1H, _OSCS_OFF_1H & _HSPLL_OSC_1H 'for 10mhz running at 40mhz
@ __CONFIG _CONFIG1H, _OSCS_OFF_1H & _HS_OSC_1H 'For normal 8-20mhz
Toni
TONIGALEA
- 19th June 2004, 11:09
Or post your code if you have any problems.
you should not have to make changes except if you are using interupts
and also remember that you have to define your osc speed as 40 not 10mhz
Toni
Moldava
- 19th June 2004, 15:12
Thanks !!!!
i will try it today,i'm almost sure it will work,because it does not use interrupts,and no pause or oscillator related critical functions...
Another question,is the ad converter initialization different in 18f452? i want it to convert as fast as possible,i had good results with the ad in 16f877,and i wonder if i could run it faster in the 18f...
thanks a million again..
Maneco
TONIGALEA
- 20th June 2004, 14:46
Everything else should be ok , just take a read through this
http://www.microengineeringlabs.com/support/mcu_hints.htm
Toni
Powered by vBulletin® Version 4.1.7 Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.