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

Hexa command sending problem

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



Joined: 04 Aug 2007
Posts: 18

View user's profile Send private message

Hexa command sending problem
PostPosted: Mon Oct 01, 2007 9:32 am     Reply with quote

I'm using a PIC 16F877A and I try to send a command "0x0D" on the rs232 but it's not working.

My program is

Code:


#include <16F877A.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)

void main() {

int x;

x=0x0D;

  do {

       printf("%x", x);
     
   } while (TRUE);
}



I tried also "%2x" or "%c" and putc(0x0D) but it's not working too.

Any help will be very welcome.

Dominik
kevcon



Joined: 21 Feb 2007
Posts: 142
Location: Michigan, USA

View user's profile Send private message

PostPosted: Mon Oct 01, 2007 9:43 am     Reply with quote

try

Code:

printf( "\r" );
Dominik



Joined: 04 Aug 2007
Posts: 18

View user's profile Send private message

PostPosted: Mon Oct 01, 2007 11:06 am     Reply with quote

Code:
printf( "\r" );

This is not working too ...

But there's something strange because the program seems to work with the CCS PCM C Compiler, Version 4.013 and doesn't working with mine's CCS PCM C Compiler, Version 4.038.
kevcon



Joined: 21 Feb 2007
Posts: 142
Location: Michigan, USA

View user's profile Send private message

PostPosted: Mon Oct 01, 2007 11:14 am     Reply with quote

How is it not working exactly?

Are you getting an error message when you compile?



I'm using 4.038 and have no problems.
Dominik



Joined: 04 Aug 2007
Posts: 18

View user's profile Send private message

PostPosted: Mon Oct 01, 2007 11:23 am     Reply with quote

The program is compiled good but the datas sent are strange characters and the ones in the program.

Might come from this part ?

Code:
#include <16F877A.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
kevcon



Joined: 21 Feb 2007
Posts: 142
Location: Michigan, USA

View user's profile Send private message

PostPosted: Mon Oct 01, 2007 12:32 pm     Reply with quote

I doubt it is a problem with the part, it's more likely that your PC's baudrate is slightly off, or your crystal is not exactly 4Mhz

Try a slower baudrate like 1200


Give this a try too.

Code:

#pragma use rs232( stream = UART_1 , baud = 1,200, UART1, parity = N, BITS = 8 )

fprintf( UART_1, "\r" );

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