PDA

View Full Version : IcePic2 & EPROM PIC, Different?



Mark Scotford
- 31st December 2004, 14:58
Last Night I put the finishing touches to my now enormous but fully functioning program, using my trusty IcePic2. This morning I was ready to Demo my creation to my customer, but was not in a position to show it with the IcePic, so I blew an EPROM version of the PIC17C756A, for demonstration purposes. Bugger me, but my program is now playing up badly, seeing inputs being made when they are not (rang the customer to cancel the appointment). I went back to the IcePic2 and everything was OK. Please can somebody help this newbie with some suggestions. I have a feeling its something to do with the ADCON statements. One question I would like answered please, is it OK to keep switching on and off the ADC? do I need to add wait statements after switching it off. I do lots of reads with the ADC at various times. I disable the ADC with an ADCON1=11101111 after doing a read, is this correct? The program also uses I2C reads and writes, I've put wait's after all the writes as it says in the book. I have the following code near the top of my program

ADCON1 = %11101111

DEFINE ADC_BITS 10
DEFINE ADC_CLOCK 3
DEFINE ADC_SAMPLEUS 50

GoTo MAIN

mister_e
- 31st December 2004, 18:08
why not trying with the Flash replacement 18F6520 (as microchip says... )

For sure simulation and real world can be different. But i can't say, 'cause i never test it, that's a good pratice to switch analog pin to digital... possible that you need delay. But i don't understand why you want to switch from analog mode to digital.

if you want to shut down the Analog converter, you must use ADCON0.0=0

Bruce
- 31st December 2004, 19:02
Hi Mark,

> seeing inputs being made when they are not <

Inputs will act flakey if left floating. If you have internal or external pull-ups or pull-downs, and your switches reverse the pull-up/pull-down logic when made, inputs should behave normally.

Without internal or external pull-ups/pull-downs, reading a floating input pin will return unexpected results.

< is it OK to keep switching on and off the ADC? <

It shouldn't matter if you switch the A/D module on or off, but you're not switching off the A/D module by writing to ADCON1. ADCON0.0 turns on/off the A/D converter module.

ADCON0.0 = ADON: A/D On bit

ADCON0.0=0 ' A/D converter module is shut-off
ADCON0.0=1 ' A/D converter module is operating

ADCON1 is for the A/D Conversion Clock Select bits, A/D Result Format Select, A/D Port Configuration Control bits, and A/D Voltage Reference Select bit.

If your external circuit maintains analog signals on your A/D inputs, I wouldn't recommend you set these A/D inputs to digital by writing 11101111 to ADCON1.

Analog levels on any pin that is defined as a digital input including the AN15:AN0 pins, may cause the input buffer to consume current that is out of the devices specification which could lead to odd problems depending on several factors.

> do I need to add wait statements after switching it off <

I have never experienced any problems turning an A/D module on or off without wait periods afterwards, but you do need to wait for the required acquisition time after turning the A/D module on via ADCON0.0 before starting the conversion via ADCON0.2.

> I disable the ADC with an ADCON1=11101111 after doing a read, is this correct? <

No. If you need to conserve power you can turn off the A/D module to reduce power consumption by clearing ADCON0.0, but you definitely don't want to make analog input pins "digital " inputs by ADCON1=11101111 with external analog signals connected to them.

Mark Scotford
- 1st January 2005, 19:16
I need to switch from Analogue to Digital because of the limited range of options available. What I mean is that the ADCON statement (as I understand it) only has 8 options to switch different combinations of Analogue and Digital on and off, with the 16 ADC channels available. Unfortunatly its too late to change which pins I am using for what function. So I assumed it would be best just to turn the whole lot off after doing a read, so that it does not affect the input pins I am not using as ADC channels.

None of my Digital (Nor my analogue) inputs are left floating, every input has its own 10K pull up.

"ADCON0.0=0 ' A/D converter module is shut-off
ADCON0.0=1 ' A/D converter module is operating" I will try this, I had come to the conclusion (and I can't remember how) that this simple statement did not apply to the PIC17C756A, will let you know the results. I will assume I can use the "ADCON0.0=0" anywhere and as many times as I like????

I was not aware of the PIC18F6520, till you mentioned it (ain't this forum just great?) I am currently changing all of my other products from OTP to Flash, but when I looked for a 17F756A, I found nothing, thanks for the info, will check all my Programs/Hardware can deal with this product.

Will let you all know how I get on, and thank you for your patience with this old newbie.

Mark Scotford
- 3rd January 2005, 21:16
I tried placing several ADCON0.0=0's in with no joy, I have just two inputs playing up and I double, treble checked all my TRIS commands etc, with no joy. As a last resort I thought I would try an OTP version instead of an EPROM version and guess what it works perfectly again, same as it did when using my IcePic2, will start a new thread asking why, thanks to all those who tried to help.

Bruce
- 3rd January 2005, 21:23
Hi Mark,

What "exactly" is it that's not working?

Are you using a few pins on one port for A/D, and other pins on this same port as digital inputs?

Is there any difference between the OTP verrsion and the EPROM version besides the obvoius?

Mark Scotford
- 3rd January 2005, 21:31
Yes I have mixed up Analogue inputs and digital inputs on the same port, but I read them at different times. The chips are identical, same part number, just one has a window and the other does not. I am sort of happy that I have found the problem, but this does create another one, that I cannot do any beta testing with reprogrammable chips, could get expensive!

Mark Scotford
- 3rd January 2005, 21:35
Forgot to mention that exact problem, I have two Digital Inputs on PortE.0 and PortA.1 that are being read as low, when they are not.

Bruce
- 3rd January 2005, 21:37
What are you covering the EPROM version UV window with?

I have seen odd behavior with UV erasable parts when the UV window was left uncovered, or when covered by material that doesn't block ambient light.

Mark Scotford
- 3rd January 2005, 21:46
Just tried covering the window with black tape, did not make any difference. Its always the same two inputs that play up.

Bruce
- 3rd January 2005, 23:16
> Just tried covering the window with black tape, did not make
> any difference

You would need to erase it first, then place several layers of tape over the UV window, then reprogram it with the tape in place. If exposure to light is causing it to act oddly, then there's a good chance EPROM registers have already been corrupted.

I've tried black electrical tape too, and found it normally took several layers to effectively block ambient light.

I wouldn't think A/D configuration would affect RA1 or RE0 with ports F & G being analog, but you never know.

Assuming you have config fuse settings set for Microcontroller mode, RE0 should work fine. RA0/INT looks relatively normal, but
if you can make it work on the OTP version, and not on the EPROM version, even with the UV window covered, I would contact Microchip. There may be some subtle difference causing all your headaches.

I gave up on windowed parts years ago when I had similar problems.