mpc5200btiny linux quickstart l-679e

Add to My manuals
105 Pages

advertisement

mpc5200btiny linux quickstart l-679e | Manualzz

phyCORE-MPC5200B tiny/IO QuickStart Instructions

3.5 Changing the Demo

Now we will extend the myHelloWorld application. The extended myHelloWorld application will write an output on the serial interface ttyPSC0 and the standard output.

Open Eclipse if is not opened yet.

Double-Click HelloWorld.c in the myHelloWorld project.

First include two additional header files:

#include <unistd.h>

#include <fcntl.h>

Then add the function write_tty to write n bytes to the serial interface /dev/ttyPSC0.

void write_tty(char *buffer, int count)

{

int out;

out=open("/dev/ttyPSC0",O_RDWR);

write(out,buffer,count);

close(out);

}

Enter the following two lines in the main function to declare the buffer und call the write_ttyS0() function.

char buf[]={"Welcome to the World of the phyCORE-

MPC5200

(ttyPSC0)\n"}; write_tty(buf,sizeof(buf)-1);

On the next screenshot you can see the complete program.

74

© PHYTEC Messtechnik GmbH 2007 L-679e_5

Getting More Involved

Save your program after changing the code.

The Application will be compiled, built, copied to the target and executed.

Executing the program on the target with Komport:

Click on the Komport icon on the desktop

If your are not logged in, enter root and press enter.

Type ./myHelloWorld to start the application.

You will see the following output:

Welcome to the world of the phyCORE-MPC5200! (ttyPSC0)

Welcome to the world of the phyCORE-MPC5200!

© PHYTEC Messtechnik GmbH 2006 L-679e_5

75

advertisement

Related manuals