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

Question about UART transmission

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



Joined: 29 Sep 2004
Posts: 39
Location: Paris (France)

View user's profile Send private message

Question about UART transmission
PostPosted: Wed Oct 13, 2004 3:09 am     Reply with quote

Hi everybody!

I have a simple question regards the UART interface with CCS Compiler : is it possible to send a simple byte like 0x2C on the serial port, which is not an ASCII character ?

Rolling Eyes

Thanks for your support
dvsoft



Joined: 28 Nov 2003
Posts: 46

View user's profile Send private message

PostPosted: Wed Oct 13, 2004 3:41 am     Reply with quote

bonjour

yes completely why?

Alain
YulL



Joined: 29 Sep 2004
Posts: 39
Location: Paris (France)

View user's profile Send private message

PostPosted: Wed Oct 13, 2004 3:52 am     Reply with quote

Coucou Surprised

Ok I have to send 0x0001C8C8 to a module with USART interface, but I'm not sure that my program will work, I'm going to test it in a few days.

Here is my code :

while(getc()!=0x10) {} // Attente du "Frame Char" pour se synchroniser
printf(lcd_putc,"\fSynchro OK!\n");

trame=getc(); // Lecture de la suite
if(trame=0x0001C8C8) output_high(LED0);


Thanks for the reply Wink
Ttelmah
Guest







PostPosted: Wed Oct 13, 2004 4:07 am     Reply with quote

YulL wrote:
Coucou Surprised

Ok I have to send 0x0001C8C8 to a module with USART interface, but I'm not sure that my program will work, I'm going to test it in a few days.

Here is my code :

while(getc()!=0x10) {} // Attente du "Frame Char" pour se synchroniser
printf(lcd_putc,"\fSynchro OK!\n");

trame=getc(); // Lecture de la suite
if(trame=0x0001C8C8) output_high(LED0);


Thanks for the reply Wink

A _byte_. only holds 8bts of data. The serial link transfers data a byte at a time. What you need is something like:
Code:

union dblock {
    int32 word;
    int8 b[4];
} buffer;
int 8 count;
   

   while(getc()!=0x10);// Attente du "Frame Char" pour se synchroniser
   printf(lcd_putc,"\fSynchro OK!\n");

   for (count=0;count<4;count++) {
      buffer.b[count]=getc();           // Lecture de la suite
   }
   if(buffer.word=0x0001C8C8L)
       output_high(LED0);[/color]

You will have to check whether the data is send least significant byte first or last, and change the count to correspond. This reads the four successive bytes, into b[0]...b[4], and then performs a test with the resulting 32bit 'word'.

Best Wishes
YulL



Joined: 29 Sep 2004
Posts: 39
Location: Paris (France)

View user's profile Send private message

PostPosted: Wed Oct 13, 2004 4:27 am     Reply with quote

Thanks for your help! Cool
I will try it in a few days (I haven't the possibility to test it yet).

it is "if(buffer.word=0x0001C8C8) output_high(LED0);" and not "if(buffer.word=0x0001C8C8L) output_high(LED0);" ?

Wink
dvsoft



Joined: 28 Nov 2003
Posts: 46

View user's profile Send private message

PostPosted: Wed Oct 13, 2004 8:24 am     Reply with quote

bonjour,

ATTENTION
in C language the test operator is "=="
if (testValue == 0x0001C8C8)
output_high(LED0);



Alain
YulL



Joined: 29 Sep 2004
Posts: 39
Location: Paris (France)

View user's profile Send private message

PostPosted: Wed Oct 13, 2004 8:40 am     Reply with quote

Thanks Alain, have a nice evening Wink
Ttelmah
Guest







PostPosted: Wed Oct 13, 2004 10:48 am     Reply with quote

YulL wrote:
Thanks for your help! Cool
I will try it in a few days (I haven't the possibility to test it yet).

it is "if(buffer.word=0x0001C8C8) output_high(LED0);" and not "if(buffer.word=0x0001C8C8L) output_high(LED0);" ?

Wink

'L', means force use of a 'long'. Though the compiler _should_ automatically detect that something 'larger' than 0xFF, needs a long comparison, I never trust it, and will always explicitly declare anything larger than 8bit, as a long.

Best Wishes
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