a very noob question -_-

Thread Starter

Macabra

Joined May 31, 2008
49
Hello! :)

It's been ages since I've done programming and I can't remember how to do conversions of data types. I'm using UART to transmit data through the serial RS232 but the function to do so only takes int...

void putsUART1(unsigned int *buffer) __attribute__ ((section (".libperi")));

void WriteUART1(unsigned int data) __attribute__ ((section (".libperi")));

so I can send integers that's fine but how do I do it if I want to print character strings?? :confused: something like "hello world"?

Oh right and this is in C by the way!
much thanks
 
Last edited:

Papabravo

Joined Feb 24, 2006
14,241
There are at least two ways to do it, yielding slightly different results.

1. You can print the least significant byte (LSB) of each integer
OR
2. You can print the the least significant byte (LSB), followed by the next most significant byte until the entire integer has been rendered as characters.

Which alternative did you have in mind?
 

Papabravo

Joined Feb 24, 2006
14,241
Ok, you fetch a character from a string and apply an explicit cast.

Rich (BB code):
unsigned char TestString[] = "Test String" ;
 
void foo(void)
{
....
    p = &TestString[0] ;
    while(*p != '\0')
    {
        WriteUART1( (unsigned int) *p++) ;
    }
....
}
 
Top