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

Bug in printf command???

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







Bug in printf command???
PostPosted: Thu Feb 02, 2006 3:54 pm     Reply with quote

My program:

Code:

#include <16F876A.h>
#device *=16
#use delay(clock=20000000)
#use rs232(baud=19200,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)

void main()
{
  int8 a=10, b=100;
 
  printf("a = %d\n",a);
  printf("b = %d\n",b);
  delay_ms(10);
}


Result:
aaaa10
b = 100

First string is BAD!!!
Second string is OK.
Why???
Ttelmah
Guest







PostPosted: Thu Feb 02, 2006 4:03 pm     Reply with quote

Unless you pull the signal line high, and (assuming you are using a MAX232), wait a while for it's capacitor charge pump to get going, the signal being received by a computer connected at the other end, will be 'indeterminate' for a while when the PIC starts....
I'd suspect this is resulting in the computer 'missing' the correct edge in the first character, and returning garbage for a moment.

Best Wishes
filodendron
Guest







PostPosted: Thu Feb 02, 2006 8:40 pm     Reply with quote

Code:

#include <16F876A.h>
#device *=16
#use delay(clock=20000000)
#use rs232(baud=19200,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)

void main()
{
  int8 a=10, b=100;

  printf("a = %d\n",a);
  printf("b = %d\n",b);
  printf("a = %d\n",a);  //repeated first command
  delay_ms(10);
}



The result of this modified code is:
aaaa10
b = 100
aaaa10

I don't understand about it.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Feb 02, 2006 9:07 pm     Reply with quote

Post your #fuses statement.
Eugeneo



Joined: 30 Aug 2005
Posts: 155
Location: Calgary, AB

View user's profile Send private message

PostPosted: Fri Feb 03, 2006 12:15 am     Reply with quote

That's strange. Have you tried a couple other variations?
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Fri Feb 03, 2006 1:56 am     Reply with quote

Strange results, but as PCM programmer already asked you, please post your #fuses statement. You are running at 20MHz and the default fuses don't work in that situation, you require at least the HS crystal fuse.

What is your compiler version? Without that we can't check for the same results.
filodendron
Guest







PostPosted: Fri Feb 03, 2006 3:02 am     Reply with quote

I am working with the PIC bootloader (www.microchipc.com).
This contains:
Code:

#define FOSC D'20000000'    ; <<< set quartz frequence [Hz], max. 20 MHz

IF FOSC<=D'4000000'
  #define _MYCRYSTAL _XT_OSC ;see datasheet
ELSE
  #define _MYCRYSTAL _HS_OSC
ENDIF

__CONFIG _CP_OFF & _WDT_OFF & _BODEN_OFF & _PWRTE_ON & _MYCRYSTAL & _WRT_OFF & _LVP_OFF & _DEBUG_OFF & _CPD_OFF

I have the latest version of the compiler (3.242).
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