Jump to content
Sign in to follow this  
Prefekt

Adc With Pic 12f675

Recommended Posts

Hi,

my code for adc with the PIC 12F675 works fine with C2C. But now I have the SourceBoost and the compiler tells me, that are any errors in my code. But I cant find any errors...

 

Here is the part with the ADC

/*- Variablen ------------------------------------------------------------- */

char ADCon0@0x1F;

char ADCon1@0x9F;

char ADResH@0x1E;

char ADResL@0x9E;

short sResult; // 16Bit ADResH & ADResL

 

/*- Config ---------------------------------------------------------------- */

//option_reg;

trisio=001001b;

//cmcon=7;

 

/*- Am Anfang den Port ausschalten und 2 sec warten ------------------------*/

gpio=000000b;

delay_s(2);

 

/*- Configure ADC module ---------------------------------------------------*/

set_bit(STATUS, 'RP0');

ADCon1 = 00000100b;

clear_bit(STATUS, 'PRO');

ADCon0 = 10000001b;

 

/*- Lüfter erst mal volle Drehzahl -*/

gpio=000010b;

delay_s(4);

 

/*- Programmschleife ------------------------------------------------------ */

while(1)

{

int i=0;

int iDelay=16;

int iDelta=CMaxTemp-CMinTemp;

 

/*- Meßvorgang -*/

clear_bit (ADCon0,3); // Select RA0

set_bit (ADCon0,1); // Start AD-Conversion

 

while ((ADCon0 & 2) == 2)

{

nop();

}

 

sResult = ADResH;

sResult <<= 8;

sResult |= ADResL;

 

Has anybody an sample for ADC conversation with PIC 12F675 and SourceBoost?

 

Thanks

Volker

Share this post


Link to post
Share on other sites
Here is the part with the ADC
*- Variablen ------------------------------------------------------------- */
char ADCon0@0x1F;
char ADCon1@0x9F;
char ADResH@0x1E;
char ADResL@0x9E;
short sResult;					// 16Bit ADResH & ADResL
/*- Configure ADC module ---------------------------------------------------*/
set_bit(STATUS, 'RP0');
ADCon1 = 00000100b;							
clear_bit(STATUS, 'PRO');
ADCon0 = 10000001b

 

Try commenting out the definitions @specific memory locations

char ADCon0@0x1F;
char ADCon1@0x9F;
char ADResH@0x1E;
char ADResL@0x9E;

If that still leaves errors try removing the quotes in

set_bit(STATUS, 'RP0');
ADCon1 = 00000100b;					
clear_bit(STATUS, 'PRO');

and be certain that PRO is a defined register.

 

If that helps I'll be as astonished as you! ;)

Share this post


Link to post
Share on other sites
If that still leaves errors try removing the quotes in

set_bit(STATUS, 'RP0');
ADCon1 = 00000100b;                    
clear_bit(STATUS, 'PRO');

and be certain that PRO is a defined register.

 

If that helps I'll be as astonished as you! ;)

 

You dont need to set the banking, the compiler looks after that for you!

Share this post


Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...