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 CCS Technical Support

long_data again

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



Joined: 28 May 2005
Posts: 14

View user's profile Send private message

long_data again
PostPosted: Thu Jun 09, 2005 2:53 am     Reply with quote

Dear Users of CCS C compiler

I want to send 16 bit value from PIC to PIC by radio (cc1000 chip) in
mode transparent UART and put it to LCD in "RECEIVE PIC"ALL work wery fine when I send and receive single 8bit value
eg.
In TX putc('U'); , in RX c=getc();
NECESSARY INVERT I realize by hardware (transistor) therefore I can to use PIC UART in hardware mode.
Is many examples in this forum but generality for send or receiving from or to PC computer no PIC to PIC

simply kod

#use RS232(...... Long_data,bits=9 ...)

.................................................
TX:
while(true)
{
value=45678;

putc(value):

delay_ms(10);


............................................

RX:
#use RS232(...... Long_data,bits=9 ...)

long c:
........................................................

while(true)
{
c=getc()

printf(lcd_putc,"\f\%05lu",c);


}


...........................................

NOT WORK

Thanks in advance

Best regards

JAN

PS

TX PIC 18F252,RX PIC 18F458
compiler 3.221
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Jun 09, 2005 5:22 pm     Reply with quote

The compiler generates incorrect code for the putc() function
when the LONG_DATA parameter is used. The code for the
getc() function looks OK. So you need to create your own putc()
function for 9-bit data. I've done that in the program below.
It's called putc_9_bits().
I don't have a terminal program that uses 9 bits, so I can't test
this, but I believe it should work.

Code:
#include <18F458.h>
#fuses XT, NOWDT, NOPROTECT,PUT,BROWNOUT,NOLVP
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, BITS=9, LONG_DATA, ERRORS)

#byte TXREG = 0xFAD
#byte TXSTA = 0xFAC
#byte PIR1  = 0xF9E

#bit TXIF = PIR1.4
#bit TX9D = TXSTA.0

void putc_9_bits(int16 c)
{
while(~TXIF);

TX9D = bit_test(c, 8);

TXREG = c;
}

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

while(1)
  {
   c = getc();

   putc_9_bits(c);
  }

}
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