Searching \ for '[PIC]: No ADC on the PIC12F675' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/ios.htm?key=adc
Search entire site for: 'No ADC on the PIC12F675'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]: No ADC on the PIC12F675'
2002\11\26@154827 by Gordon Varney

flavicon
face
What am I doing wrong??????? I would appreciate any help.

Note: this code works on a PIC12C671.

The ADC does not work, I have tried init in ASM and C.  Still does not
work.

CCS C V. 3.127
MPLAB5.70.40
PIC12F675

----------------------------------------------------------------------
------------------------------------------------------

#include <12F675.h>
#use delay(clock = 20000000,RESTART_WDT)     // 1/(20000000/4) =
1/5000000 = .0000002 (200ns)
#fuses HS,WDT,PUT,NOCPD,NOPROTECT,NOMCLR,BROWNOUT
#use fast_io(A)

int8 value;               //adc value
int8 s1;                 //adc sample #1
int8 s;
int8 loop;               //loop for off time
int8 p;

void ADtest(void) {   //read the input voltage
    do {
    restart_wdt();
         //          value = read_adc();    //read the ADC
   #asm asis
         bsf    0x1F,0x0
         nop
         bsf    0x1F,0x1
         nop
   ag:
         btfsc  0x1F,0x1          //I do not see the compiler turning
this bit on or off
         goto   ag                    //using the read_adc() command,
so I wrote it in ASM.
         movf   adresh,W      //I get a small variation in the output
but no ADC to speak of.
         movwf  value
         bcf    0x1F,0x0
    #endasm
                   output_high(42);
                   delay_ms(10);
                   output_low(42);
                   delay_ms(10);
                   s1=value;
                   do {                //this routine will pulse one
time for each bit
                       output_high(42);    //measured in the ADC.
                       delay_ms(1);
                       output_low(42);
                       delay_ms(1);
                       s1=(s1-1);
                   } while(s1 <= 1);
                     p = 0;
                     delay_ms(100);
    } while(p == 0);
}

//////////////////////////////////////////////////////////////////////
//////////////////////////////
#zero_ram
void main() {
    setup_wdt(wdt_144ms);
    setup_timer_0(RTCC_INTERNAL | RTCC_DIV_4);
    setup_comparator(NC_NC_NC_NC);
    setup_vref(false);
    setup_adc(ADC_CLOCK_DIV_32);   //I tried this in ASM also, still
does not work
    setup_adc_ports(AN0_ANALOG);
    set_adc_channel(0);

    restart_wdt();
    set_tris_A(0b00111011);
    delay_cycles(10);
    output_A(0b00111011);
    delay_cycles(10);

    restart_wdt();
    ADtest();

}
----------------------------------------------------------------------
-------------------------
Gordon Varney

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email spam_OUTlistservTakeThisOuTspammitvma.mit.edu with SET PICList DIGEST in the body


2002\11\26@213503 by Eric von Hoene

picon face
--- Gordon Varney <.....gordonvKILLspamspam@spam@IAMNEE.COM> wrote:
> What am I doing wrong??????? I would appreciate any
> help.
>
> Note: this code works on a PIC12C671.

<snip>

{Quote hidden}

<snip>

Gordon,
the 12C671 is an 8-bit ADC, the 12F675 is 10-bit.  You
need to select if you want the value left-justified or
right-justified in ADRESH and ADRESL (look at the ADFM
bit in ADCON0).  If you have it right-justified, then
ADRESH only has the top 2 msb's, and you won't get
much response!

hope this helps,
Eric

__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email listservspamKILLspammitvma.mit.edu with SET PICList DIGEST in the body


2002\11\26@215829 by Dale Botkin

flavicon
face
On Tue, 26 Nov 2002, Gordon Varney wrote:

> What am I doing wrong??????? I would appreciate any help.
>
> Note: this code works on a PIC12C671.
>
> The ADC does not work, I have tried init in ASM and C.  Still does not
> work.
>
> CCS C V. 3.127
> MPLAB5.70.40
> PIC12F675

Have you looked at the .LST file?  I had lots of problems with the 12F675,
turns out there were some bugs (lots of 'em) with CCS & 12F675/629 up
until 3.2-something.  I emailed them and asked, they said to upgrade to
the latest code, but my support had run out.  After a brief back and forth
the support guy enabled my download support long enough to get the latest
updates.  Nice people.  I may need to move to an 18F on another project,
I'll upgrade to PCW 18 if so.

Dale

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email .....listservKILLspamspam.....mitvma.mit.edu with SET PICList DIGEST in the body


2002\11\27@092340 by Gordon Varney

flavicon
face
Eric,
       Yes, my original code was for the 10 bit ADC when that did not work,
I converted to 8 bit.  The left and right justify through me at first,
mostly trying to figure out why I would want it right justified. Then
it hit me (thump) Oh, left Justify for 8 bit and read only the ADRESH
register, or right justify and read both for 10 bit.

Actually, there is a bug in MPLAB V5.70.00 and v. 5.70.40, in the
debugger. If you are trying to simulate the PIC12F675 the debugger
will not activate some of the registers, and you can not simulate the
ADC.  I found this out last night after putting a Microchip app.
engineer on the spot. If you are using a PIC12F675 you need to be
using MPLAB v. 6.10.00 or newer, however CCS will not be compatible
until v 6.20.00. You can use v. 6.10.00 and read in the CCS hex file.
MPLAB will then load the xxx.c file. Set the part type and simulate.
This works great. I hope to find the problem this morning.

Gordon Varney
http://www.iamnee.com
http://www.talk2it.com Voice recognition project.

{Quote hidden}

--
http://www.piclist.com hint: To leave the PICList
piclist-unsubscribe-requestspamspam_OUTmitvma.mit.edu


2002\11\27@092547 by Gordon Varney

flavicon
face
Thanks, I will look closer and see if there is anything obvious.

Gordon Varney
http://www.iamnee.com
http://www.talk2it.com A voice recognition project

{Quote hidden}

--
http://www.piclist.com hint: To leave the PICList
KILLspampiclist-unsubscribe-requestKILLspamspammitvma.mit.edu


2002\11\27@100530 by Dale Botkin

flavicon
face
On Wed, 27 Nov 2002, Gordon Varney wrote:

> Thanks, I will look closer and see if there is anything obvious.

I seem to recall in my case the problems were mostly related to delay_ms
and delay_us not being correct in some cases.  Setting internal RC osc
mode really screwed things up, and it wasn't loading the osccal when it
should have.

Dale

--
http://www.piclist.com hint: To leave the PICList
RemoveMEpiclist-unsubscribe-requestTakeThisOuTspammitvma.mit.edu


2002\11\27@102031 by Gordon Varney

flavicon
face
Dale,
       I am running an external 20Mhz ceramic resonator. The timing appears
to be correct. The part runs, I just get no ADC value.  Vref is VDD
and the input to AN0 can be adjusted from 60mv to 4.2V. The ADC
returns [0].

Using MPLAB v. 6.10.00 the simulator indicates that the ADC should be
working. The step through looks good... ??????

More confused, to much information, overload inevitable...... Caution
Will Robinson........Danger, Danger......

Gordon Varney
http://www.iamnee.com
http://www.talk2it.com A voice Recognition project.


{Quote hidden}

--
http://www.piclist.com hint: To leave the PICList
TakeThisOuTpiclist-unsubscribe-requestEraseMEspamspam_OUTmitvma.mit.edu


2002\11\28@155033 by Dwayne Reid

flavicon
face
At 02:46 PM 11/26/02 -0600, Gordon Varney wrote:
>What am I doing wrong??????? I would appreciate any help.
>
>Note: this code works on a PIC12C671.
>
>The ADC does not work, I have tried init in ASM and C.  Still does not
>work.

There are several differences between the 12c671 and the 12f675.  Of
particular note is that the a/d go/done bit is in a different location
(ADCON0,1 vs ADCON0,2) and the requirement for setting the ADSEL
register.  Also pay attention to CMCON - it may also affect the a/d (I
don't remember right now).

dwayne

--
Dwayne Reid   <RemoveMEdwaynerspamTakeThisOuTplanet.eon.net>
Trinity Electronics Systems Ltd    Edmonton, AB, CANADA
(780) 489-3199 voice          (780) 487-6397 fax

Celebrating 18 years of Engineering Innovation (1984 - 2002)
 .-.   .-.   .-.   .-.   .-.   .-.   .-.   .-.   .-.   .-
    `-'   `-'   `-'   `-'   `-'   `-'   `-'   `-'   `-'
Do NOT send unsolicited commercial email to this email address.
This message neither grants consent to receive unsolicited
commercial email nor is intended to solicit commercial email.

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


More... (looser matching)
- Last day of these posts
- In 2002 , 2003 only
- Today
- New search...