I have some boards I need to test before committing labour and some expensive peripherals. I have changed the thread name as the older one was getting off the track I thought.
I have partly loaded just the bare minimum parts to implement the attached circuit on my target PCB and the LEDs do not flash. To decide whether the problem is my code or a PCB fault, I have built this circuit on two different proto boards. They don't flash the LEDs either so I suspect my code. I also built up a second target PCB so I now have four copies of the problem which I am sure will be solved with some 'ah-ha' moment from one of the smart PBP3 forum members.
Numerous forum users have made suggestions, for which I thank you, but the code is still no go.
OSCTUNE is of no consequence. I do not care if the clock is +/- 50% so I think I can ignore OSCTUNE. LED brightness truly does not matter at this point and believe me 1k is plenty bright enough for indoor close range use.
OSCCON is vital. If you want to use any of the frequencies listed in OSCCON (except 31 KHz), you must have OSCCON bits 0 & 1 set for "Internal Oscillator Block" which is 1x. If these bits are 0 0 then the PIC expects a clock to be supplied on RA6 pin 13 (40 pin DIP variant).
I have used an oscilloscope to check for ClkOut on pin RA.7 and to ensure the reset line is +5. The chip has both power and ground pins correctly supplied.
I am using PBP3.0.7.4 MCSPX 5.0.0.5 MPASM
Any assistance greatly appreciated.
Cheers
BrianT
code:
data @0, "Wet ver a 2 Nov 2013 "
'Internal 8 MHz clock. INTIO1 Internal Oscillator with FOSC/4 output
'on RA6 and I/O on RA7 - I wish!.
'******************* Configuration fuses ***************************
' Device = PIC18F4620
' Osc = INTIO1 (ClkOut), FSCM = En, Int Ext Switch = En, PwrUpTmr = En,
' BrownOut = Dis, BrwnOut Volt = 2, WDT = Dis, WDT PostScaler = 512
' CCP2 on RC1, PortB Rst = Digital, LowPwr Tmr1 Osc = Higher power,
' MCLR = Reset, Stack Over/Under = En, LowVoltProg = Dis,
' Enhanced CPU = Dis, ALL FOLLOWING set to Not Protected.
'********************** DATA and DEFINES ***************************
DEFINE OSC 8
'Select INTIO1 (ClkOut) in the configuration menu at programming.
'Use OSCCON to select frequency & select internal oscillator block
'Use CRO to see if any ClkOut visible on Osc2/ClkOut pin 14(40) or 31(44)
Initialise:
LED1 var PORTE.1 'LATE.1 does not work either
LED2 var PORTE.2 'LATE.2 does not work either
TRISE = %00001000 'make sure PSP is OFF & MCLR active
PORTE = %00001000 '
OSCCON = %11111110 ' 8 MHz Internal Osc Block
' 0------- IDLEN 0 = enters SLEEP on Sleep command. Board draws 4 uA
' 1------- IDLEN 1 = enters IDLE on Sleep command and draws 550 uA
' -111---- IRCF <2:0> Int Osc freq select 111 = 8 MHz
' -110---- IRCF <2:0> Int Osc freq select 110 = 4 MHz
' -101---- 2 MHz
' -100---- 1 MHz
' -011---- 500 kHz
' -010---- 250 kHz
' -010---- 125 kHz
' -000---- 31 kHz
' ----0--- OSTS Osc Startup Status - read only - ignore
' -----0-- IOFS IntOsc Freq Stable - read only - ignore
' ------00 System Clock Select 00 = Primary Osc = external xtal
' ------01 Secondary (Timer1) oscillator
' ------1x Internal oscillator block.
WDTCON = %00000001 ' enables SWDT - needs WDT OFF in config
' xxxxxxx1 SWDTEN software controlled WDT enabled
ADCON0 = %00000000 ' ADC OFF
' xx0000-- CH<3:0> select analog channels
' ------0- 1 = Go, 0 = Done
' -------0 1 = ADC ON, 0 = ADC OFF
ADCON1 = %00001111 'VRef = Vdd, Vss, All ports digital
' configures all digital
' 00------ Unimplemented
' --00---- VCFG<1:0> Select Vcc & Gnd as ADC references
' ----0110 PCFG<3:0> A/D Port configuration see "register 19-1"
CMCON = %00000111 ' Comparators OFF
' 00------ No comparator outputs
' --00---- No inversion on outputs
' ----0--- Vin to pins AN0 & AN1
' -----111 Comparators OFF
MainLoop:
High LED1 '
high led2
Pause 10 '
Low LED1 '
low led2
Pause 10 '
Goto mainloop '
End
endcode:
Bookmarks