56F8013 writing to SCI QuickStart

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

56F8013 writing to SCI QuickStart

4,018 次查看
RGehring
Contributor II
I am using CW8.0 with the 56F8013Demo board.  And I am using Quick Start codes.  I have everything setup correctly, based off the sample applications.  I can send data with
"    write(SCI_0, BUFFERED, buff, sizeof(buff)-1);   "
code as long as buff is a const char definted above main as
" char buff[] = "Hello World";    "
But when I try to send ADC data out to through the SCI like:
volatile UWord16 w1;
w1 = ioctl( ADC, ADC_READ_SAMPLE, 1);
write(SCI_0, BUFFERED, w1, sizeof(w1)-1);
But it errors out complaining "illegal implicit conversion from 'volatile unsigned short' to 'const char *'
I don't know how to make w1 to a const char.  I have tried using sprintf to a char variable, but that didn't work.  Anyone know of any other ideas?

Thank you,
Rob.
标签 (1)
标记 (1)
0 项奖励
回复
6 回复数

1,654 次查看
trytohelp
NXP Employee
NXP Employee
Hi,
 
Do you refer to an example delivered on the installation ?
Can you please provide us more details about the Quick Start code ?
 
Pascal
0 项奖励
回复

1,654 次查看
RGehring
Contributor II
I got QuickStart from freescale:
http://www.freescale.com/webapp/sps/site/prod_summary.jsp?code=DSP56800EQUICKSTART&fsrch=1

You have to setup CW to recognize it the code correctly.  But I used the sample applications to run my code.  In my code attached, it works perfectly if I comment out both:
            w1c=w1;
            write(SCI_0, BUFFERED, w1c, sizeof(w1c)-1);

with them in there, it complains that wlc is not a const char *, while the line
            write(SCI_0, BUFFERED, buff, sizeof(buff)-1);
works fine because it is defined as a const char *. 
Or if I change
            write(SCI_0, BUFFERED, w1c, sizeof(w1c)-1);
to
            write(SCI_0, BUFFERED, w1, sizeof(w1)-1);
it also complains because w1 is a Uword16 and not a const char.  I am just wondering how I could get the data from w1 into a const char to send it over SCI.  Will I have to use pointers and just redefine where a const char of say w1_buff it pointing to and have it point to where w1's data is?

Hopefully this is what you are looking for.
Thanks for the help.
Rob.
0 项奖励
回复

1,654 次查看
trytohelp
NXP Employee
NXP Employee
Hi,
 
Humm, DSP56800E_Quick_Start r2.3 ...
I've never used it.
This is a code generattor tool like Processor Expert.
The support for this product is provided by another team.
In order to investigate the problem I want to suggest you to log it in CRM system.
 
I suggest you to log your request to the Freescale CRM system.
Please use Freescale on line support web page.
  - Go to following URL: http://www.freescale.com/TechSupport
  - Click on Submit a Service Request to create a new one or Manage Existing Service Request.
  - You will come to a login page.
  - You can submit your request through the web from there or view the activities of a SR.
Pascal
0 项奖励
回复

1,654 次查看
RGehring
Contributor II
I solved my problem.  I figured I would post it here too; to convert a UWord16, or probably any anything to char, I used this function:
void convert(UWord16 w_adc)
{
    char buffer[6];
    char *back;
    UWord16 w_adc2 = w_adc;
   
    back = buffer + 5;
    *back = 0;
    do {                           
           *--back = w_adc2 % 10 + '0';    /* Taken from http://tinyurl.com/3xruhq */
        w_adc2 /= 10;
    } while (w_adc2);
        if(w_adc<= 9999 && w_adc>=1000)
            buffer[5] = 0x00;
        if(w_adc<=999 && w_adc>=100)
        {     buffer[5] = 0x33; buffer[4] = 0x33; }
        if(w_adc<=99 && w_adc>=10)
        {     buffer[5] = 0x00; buffer[4] = 0x00; buffer[3] = 0x00; }
        if(w_adc<=9 && w_adc>=0)
        {     buffer[5] = 0x00; buffer[4] = 0x00; buffer[3] = 0x00; buffer[2] = 0x00; }
    write(SCI_0, BUFFERED, (char *)&buffer, 6);
}
It will take each letter/number from w_adc and put it into the buffer char.  Then to output it you have to use the pointer to the location of the char.  The if statements get rid of the trailing zero's at the end of the buffer, definitely needed.
0 项奖励
回复

1,654 次查看
jag
Contributor IV
Use Unions Luke! :smileyhappy:

example (perhaps depending on endianess, you can have bytes swapped):

union { short a;
 unsigned char b[2];
      } union_var;
unsigned char *pb;

pb = &union_var;
union_var.a = ioctl( ADC, ADC_READ_SAMPLE, 1);
write(SCI_0, BUFFERED, pb, sizeof(union_var));

or without unions:

UWord16 temp;
UWord8 buf[2];

temp = ioctl( ADC, ADC_READ_SAMPLE, 1);

//if you prefer you can change low part-high part...
buf[0] = (temp >> & 0x00FF; //high part
buf[1] = temp & 0x00FF; //low part

write(SCI_0, BUFFERED, buf, 2);

I've not tested this code...

Bye Jack


0 项奖励
回复

1,654 次查看
trytohelp
NXP Employee
NXP Employee
Hi,
 
Thanks for the feedback.
Don't hesitate to contact us.
 
Regards
Pascal
0 项奖励
回复