View Full Version : 18F1220 fuse help
mr.sneezy
- 23rd May 2010, 14:32
Hi all,
Anybody got a code fragment of how they set the fuses and special registers to dumb down a PIC18F1220 to use internal OSC (8Mhz) and no A/D's, and no other special features, just plain digital I/O on all pins (other than power pins)...
I've RTFM'd and set accordingly (I think), but still can't flash a simple LED on PortA.0, so I must be overlooking something that I'm not used too coming from 16F series PICs ?
malc-c
- 23rd May 2010, 16:19
Post up your current config settings and I'm sure someone will correct them.
mr.sneezy
- 24th May 2010, 00:06
This is the config sections plus the pin var definitions, not the whole code. As I don't get a flash on PortA.1 at startup for 500mS the rest is sort of irrelevant I think.
Thanks in advance,
Martin
(T-rex 450 and 500 pilot :-)
PS. I have remarked out the _Config lines in 18F1220.INC in PBP directory
'-----------------------
' PIC Defines
' ===========
'Config bits set to INTERNAL OSC, Watch dog ON, Power up timer ON, Master Clear NOT used, BrownOut protection ON,
'@ device pic16F819, intrc_osc, wdt_on, pwrt_on, mclr_off, bod_off, lvp_off, DEBUG_OFF, CPD_OFF, WRT_OFF ;Config switches, different from PBP default
'Config1H register
@ CONFIG OSC=INTIO2
' Oscillator switch OFF
'
'Config2L register
@ CONFIG BOR=ON, PWRT=ON, BORV=27
' Brown out reset ON @ 2.7Volts
' Power-up timer ON
'
'Config2H register
@ CONFIG WDT=ON
' Watch dog timer ON
'
'Config4L register
@ CONFIG STVR=ON, LVP=OFF, DEBUG=OFF
' Stack over/underflow ON
' Low Voltage programming OFF
' Background debugger OFF
Define Osc 8 '8Mhz clock used.
CPIN var PortB.0 ' I2C clock pin
DPIN var PortB.1 ' I2C data pin
SO Var PortA.0 'Serial out pin
LED var PortA.1 'Indicator LED, via 500ohm to +3.3V rail
' Initialise Processor - check for each PIC type
' --------------------
' VRCON.7 = %0 'Comparator voltage reference OFF
' CMCON0 = %111 'Comparator inputs to OFF, all pins normal I/O
' ADCON0 = 0 'Turn off all AD's
ADCON1 = %11111111 'Turn off all AD's
' Osccon = %01100000 'set INTRC to 4 MHZ
' Set initial state of GPIO port pins as Input or Output
TRISA = %11111100 'Input(0 = output, 1 = Input)
TRISB = %11111100 '
' PIC initialization code
Low So 'Must start low, or you get rubbish on the LCD at PIC boot up.
Low LED 'LED on
pause 500
High LED 'LED off
mackrackit
- 24th May 2010, 09:16
First I do not see how you are handling MCLRE in the configs or hardware.
Second, take a look at the P18F1220.inc in the MPASM directory. That will show the correct way of setting the configs. They should be in this format
@ __CONFIG _CONFIG1H, _OSC_HS_1H
@ __CONFIG _CONFIG2H, _WDT_OFF_2H & _WDTPS_128_2H
@ __CONFIG _CONFIG4L, _LVP_OFF_4L
mr.sneezy
- 24th May 2010, 10:59
Thanks Dave, yes the MCLRE was the magic missing ingredient. I thought I'd done that last night but noooo....
I did look in the P18F1220.INC and followed it's advice. It actually says this, and shows the word 'Important' in loud capitals...
;================================================= =========================
;
; IMPORTANT: For the PIC18 devices, the __CONFIG directive has been
; superseded by the CONFIG directive. The following settings
; are available for this device.
;
; Oscillator Selection:
; OSC = LP LP Oscillator
; OSC = XT XT Oscillator
; OSC = HS HS Oscillator
etc etc for about 50 lines of Config choices.
I added this to get my PIC alive.
'Config3H register
@ CONFIG MCLRE=OFF
'Reset pin disabled
It works fine for me, no PBP compile errors, so is it really the wrong way to write the configs ?
I have a new issue though, I sped up the INT OSC to 8Mhz with the OSCCON and set 'Define Osc 8' to match, but the code is executing now twice as fast as it should, like the Define Osc 8 is not being used by PBP. Can that happen for some reason ?
Acetronics2
- 24th May 2010, 13:11
Hi,
Both methods work ...
the old one still is in "old" devices .inc files :
; To embed the Configuration Bits in your source code, paste the
; following lines into your source code in the following format,
; and change the configuration value to the desired setting (such
; as WDT_OFF to WDT_ON).
; These lines are commented out - each __CONFIG line should have the
; preceding semicolon (;) removed when pasted into your source code.
; __CONFIG _CONFIG1H, _IESO_ON_1H & _FSCM_OFF_1H & _RC_OSC_1H
; __CONFIG _CONFIG2L, _PWRT_ON_2L & _BOR_OFF_2L & _BORV_27_2L
; __CONFIG _CONFIG2H, _WDT_OFF_2H & _WDTPS_32K_2H
; __CONFIG _CONFIG3H, _MCLRE_ON_3H
; __CONFIG _CONFIG4L, _DEBUG_OFF_4L & _LVP_ON_4L & _STVR_ON_4L
; __CONFIG _CONFIG5L, _CP0_OFF_5L & _CP1_OFF_5L
; __CONFIG _CONFIG5H, _CPB_OFF_5H & _CPD_OFF_5H
; __CONFIG _CONFIG6L, _WRT0_OFF_6L & _WRT1_OFF_6L
; __CONFIG _CONFIG6H, _WRTC_OFF_6H & _WRTB_OFF_6H & _WRTD_OFF_6H
; __CONFIG _CONFIG7L, _EBTR0_OFF_7L & _EBTR1_OFF_7L
; __CONFIG _CONFIG7H, _EBTRB_OFF_7H
from the "up to date" .inc file of the '1320 ... ( MPLAB 8.50 )
using those, we only Get an "Info message" from MPASM ... telling there's a new ( simplified ??? ) way ...
The old way advantage ??? ...:D there are templates available in the MPASM .inc files !!!
Alain
PS:
in MPLAB, for Pic 18 ... there's a tool named Visual initializer ... that could help.
see :
; Initialization Code for PIC18F2520, Family: GP control, Package: 28-Pin SDIP 28pins
#include P18F2520.inc
; Filter Controls used to Generate Code:
; POR Match Filter OFF
; Provisioned Feature Filter OFF
; Masks are Ignored and uses UnMasked Register Writes
; Feature=fuses - fuses (DCR) configuration
; B7=IESO B6=FCMEN B3:0=FOSC3:0
CONFIG1H=0x02
; B4:3=BORV1:0 B2:1=BOREN1:0 B0=PWRTEN-L
CONFIG2L=0xEB
; B4:1=WDTPS3:0 B0=WDTEN
CONFIG2H=0xE0
; B7=MCLRE B2=LPT1OSC B1=PBADEN B0=CCP2MX
CONFIG3H=0xFF
; B7=DEBUG-L B6=XINST B2=LVP B0=STVREN
CONFIG4L=0xFF
; B3:0=CP3:0
CONFIG5L=0xFF
; B7=CPD B6=CPB
CONFIG5H=0xFF
; B3:0=WR3:0
CONFIG6L=0xFF
; B7=WRTD B6=WRTB B5=WRTC
CONFIG6H=0xFF
; B3:0=EBTR3:0
CONFIG7L=0xFF
; B6=EBTRB
CONFIG7H=0xFF
...
isn't life marvellous ???
mr.sneezy
- 24th May 2010, 14:54
Thanks Alain, glad I was doing something OK.
I like the new method, I was never very happy with all the _underscore stuff going on with the other method so I'll stick with it.
(Perhaps there is a need for a new template library in this forum somewhere for the new syntax).
I'll have a look at the tool you pointed out, thanks. I got to say I'm having information overload with this particular project, I've changed PIC's twice now from my original choice, and it caused headaches both times. Hoping to settle down to writing useful code real soon.
Cheers,
Martin
Powered by vBulletin® Version 4.1.7 Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.