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

problem with putc()

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



Joined: 05 Jul 2006
Posts: 10

View user's profile Send private message

problem with putc()
PostPosted: Sat Jul 22, 2006 9:00 pm     Reply with quote

i need help with putc(), it's a strange problem,
i declare int8 dummy, dummy1;
Code:

         dummy=1;
         dummy1=255;
         printf("start");
         for(i=0;i<12928;i++)
         if((i%129)==0)
            putc(dummy);
         else
         putc(dummy1);


and dummy1 and dummy are suppose to be color data (0 being white, and 255 being black)

when I use 1 as white everything works perfect, but when I set dummy=0, then the picture is all messed up

the pc software has no problem, I can use 0 when no communication with PIC...so can putc() not send 0?
Thanks in advance
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Jul 22, 2006 11:20 pm     Reply with quote

Yes, putc() can send a 0. Here is a test program:
Code:

#include <16F877.h>
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)

//======================
void main()
{
int8 c;

c = 0;

putc(c);

while(1);
}


Here is the code generated by vs. 3.249 of the compiler,
with comments:
Code:

0000            00311 ... int8 c;
0000            00312 ... 
0000            00313 ... c = 0;     
0016 01A1       00314 CLRF   21   // Set 'c' to 0x00
0000            00315 ... 
0000            00316 ... putc(c);
0017 0821       00317 MOVF   21,W // Move 'c' into W reg.   
0018 1E0C       00318 BTFSS  0C.4 // Wait until UART is ready
0019 2818       00319 GOTO   018
001A 0099       00320 MOVWF  19   // Put W into the TXREG
0000            00321 ... 
0000            00322 ... 
0000            00323 ... while(1); 
001B 281B       00324 GOTO   01B
0000            00325 ... }

SYMBOL TABLE
  LABEL                             VALUE

main.c                            00000021
 

This code shows that a variable can be set to 0 and transmitted
by the UART.
Ttelmah
Guest







PostPosted: Sun Jul 23, 2006 3:23 am     Reply with quote

As PCM programmer says, putc, must definately can send a '0'. I'd be wondering about other possible problems. How is the connection made?. remember a '0' will be unique in having eight consecutive 'low' bits, and some connections (wireless for example, or something with a capacitive connection), can at times show problems with such a data pattern.

Best Wishes
sheing3003



Joined: 05 Jul 2006
Posts: 10

View user's profile Send private message

PostPosted: Tue Jul 25, 2006 12:17 pm     Reply with quote

the connection is by serial port, rs232...
i don't know why it's behaving like that, it should work, but it's not...
the strangest thing is that when I replace 0 with 1, (there's 255 color bits so replacing 0 with 1 doesn't really matter, since our eyes cant tell), when i replace 0 with 1 everything works fine... but if i leave the 0 as it is my image get all screwed up....
still can't figure it out...

but i guess it works...probably just my program
Ttlemah
Guest







PostPosted: Tue Jul 25, 2006 2:50 pm     Reply with quote

As a suggestion, are you using the 'MScomm' active-X control to retrieve the data at the PC?. If so, 'null discard', needs to be set to false, or 0 characters will not be returned...

Best Wishes
sheing3003



Joined: 05 Jul 2006
Posts: 10

View user's profile Send private message

PostPosted: Wed Jul 26, 2006 5:35 pm     Reply with quote

Ttlemah wrote:
As a suggestion, are you using the 'MScomm' active-X control to retrieve the data at the PC?. If so, 'null discard', needs to be set to false, or 0 characters will not be returned...

Best Wishes


ooo!! that might be the reason! thanks for the suggestion
now i gotta figure out how to set that to false...lol
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