PDA

View Full Version : What am I doing wrong?



Charles Linquis
- 29th November 2007, 18:13
I have the simplest piece of code that I have probably ever written, but it still doesn't work. The code is as follows, and is supposed to flash a LED connected to PortF.1 The LED refuses to flash.

Chip is 18F66J60
Crystal is 25MHz (yes, I know my flash rate will be off)
Watchdog timer is OFF
Oscillator is set to OSC1,OSC2 inputs and "HS mode"
An oscilloscope confirms that the crystal is oscillating with
a good 25MHz signal.

Can someone tell me what I'm doing wrong?


DEFINE OSC 20

TRISF = %00000000 ' Make all output
ADCON1 = %11111111 ' Make certain that PortF.1 is digital
CMCON = %00000000 ' Disable comparator outputs


Flash:

PortF.1 = 1
PAUSE 1000
PortF.1 = 0
PAUSE 1000
GOTO Flash


END

Darrel Taylor
- 29th November 2007, 18:48
ADCON1 = 15
CMCON  = 7
  ??
<br>

Charles Linquis
- 29th November 2007, 20:45
Problem solved!

In our lab, we had an old version of MPLAB (7.20) that apparently didn't support the 18F67J60 properly. I upgraded to MPLAB version 8.0 - VOILA! The LED is flashing now.

Charles Linquis
- 29th November 2007, 20:54
I should also mention that I use an ICD2 to load code. MPLAB version 7.2 was setting the configuration registers incorrectly.

mister_e
- 29th November 2007, 20:55
first post it was a 66J60, and now 67J60 ;)

it still work even with CMCON=0 ? but yeah.. maybe as long as there's nothing attach to the comparator input... it shouldn't caused any grief.. i'm just a little bit surprised ;)

EDIT: thanks for the update about ICD2

Darrel Taylor
- 29th November 2007, 21:40
Can't imagine Charles using less than 128K.
So I believe it was a 67J60 all along. :)
<br>

Charles Linquis
- 29th November 2007, 21:46
A typo. I'm using an 18F67J60

And Darrel, you are correct. I'm constantly hammering on Microchip to build a bigger 18F part.
It seems that I might be getting their attention. Stay tuned!