Forums

BF518 UART sending a txt file to the pc.

Started by Chagai Ensenberg June 22, 2010
Hi All,

I just started using the BF518 with the EZkit. As a new user engineer (first
job) I have some simple questions:

1) I couldn't find an example to using UART and RS-232 to send a file back
to pc. all the initializations etc. Is there a reference / example (talk
through)
preferebly in C?

2) if I use UART do I have to use a hyperterminal program?

My task is to receive an audio signal (of about 0.5sec) sample it and store
it. then do FFT create a txt file of the fft and send it via UART.
thanks for any help,

Chagai
Chagai,

There's probably some good examples on Analog Device's website. I can't
recall seeing one that describes the UART, but I haven't looked for one.
Look for Blackfin tutorials (there are some video ones) or post your
question to the Blackfin forum at ez.analog.com.

As far as using a hyperterminal program...you'll need something to receive
the data on the PC. If you just have to transfer the file once, sure, use a
hyperterminal program. If the file is transferred at some regular interval,
like several times a minute or second or even hour, then I'd write some app
for the PC to automatically receive the data and write it to a file. RS-232
is probably your best bet for the UART. You could use an intermediary chip
to convert the UART signals to USB if you want to communicate through USB. I
don't have much experience with USB, to advise that approach.

David

On Tue, Jun 22, 2010 at 4:37 AM, Chagai Ensenberg <
c...@sds-digitalradio.com> wrote:

> Hi All,
>
> I just started using the BF518 with the EZkit. As a new user engineer
> (first job) I have some simple questions:
>
> 1) I couldn't find an example to using UART and RS-232 to send a file back
> to pc. all the initializations etc. Is there a reference / example (talk
> through)
> preferebly in C?
>
> 2) if I use UART do I have to use a hyperterminal program?
>
> My task is to receive an audio signal (of about 0.5sec) sample it and store
> it. then do FFT create a txt file of the fft and send it via UART.
> thanks for any help,
>
> Chagai
>
Hi Chagai

You can use the fwrite function:
I have put the function into a method print_to_txt.
It will place the txt file sample.txt in your current project folder in the
Debug folder.

void print_to_txt(int array_to_print[], int length) {

int nnn2 = 0;
FILE *fp;
fp = fopen("sample.txt", "w"); // sample.txt is the name of the txt
file.
char buffer[8] = {'0','0','0','0','0','0','0','0'};
int buflen = 0;

for (nnn2=0; nnn2 < length; nnn2++)
{
buflen = sprintf(buffer,"%X",array_to_print[nnn2]);
fwrite (buffer, sizeof(char), buflen, fp);
fwrite ("\n", sizeof(char) , strlen("\n") , fp);
}
fclose(fp);
}

//Call it from within your program like this:
print_to_txt(array, 7000); //7000 is the length of your array.

Best regards
Benjamin