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

more problems with printf!!!

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



Joined: 19 Oct 2004
Posts: 40

View user's profile Send private message

more problems with printf!!!
PostPosted: Wed Nov 10, 2004 11:46 am     Reply with quote

I use a PIC 16F872 and a Max 232 CPE.
I have some problems with the printf function.
For exemple :
1)
..........................
printf ("f1,\n\r");
delay_ms(100);
value=Read_ADC();
printf("A/D value=%2x \n\r",value);
printf("f2,\n\r");

What happen? I read in my computer only f1. It doesn't appear A/D... and f2. The program jumps all the printf afther the first!!!

2)
....................................
printf ("f1,\n\r");
printf ("f2,\n\r");

What happen? In this case the answer is correct. I read in my computer f1 and f2.

3) Between printf f1 and printf f2 I changed the lines. Before I wanted to read a value after a ADC and now I use some lines from the DS1624.c driver of CCS. I want to read a temperature value.

..................................
printf ("f1,\n\r");
init_temp();
temp=read_temp();
printf("Temp(F):%6.4f\r\n",temp);
printf ("f2,\n\r");

what happen? the same that 1). Only I read in my computer f1.

Conclusion : When I try to read a value from out the PIC I can't read it using the function printf.

What happen? Does anyone know the solution of this problem?
Thanks for your answer.
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Wed Nov 10, 2004 12:55 pm     Reply with quote

My conclusion Very Happy you didn't setup the ADC correctly and its waiting for the value. Nothing to do with printf.
SherpaDoug



Joined: 07 Sep 2003
Posts: 1640
Location: Cape Cod Mass USA

View user's profile Send private message

PostPosted: Wed Nov 10, 2004 2:35 pm     Reply with quote

From what you have told us Mark's conclusion seems right. Try commenting out one line at a time to see what the effect of each one is.
_________________
The search for better is endless. Instead simply find very good and get the job done.
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Wed Nov 10, 2004 2:47 pm     Reply with quote

To prove me right Very Happy angel could add
Code:
printf ("f1,\n\r");


after the ADC call since we know that this printf works correctly.
angel



Joined: 19 Oct 2004
Posts: 40

View user's profile Send private message

OK it is the ADC!!!
PostPosted: Mon Nov 15, 2004 1:15 pm     Reply with quote

hi
Ok it seems it is the ADC.
My software is :
...........................
main(){

int value;
setup_port_a(ALL_ANALOG);
setup_adc(ADC_CLOCK_INTERNAL);
set_adc_channel(2);
while(1) {
if (kbhit) {

printf("f1 \n\r");
delay_ms(100);
value=Read_ADC();
printf ( "A/D value =%2x \n\r");
printf("f2 \n\r");
}
}
}


--------------------------------------------
--------------------------------------------
I try to read the out from a CNY70 sensor. It works correctly.
is "set_adc_channel(2);" the pin_A2?
is the software correct?
My PIC is a 16F872 and my quartz is 4 MHz.
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