CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

V3.169 and ADC whit pic18f1320... crap

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Lars Molnit
Guest







V3.169 and ADC whit pic18f1320... crap
PostPosted: Thu Jul 24, 2003 5:17 am     Reply with quote

What happendt, I got the 3.169 update, and then my 10bit AD doesent work any more... to get the corect value I have to use this line :

ADCValue=ADCValue>>6;

To get the right resoult ?????

The test code I use is hier :

#include <18F1320.h>
#device ADC=10
#fuses INTRC,NOWDT,PUT,BROWNOUT,BORV20,MCLR,NOLVP,NODEBUG
#use delay(clock=8000000) //8 MHz
#use rs232(baud=2400, xmit=PIN_B1, rcv=PIN_B4)
#byte OSCCON = 0x0FD3

void main() {
unsigned int16 ADCValue=0x0000;
#use standard_io(A)
#use standard_io(B)
OSCCON = 0b11111001;
SETUP_ADC_PORTS(NO_ANALOGS | sAN0 | VSS_VDD);
SETUP_ADC(ADC_CLOCK_INTERNAL | ADC_TIME_0_TAD);
SET_ADC_CHANNEL(0);

while (1)
{
ADCValue=Read_ADC(ADC_START_AND_READ);
ADCValue=ADCValue>>6;
delay_ms(500);
printf("\%lu \r",ADCValue);
};
}
___________________________
This message was ported from CCS's old forum
Original Post ID: 144516309
hhoebel
Guest







Re: V3.169 and ADC whit pic18f1320... crap
PostPosted: Mon Jul 28, 2003 2:03 am     Reply with quote

Hi,

i'm using too the 18F1320 with 3.169 and found a bug in the compiler itself. It took me a long time to find this. The compiler uses the wrong registers when using setup_adc.

When using setup_adc(ADC_CLOCK_DIV_16|ADC_TIME_20_TAD|ADC_START_ONLY) or something similar the compiler produces:

0926: MOVLW BD
0928: MOVWF FC2
092A: BSF FC2.0

which is definitly wrong, as this is the adcon0-register and the above settings are found in adcon2 (FC0).
With setting the register without "setup_adc" all works fine.
So simply use the #byte statement for setting up the adc instead of using setup_adc and it will work.

regards,

Heiko

P.S.: i send this to CCS but got no answer
___________________________
This message was ported from CCS's old forum
Original Post ID: 144516419
ritchie



Joined: 13 Sep 2003
Posts: 87

View user's profile Send private message

Re: V3.169 and ADC whit pic18f1320... crap
PostPosted: Wed Mar 03, 2004 9:21 am     Reply with quote

Lars Molnit wrote:
What happendt, I got the 3.169 update, and then my 10bit AD doesent work any more... to get the corect value I have to use this line :

ADCValue=ADCValue>>6;

To get the right resoult ?????

The test code I use is hier :

#include <18F1320.h>
#device ADC=10
#fuses INTRC,NOWDT,PUT,BROWNOUT,BORV20,MCLR,NOLVP,NODEBUG
#use delay(clock=8000000) //8 MHz
#use rs232(baud=2400, xmit=PIN_B1, rcv=PIN_B4)
#byte OSCCON = 0x0FD3

void main() {
unsigned int16 ADCValue=0x0000;
#use standard_io(A)
#use standard_io(B)
OSCCON = 0b11111001;
SETUP_ADC_PORTS(NO_ANALOGS | sAN0 | VSS_VDD);
SETUP_ADC(ADC_CLOCK_INTERNAL | ADC_TIME_0_TAD);
SET_ADC_CHANNEL(0);

while (1)
{
ADCValue=Read_ADC(ADC_START_AND_READ);
ADCValue=ADCValue>>6;
delay_ms(500);
printf("\%lu \r",ADCValue);
};
}
___________________________
This message was ported from CCS's old forum
Original Post ID: 144516309


OSCCON = 0b11111001; ---> is this really needed for a PIC18F1320 especially you use the internal oscillator?

Need comments please?

Thnx
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group